Page 1 of 1
problems with binutils 2.20
Posted: Fri Jan 29, 2010 8:40 am
by FlashBurn
Yesterday I switched to gcc 4.4.3 (from 4.4.2) and to binutils 2.20 (from 1.19) and now I have problems with compiling my loader. I get errors with undefined references, but the code worked with the old binutils! The undefined references are the functions which are defined in other object files and I get the errors when I try to link my loader:
Code: Select all
ld loader_stub.o $(OBJS) -o osloader -nostdlib -T loader.ld
In $(OBJS) are my object files.
I use this linker script:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(loader_stub)
SECTIONS
{
. = 0x500;
_text_start = .;
.text : { *(.text) }
. = ALIGN(16);
_data_start = .;
.data : { *(.data) }
. = ALIGN(16);
_bss_start = .;
.bss : { *(.bss) }
. = ALIGN(16);
_loader_end = .;
}
So does anyone has similar problems with the new binutils or/and does know what the problem is?
Re: problems with binutils 2.20
Posted: Fri Jan 29, 2010 1:19 pm
by AJ
Hi,
I am the one who updated the wiki to reflect GCC 4.4.2 with binutils 2.20 and no linking problems here. I have yet to try 4.4.3, but could you provide the exact error messages and the contents of $(OBJS), please?
Cheers,
Adam
Re: problems with binutils 2.20
Posted: Fri Jan 29, 2010 1:47 pm
by FlashBurn
Ok, in $(OBJS) are as said, my objects files (like kernel.o string.o and so on) and here comes one of the error msgs:
Code: Select all
patriciatree.o: In function `patriciaTreeGetValue':
patriciatree.c:(.text+0x194): undefined reference to `strlen'
patriciatree.c:(.text+0x1e6): undefined reference to `strcmp'
The thing is I updated last year to binutils 2.20 and there I got an error msg that there is something wrong with the linker script and I downgraded to binutils 2.19. So yesterday I thought when I create gcc 4.4.3 I also could try binutils 2.20 once more.
Re: problems with binutils 2.20
Posted: Fri Jan 29, 2010 4:13 pm
by Grunt
What if you put string.o before kernel.o in the command line?
Re: problems with binutils 2.20
Posted: Fri Jan 29, 2010 5:16 pm
by FlashBurn
@Grunt
This isn´t the problem, because string.o comes before patriciatree.o!
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 2:33 am
by xenos
Have you tried to look up which symbols are actually present in string.o?
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 3:22 am
by FlashBurn
Yeah, and all the symbols which should are marked as global.
Edit::
It has to be a problem with my linker script, because when I don´t use the linker script, I only get errors because of the symbols I define in my linker script, but I don´t get the other errors!
So if I remembering right they changed something in linker scripts with 2.20. Does anybody know what this was?
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 3:38 am
by qw
Underscores?
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 3:54 am
by FlashBurn
The underscores are not the problem!
I just found out that the undefined reference error does not come for all symbols of other files!?
The relocation section (readelf -a menu.o) for one object file:
Code: Select all
Relocation section '.rel.text' at offset 0xafc contains 22 entries:
Offset Info Type Sym.Value Sym. Name
0000000d 00000c02 R_386_PC32 00000000 memAlloc
00000068 00000e01 R_386_32 00000004 root
00000073 00000501 R_386_32 00000000 .rodata.str1.1
00000078 00000501 R_386_32 00000000 .rodata.str1.1
0000007e 00000b02 R_386_PC32 00000000 menuAddEntry
00000086 00000e01 R_386_32 00000004 root
00000091 00000f01 R_386_32 00000000 vbeMenuFailSafeOption
0000009a 00000601 R_386_32 00000000 .rodata.str1.4
0000009f 00000501 R_386_32 00000000 .rodata.str1.1
000000a5 00000b02 R_386_PC32 00000000 menuAddEntry
000000ad 00000e01 R_386_32 00000004 root
00000174 00000801 R_386_32 00000000 .rodata
0000034a 00001002 R_386_PC32 00000000 callBIOS
0000038d 00000801 R_386_32 00000000 .rodata
000004ba 00001201 R_386_32 00000000 loaderArgs
000004d2 00001201 R_386_32 00000000 loaderArgs
000004dc 00001201 R_386_32 00000000 loaderArgs
000004e6 00001201 R_386_32 00000000 loaderArgs
00000532 00001301 R_386_32 00000004 menuScrOldCur
0000054c 00000801 R_386_32 00000000 .rodata
00000580 00000e01 R_386_32 00000004 root
0000058f 00001301 R_386_32 00000004 menuScrOldCur
and the symbol table:
Code: Select all
Symbol table '.symtab' contains 20 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FILE LOCAL DEFAULT ABS menu.c
2: 00000000 0 SECTION LOCAL DEFAULT 1
3: 00000000 0 SECTION LOCAL DEFAULT 3
4: 00000000 0 SECTION LOCAL DEFAULT 4
5: 00000000 0 SECTION LOCAL DEFAULT 5
6: 00000000 0 SECTION LOCAL DEFAULT 6
7: 000000c0 1008 FUNC LOCAL DEFAULT 1 menuExec
8: 00000000 0 SECTION LOCAL DEFAULT 7
9: 0000002c 15 OBJECT LOCAL DEFAULT 7 menuTopLineStr
10: 00000000 0 SECTION LOCAL DEFAULT 9
11: 00000000 89 FUNC GLOBAL DEFAULT 1 menuAddEntry
12: 00000000 0 NOTYPE GLOBAL DEFAULT UND memAlloc
13: 00000060 92 FUNC GLOBAL DEFAULT 1 menuInit
14: 00000004 4 OBJECT GLOBAL DEFAULT COM root
15: 00000000 0 NOTYPE GLOBAL DEFAULT UND vbeMenuFailSafeOption
16: 00000000 0 NOTYPE GLOBAL DEFAULT UND callBIOS
17: 000004b0 292 FUNC GLOBAL DEFAULT 1 menuEnter
18: 00000000 0 NOTYPE GLOBAL DEFAULT UND loaderArgs
19: 00000004 4 OBJECT GLOBAL DEFAULT COM menuScrOldCur
And now the error which I get from ld:
Code: Select all
menu.o: In function `menuExec':
menu.c:(.text+0x34a): undefined reference to `callBIOS'
So I wonder now why is there only an undefined reference to "callBIOS" and not also to memAlloc, vbeMenuFailSafeOption and loaderArgs?!
The thing is I never saw an error with an undefined reference to "printf", but to "itoa" which is in the same object file.
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 5:55 am
by AJ
Hi,
The only thing I can see with your linker script is that you have no .rodata section defined, even though your have .rodata entries in the object file dump. Although I'd expect that to cause link problems with your strings, not your functions...
Cheers,
Adam
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 6:18 am
by gravaera
Hi:
As a general rule, you must place object file with dependencies first on the command line, followed by object files with none. So an object which depends on strings.o would be placed before strings.o on the command line.
Note well that this is not an official statement from the LD manuals AFAIK but rather something I discovered through experimentation.
--All the best,
gravaera
Re: problems with binutils 2.20
Posted: Sat Jan 30, 2010 6:30 am
by FlashBurn
@gravaera
This is not always possible and this should not be the case.
@all
I just downgraded to 2.19.1 and what should I say it works