Page 1 of 1
as under Cygwin: weird error
Posted: Wed Aug 25, 2004 11:46 pm
by Colonel Kernel
I'm trying to move my project (currently the BareBones C example with a bit of my own stuff) from my Linux VM to Cygwin. Everything builds fine under Linux, but I'm getting a weird error from as under Cygwin:
Code: Select all
loader.asm:33: Error: junk at end of line, first unrecognized character is `,'
make: *** [loader.o] Error 1
The line it refers to is:
Code: Select all
.comm stack, STACKSIZE, 32 # reserve 16k stack on a quadword boundary
I've already ruled out the possibility of a CR/LF problem. The as versions are as follows:
Linux: 2.14.90.0.5 20030722
Cygwin: 2.15.91 20040725
Is this a known problem?
If I comment out the offending line, it assembles ok, but then ld fails with "PE operation on non-PE file", but I gather this is part of the reason to build a cross-compiler (maybe next week

).
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 12:45 am
by Solar
The as error has the same reason as the ld error: You are not compiling for an ELF target.
.comm accepts a third parameter
only for ELF targets (as writ in the binutils/as manual). Once you have the cross-compiler set up, your woes will be gone.
(You should have built a cross-compiler under Linux, too, if only to avoid including standard headers, linking in the C runtime or getting funny sections in your object files by accident. You just were lucky.

)
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 4:30 am
by srg
Solar wrote:
The as error has the same reason as the ld error: You are not compiling for an ELF target.
.comm accepts a third parameter
only for ELF targets (as writ in the binutils/as manual). Once you have the cross-compiler set up, your woes will be gone.
(You should have built a cross-compiler under Linux, too, if only to avoid including standard headers, linking in the C runtime or getting funny sections in your object files by accident. You just were lucky.

)
Follow the Wiki and it's eeaaasssssyyyyy.
BTW to make a cross compiler for m68K, would I just change the target from i386-elf to m68K-elf?
thanks
srg
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 4:50 am
by Solar
srg wrote:
BTW to make a cross compiler for m68K, would I just change the target from i386-elf to m68K-elf?
An untested affirmative to that. (And tell me how it went, I'm intending to extend the page a bit.)
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 6:37 am
by srg
binutils built beautifully
but I got a configure error on gcc:
configure: error:
The following requested languages were not found: c++
The following languages were available: c treelang
Configure in /usr/src/build-gcc/gcc failed, exiting.
not sure about this one.
srg
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 7:18 am
by Candy
srg wrote:
binutils built beautifully
but I got a configure error on gcc:
configure: error:
The following requested languages were not found: c++
The following languages were available: c treelang
Configure in /usr/src/build-gcc/gcc failed, exiting.
Did you download & unpack the gcc-g++ package for your version?
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 8:10 am
by srg
Candy wrote:
srg wrote:
binutils built beautifully
but I got a configure error on gcc:
configure: error:
The following requested languages were not found: c++
The following languages were available: c treelang
Configure in /usr/src/build-gcc/gcc failed, exiting.
Did you download & unpack the gcc-g++ package for your version?
d'oh!
srg
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 8:28 am
by srg
One cross compiler.
I compiled this program:
Code: Select all
/* Test.c */
int main()
{
unsigned int count1, count2;
for (count1 = 0; count1 < 550 -1 ; count1++ )
{
count2 += 5;
}
return 0;
}
with this commandline:
$ /usr/cross/bin/m68k-elf-gcc.exe -O2 -nostdlib -nostdinc++ -nostdinc -fno-buil
tin -fsigned-char -ffreestanding --entry main test.c -o test.m68k
And after dissasembling with my new m68k objdump:
Code: Select all
test.m68k: file format elf32-m68k
Disassembly of section .text:
80000074 <main>:
80000074: 4e56 0000 linkw %fp,#0
80000078: 91c8 subal %a0,%a0
8000007a: 41e8 0009 lea %a0@(9),%a0
8000007e: b0fc 0224 cmpaw #548,%a0
80000082: 63f6 blss 8000007a <main+0x6>
80000084: 4280 clrl %d0
80000086: 4e5e unlk %fp
80000088: 4e75 rts
srg
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 8:43 am
by Candy
As far as I can read M68K code (no, it being at&t too doesn't really help) it seems OK.
Could you add your success to the Wiki page, or tell us which versions you used and on what platform (so we can add it) ?
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 8:49 am
by srg
Sure, I used binutils 2.15 and GCC 3.3.1-3.
my target was: m68K-elf. I did this on Cygwin btw.
the only difference in command line was the target and I just compiled for C, and not C++.
srg
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 9:14 am
by Colonel Kernel
Solar wrote:
The as error has the same reason as the ld error: You are not compiling for an ELF target.

It's a pretty misleading error message then.
"You're using an unsupported featu... uhh, I mean, I see junk on that line!" [me=Colonel Kernel]smacks the GNU programmers who don't know how to write good error messages

[/me]
I'll work on the cross-compiler next week... In the meantime, I was planning to switch from as to nasm -- will I run into the same problem (i.e. -- do I have to cross-compile nasm as well)?
Re:as under Cygwin: weird error
Posted: Thu Aug 26, 2004 9:20 am
by Candy
There is only one true nasm
The reason you have to recompile AS etc is because they work on X computers for Y targets with probably Z ways to do all things in there. You just disagree with the cygwin goal of Z and Y, but chose it because of X. Since their Y is your X, but your Y is different, you can use this compiler to make your own
Nasm has one input (nasm type source), multiple outputs that are all supported, and only one way to do it (just g*ddamn compile). That makes it a lot easier to get working decently

Re:as under Cygwin: weird error
Posted: Fri Aug 27, 2004 1:22 am
by Solar
@ Colonel:
GNU as is part of binutils, which in turn is the backend of GCC. No matter whether you want to use as or NASM for the ASM parts, you still need the binutils compiled for the target in order to have GCC running.
If you want to have ELF output, GCC must be configured to support it. The easiest way is to follow the GCC Cross-Compiler tutorial, since that is valid on any platform regardless.
As for the as error message: as configured for x86-ELF is a completely different program from as configured for m68k-COFF, for example. They don't even know about the feature set of the other. as not configured for ELF doesn't know that as configured for ELF accepts a third argument to .comm, so it can't tell you more than that...
Re:as under Cygwin: weird error
Posted: Fri Aug 27, 2004 9:19 am
by Colonel Kernel
Solar wrote:
GNU as is part of binutils, which in turn is the backend of GCC. No matter whether you want to use as or NASM for the ASM parts, you still need the binutils compiled for the target in order to have GCC running.
I know -- I just want to use nasm for the "pure asm" parts of my project. I converted my modified BareBones over last night (after a bit of futzing around... if I strip it down to the original example, maybe I can post the changes on the wiki) and it assembles ok, but goes back to the linker error... which I guess is expected, except for the fact that I told nasm to output PE format, so I'm not sure what ld is really complaining about...
If you want to have ELF output, GCC must be configured to support it. The easiest way is to follow the GCC Cross-Compiler tutorial, since that is valid on any platform regardless.
I actually don't necessarily want ELF output. My kernel image is a flat binary file that just uses the basic multiboot header to get itself loaded correctly by GRUB. So, the only choice to make is what intermediate format to use as the output of GCC/as and nasm (and consequently as the input to ld). Although I understand that I need to create a cross-compiler (which I will do as soon as I have time), I still don't really understand why the lack of one affects ld in this particular manner. No one has really explained that as far as I can see.
Re:as under Cygwin: weird error
Posted: Fri Aug 27, 2004 9:28 am
by beyondsociety
Even though nasm allows you to compile for PE-format, ld on cygwin will still bomb because its set to only support PE. You can either create a barebones gcc and ld for the desired output format you want or you can use a simple hack with make.
I set the output format in my linker script to "PE-i386" and then assemble my nasm code as gnuwin32 and C code as PE format (.EXE). I then use objcopy to convert it to a .bin file and it works perfectly. You can get objcopy to output whatever format you want: be it elf, binary, coff, etc.
Hope this helps.