[M3devel] the SOLgnu alignment problem finally understood
Jay K
jay.krell at cornell.edu
Mon Aug 3 10:36:24 CEST 2009
Here finally is a small example of the SOLgnu problem I've been looking at it.
It is specific to using /usr/sfw/bin/gcc -g to asssemble.
No problem without -g, no problem with /usr/bin/cc, no problem with
whatever I built in /usr/local/bin/gcc, no problem if you assemble
with anything else and then link with /usr/sfw/bin/gcc -g.
-bash-3.00$ cat 4.c asm.s
4.c
void Asm(void);
#include
int main()
{
Asm();
printf("\n");
return 0;
}
asm.s
.section ".text",#alloc,#execinstr
.align 4
.global Asm
.type Asm,#function
Asm:
retl
nop
.size Asm, (.-Asm)
Not all possibilities shown here:
-bash-3.00$ /usr/local/bin/gcc -g asm.s 4.c
ok
-bash-3.00$ /usr/sfw/bin/gcc -g asm.s 4.c
ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccICgvny.o: symbol : offset 0xfeed139e is non-aligned
ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccICgvny.o: symbol : offset 0xfeed14c2 is non-aligned
ld: fatal: relocation error: R_SPARC_32: file /var/tmp//ccICgvny.o: symbol : offset 0xfeed15f6 is non-aligned
collect2: ld returned 1 exit status
-bash-3.00$ /usr/bin/cc -g asm.s 4.c
asm.s:
4.c:
ok
-bash-3.00$ /usr/bin/cc asm.s 4.c
asm.s:
4.c:
ok
-bash-3.00$ /usr/sfw/bin/gcc asm.s 4.c
ok
-bash-3.00$ /usr/local/bin/gcc asm.s 4.c
ok
-bash-3.00$ /usr/sfw/bin/gcc -g -c asm.s
ok but haven't linked yet, input to later steps
-bash-3.00$ /usr/bin/cc asm.o 4.c
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
ff10148e is non-aligned
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
ff1014ca is non-aligned
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
ff1015be is non-aligned
-bash-3.00$ /usr/local/bin/gcc asm.o 4.c
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
feee1213 is non-aligned
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
feee122a is non-aligned
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
feee122e is non-aligned
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
feee1232 is non-aligned
ld: fatal: relocation error: R_SPARC_32: file asm.o: symbol : offset 0x
feee126e is non-aligned
collect2: ld returned 1 exit status
-bash-3.00$ /usr/local/bin/gcc -g -c asm.s
ok, try linking with others
-bash-3.00$ /usr/bin/cc asm.o 4.c
ok
-bash-3.00$ /usr/sfw/bin/gcc asm.o 4.c
ok
Actually even -gstabs or -gstabs+ instead of -g make it work.
-g resolves to -gdwarf2.
- Jay
More information about the M3devel
mailing list