|
Message
From: Robert Cragie<rcc@j...>
Date: Tue Aug 1 17:12:04 CEST 2006
Subject: [openrisc] LD doesn't complain undefined reference
I noticed this a while ago and there was no response about this (http://www.opencores.org/forums.cgi/openrisc/2006/02/002518).
This only applies to binutils 2.16.1, not 2.11.93
Robert Cragie, Design Engineer _______________________________________________________________ Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK http://www.jennic.com Tel: +44 (0) 114 281 2655 _______________________________________________________________
> -----Original Message----- > From: openrisc-bounces@o... > [mailto:openrisc-bounces@o...]On Behalf Of Tzu-Chien Chiu > Sent: 28 July 2006 10:48 > To: List about OpenRISC project > Subject: Re: [openrisc] LD doesn't complain undefined reference > > > No. Note that in my running log I test both gcc (native compiler) and > or32-elf-gcc (cross compiler). The former complains undefined > reference, while the later not. > > > 2006/7/28, Korbinian Schmid <korbi@g...>: > > Hello, > > I'm not sure whether I understood. The linker did complain, didn't he? > > > > I tryed your main.c but with a functin body for foo and it > works quite well: > > > > void foo(){} > > int main() { foo(); return 0; } > > > > objdump -S > > > > > > Tzu-Chien Chiu wrote: > > > > > Hello, everyone: > > > > > > My linker or32-elf-ld didn't report complain undefined reference. What > > > should I check? > > > > > > The port GNU tool chain (binutils and gcc) are not modified. > > > > > > Log start: > > > > > > $ cat main.c > > > > > > void foo(); > > > int main() { foo(); return 0; } > > > > > > $ gcc main.c > > > > /cygdrive/c/DOCUME~1/s110/LOCALS~1/Temp/cck3LBzx.o:main.c:(.text+0x2b): > > > undefined reference to `_foo' > > > collect2: ld returned 1 exit status > > > > > > $ or32-elf-gcc --verbose main.c > > > Reading specs from /usr/local/cross/lib/gcc/or32-elf/3.4.4/specs > > > Configured with: ../configure --target=or32-elf > > > --prefix=/usr/local/cross --disable-nls --with-gnu-ld --with-gnu-ls > > > --enable-languages=c,c++ --with-new-lib > > > Thread model: single > > > gcc version 3.4.4 > > > /usr/local/cross/libexec/gcc/or32-elf/3.4.4/cc1.exe -quiet -v main.c > > > -quiet -dumpbase main.c -auxbase main -version -o > > > /cygdrive/c/DOCUME~1/s110/LOCALS~1/Temp/ccDF265T.s > > > ignoring nonexistent directory > > > > "/usr/local/cross/lib/gcc/or32-elf/3.4.4/../../../../or32-elf/sys-include" > > > > > > #include "..." search starts here: > > > #include <...> search starts here: > > > /usr/local/cross/lib/gcc/or32-elf/3.4.4/include > > > /usr/local/cross/lib/gcc/or32-elf/3.4.4/../../../../or32-elf/include > > > End of search list. > > > GNU C version 3.4.4 (or32-elf) > > > compiled by GNU C version 3.4.4 (cygming special) (gdc 0.12, > > > using dmd 0.125). > > > GGC heuristics: --param ggc-min-expand=100 --param > > > ggc-min-heapsize=131072 > > > > /usr/local/cross/lib/gcc/or32-elf/3.4.4/../../../../or32-elf/bin/as.exe > > > -o /cygdrive/c/DOCUME~1/s110/LOCALS~1/Temp/ccA4HgLJ.o > > > /cygdrive/c/DOCUME~1/s110/LOCALS~1/Temp/ccDF265T.s > > > /usr/local/cross/libexec/gcc/or32-elf/3.4.4/collect2.exe > > > /usr/local/cross/lib/gcc/or32-elf/3.4.4/crt0.o > > > -L/usr/local/cross/lib/gcc/or32-elf/3.4.4 > > > -L/usr/local/cross/lib/gcc/or32-elf/3.4.4/../../../../or32-elf/lib > > > /cygdrive/c/DOCUME~1/s110/LOCALS~1/Temp/ccA4HgLJ.o -lgcc -lc -lgcc > > > > > > $ or32-elf-objdump -S a.out > > > > > > 01000218 <_main>: > > > 1000218: 9c 21 ff f4 l.addi r1,r1,0xfffffff4 > > > 100021c: d4 01 10 04 l.sw 0x4(r1),r2 > > > 1000220: 9c 41 00 0c l.addi r2,r1,0xc > > > 1000224: d4 01 48 00 l.sw 0x0(r1),r9
> > > 1000228: 04 00 00 84 l.jal 1000438 <___main>
> > > 100022c: 15 00 00 00 l.nop 0x0
> > > 1000230: 07 bf ff 74 l.jal 0 <_start_proc-0x1000074>
> > > 1000234: 15 00 00 00 l.nop 0x0
> > > 1000238: 9c 60 00 00 l.addi r3,r0,0x0
> > > 100023c: d7 e2 1f fc l.sw 0xfffffffc(r2),r3
> > > 1000240: 85 62 ff fc l.lwz r11,0xfffffffc(r2)
> > > 1000244: 85 21 00 00 l.lwz r9,0x0(r1)
> > > 1000248: 84 41 00 04 l.lwz r2,0x4(r1)
> > > 100024c: 44 00 48 00 l.jr r9
> > > 1000250: 9c 21 00 0c l.addi r1,r1,0xc
> > >
> > > Notice that in address 1000230, the program jump to address zero.
> > >
> > >
> >
> >
> >
> >
> > test: file format elf32-or32
> >
> > Disassembly of section .text:
> >
> > 01000074 <_foo>:
> > 1000074: 9c 21 ff fc l.addi r1,r1,0xfffffffc
> > 1000078: d4 01 10 00 l.sw 0x0(r1),r2
> > 100007c: 9c 41 00 04 l.addi r2,r1,0x4
> > 1000080: 84 41 00 00 l.lwz r2,0x0(r1)
> > 1000084: 44 00 48 00 l.jr r9
> > 1000088: 9c 21 00 04 l.addi r1,r1,0x4
> >
> > 0100008c <_main>:
> > 100008c: 9c 21 ff f8 l.addi r1,r1,0xfffffff8
> > 1000090: d4 01 10 04 l.sw 0x4(r1),r2
> > 1000094: 9c 41 00 08 l.addi r2,r1,0x8
> > 1000098: d4 01 48 00 l.sw 0x0(r1),r9
> > 100009c: 07 ff ff f6 l.jal 1000074 <_foo>
> > 10000a0: 15 00 00 00 l.nop 0x0
> > 10000a4: 9c 60 00 00 l.addi r3,r0,0x0
> > 10000a8: a9 63 00 00 l.ori r11,r3,0x0
> > 10000ac: 85 21 00 00 l.lwz r9,0x0(r1)
> > 10000b0: 84 41 00 04 l.lwz r2,0x4(r1)
> > 10000b4: 44 00 48 00 l.jr r9
> > 10000b8: 9c 21 00 08 l.addi r1,r1,0x8
> >
> > 010000bc <_start>:
> > 10000bc: 9c 21 ff fc l.addi r1,r1,0xfffffffc
> > 10000c0: d4 01 48 00 l.sw 0x0(r1),r9
> > 10000c4: a8 a3 00 00 l.ori r5,r3,0x0
> > 10000c8: 84 63 ff fc l.lwz r3,0xfffffffc(r3)
> > 10000cc: a8 85 00 00 l.ori r4,r5,0x0
> > 10000d0: b8 c3 00 02 l.slli r6,r3,0x2
> > 10000d4: e0 a5 30 00 l.add r5,r5,r6
> > 10000d8: 04 00 00 05 l.jal 10000ec <___uClibc_main>
> > 10000dc: 9c a5 00 04 l.addi r5,r5,0x4
> > 10000e0: 85 21 00 00 l.lwz r9,0x0(r1)
> > 10000e4: 44 00 48 00 l.jr r9
> > 10000e8: 9c 21 00 04 l.addi r1,r1,0x4
> >
> > 010000ec <___uClibc_main>:
> > 10000ec: 9c 21 ff f0 l.addi r1,r1,0xfffffff0
> > 10000f0: d4 01 48 00 l.sw 0x0(r1),r9
> > 10000f4: d4 01 50 04 l.sw 0x4(r1),r10
> > 10000f8: d4 01 60 08 l.sw 0x8(r1),r12
> > 10000fc: d4 01 70 0c l.sw 0xc(r1),r14
> > 1000100: a9 c3 00 00 l.ori r14,r3,0x0
> > 1000104: a9 84 00 00 l.ori r12,r4,0x0
> > 1000108: 18 60 01 00 l.movhi r3,0x100
> > 100010c: a8 63 12 04 l.ori r3,r3,0x1204
> > 1000110: d4 03 28 00 l.sw 0x0(r3),r5
> > 1000114: 18 80 00 00 l.movhi r4,0x0
> > 1000118: a8 84 00 00 l.ori r4,r4,0x0
> > 100011c: 9c 60 00 00 l.addi r3,r0,0x0
> > 1000120: e4 04 18 00 l.sfeq r4,r3
> > 1000124: 10 00 00 04 l.bf 1000134 <___uClibc_main+0x48>
> > 1000128: a9 45 00 00 l.ori r10,r5,0x0
> > 100012c: 07 bf ff b5 l.jal 0 <_foo-0x1000074>
> > 1000130: 15 00 00 00 l.nop 0x0
> > 1000134: 04 00 00 10 l.jal 1000174 <___errno_location>
> > 1000138: 15 00 00 00 l.nop 0x0
> > 100013c: 9c 60 00 00 l.addi r3,r0,0x0
> > 1000140: a8 8c 00 00 l.ori r4,r12,0x0
> > 1000144: d4 0b 18 00 l.sw 0x0(r11),r3
> > 1000148: a8 aa 00 00 l.ori r5,r10,0x0
> > 100014c: 07 ff ff d0 l.jal 100008c <_main>
> > 1000150: a8 6e 00 00 l.ori r3,r14,0x0
> > 1000154: 04 00 00 0c l.jal 1000184 <_exit>
> > 1000158: a8 6b 00 00 l.ori r3,r11,0x0
> > 100015c: 85 21 00 00 l.lwz r9,0x0(r1)
> > 1000160: 85 41 00 04 l.lwz r10,0x4(r1)
> > 1000164: 85 81 00 08 l.lwz r12,0x8(r1)
> > 1000168: 85 c1 00 0c l.lwz r14,0xc(r1)
> > 100016c: 44 00 48 00 l.jr r9
> > 1000170: 9c 21 00 10 l.addi r1,r1,0x10
> >
> > 01000174 <___errno_location>:
> > 1000174: 19 60 01 00 l.movhi r11,0x100
> > 1000178: a9 6b 12 08 l.ori r11,r11,0x1208
> > 100017c: 44 00 48 00 l.jr r9
> > 1000180: 15 00 00 00 l.nop 0x0
> >
> > 01000184 <_exit>:
> > 1000184: 9c 21 ff f8 l.addi r1,r1,0xfffffff8
> > 1000188: d4 01 48 00 l.sw 0x0(r1),r9
> > 100018c: d4 01 50 04 l.sw 0x4(r1),r10
> > 1000190: a9 43 00 00 l.ori r10,r3,0x0
> > 1000194: 18 60 01 00 l.movhi r3,0x100
> > 1000198: a8 63 12 00 l.ori r3,r3,0x1200
> > 100019c: 84 83 00 00 l.lwz r4,0x0(r3)
> > 10001a0: 9c 60 00 00 l.addi r3,r0,0x0
> > 10001a4: e4 04 18 00 l.sfeq r4,r3
> > 10001a8: 10 00 00 04 l.bf 10001b8 <_exit+0x34>
> > 10001ac: 15 00 00 00 l.nop 0x0
> > 10001b0: 48 00 20 00 l.jalr r4
> > 10001b4: 15 00 00 00 l.nop 0x0
> > 10001b8: 04 00 00 06 l.jal 10001d0 <__exit>
> > 10001bc: a8 6a 00 00 l.ori r3,r10,0x0
> > 10001c0: 85 21 00 00 l.lwz r9,0x0(r1)
> > 10001c4: 85 41 00 04 l.lwz r10,0x4(r1)
> > 10001c8: 44 00 48 00 l.jr r9
> > 10001cc: 9c 21 00 08 l.addi r1,r1,0x8
> >
> > 010001d0 <__exit>:
> > 10001d0: 9d 60 00 01 l.addi r11,r0,0x1
> > 10001d4: 20 00 00 01 l.sys 0x1
> > 10001d8: 15 00 00 00 l.nop 0x0
> > 10001dc: 9c 60 f0 00 l.addi r3,r0,0xfffff000
> > 10001e0: e4 ab 18 00 l.sfleu r11,r3
> > 10001e4: 10 00 00 05 l.bf 10001f8 <__exit+0x28>
> > 10001e8: e0 80 58 02 l.sub r4,r0,r11
> > 10001ec: 18 60 01 00 l.movhi r3,0x100
> > 10001f0: a8 63 12 08 l.ori r3,r3,0x1208
> > 10001f4: d4 03 20 00 l.sw 0x0(r3),r4
> > 10001f8: 44 00 48 00 l.jr r9
> > 10001fc: 15 00 00 00 l.nop 0x0
> >
> >
> > _______________________________________________
> > http://www.opencores.org/mailman/listinfo/openrisc
> >
> >
>
>
> --
> Tzu-Chien Chiu - SMedia Technology Corp.
> URL: http://www.csie.nctu.edu.tw/~jwchiu/
> _______________________________________________
> http://www.opencores.org/mailman/listinfo/openrisc
|
 |