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.