This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: symbol resolution in linker?
- From: "Vineet Sharma, Noida" <vineets at noida dot hcltech dot com>
- To: Ian Lance Taylor <ian at wasabisystems dot com>, "Vineet Sharma, Noida" <vineets at noida dot hcltech dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Sat, 29 Nov 2003 12:01:59 +0530
- Subject: RE: symbol resolution in linker?
Hi Ian,
Thank you for your reply, let me be more specfic about my problem
what i observe is
If my assembler sees any undefined symbol (say "xyz"), it makes an entry of
symbol "xyz"(section "*UND*") and a reloc entry.
Now when my linker tries to resolve the address. it does not resolve
it(inspite of the fact that this symbol "xyz" is defined in another object
file linked with it. and continues to see the symbol "xyz" undefined"
Secondly "Is it normal to have linker output as :
00000000 <.text>:
0: 8a 8a /* Some instruction*/
2: 0c 03 /* Some instruction*/ /*
Note there are 2 .text section, 2 abc label*/
4: 0b 03 /* Some instruction*/ /*Is
it normal?*/
6: 0c 05 /* Some instruction */
00000008 <xyz>:
8: 0c 01 /* Some instruction*/
0000000a <abc>:
a: 8c 0d /* Some instruction*/
0000000c <.text>:
c: 8a 1a /* Some instruction*/
0000000e <abc>:
e: 0b ff /* Some instruction*/
10: 0c 00 /* Some instruction refreing xyz*/ /*This
instruction never finds the xyz symbol*/
/* though it is defined above*/
And i dont want two .text section i want them to be combined and reslove the
symbols uniqily.
I hope i explained my self?
If you need more info plz feel free to write and help me out
Regards
Vineet
-----Original Message-----
From: Ian Lance Taylor [mailto:ian@wasabisystems.com]
Sent: Saturday, November 29, 2003 4:58 AM
To: Vineet Sharma, Noida
Cc: binutils@sources.redhat.com
Subject: Re: symbol resolution in linker?
"Vineet Sharma, Noida" <vineets@noida.hcltech.com> writes:
> when my BFD_ASSEMBLER encounters an undefined label(say xyz), it makes
> and reloc entry of (xyz and section "*UND*"), and when my linker tries to
> reloc it finds section "*UND*" and coundn't find the absolute address for
> the symbol. Now which part in linker is responsible to find correct "xyz"
> symbol and pass it on to coff_XXX_reloc(abfd, reloc_entry, symbol_in,
data,
> input_section, output_bfd,error_message) function any help.
This question seems a bit confused.
The linker works by reading the symbols of the input objects and
building a global symbol table. It then reads all the relocs, and
resolves them using the global symbol table. If the linker finds that
a relocation is against a symbol which is not in the global symbol
table, it reports an undefined symbol error.
If that does not help, you must either be much more specific, or you
must spend some time learning how linkers work.
> As of now i see that the bfd depends on reloc entry for symbol resolution
> even it was undefined?
How can you resolve a symbol if it was undefined? How can a symbol be
undefined if there is no reloc entry for it?
Ian