How to determine if a global symbol is defined in .so and hence needs to be output to the binary as undefined

Mayank Kumar mayank@microsoft.com
Fri Sep 7 04:36:00 GMT 2007


Hi Ian
Thanks for the reply. I am not looking forward to copy the code but since I had no clue how this thing work, I was trying to get some help here.
The way you pointed for elf works, its exactly the same way for coff as well. If the output_section is NULL , the symbol is output as undefined into the binary. Now the problem is that in my porting effort, this output_section doesn't come out to be NULL for all defined symbols in the .so and hence it gets output to the binary as defined which is wrong.
        Now I wanted to understand where this output_section gets populated so that I can debug through why this section is not coming to be NULL.
Can you give me some clues ?


Thanks
Mayank


-----Original Message-----
From: Ian Lance Taylor [mailto:iant@google.com]
Sent: Thursday, September 06, 2007 10:35 PM
To: Mayank Kumar
Cc: binutils@sources.redhat.com
Subject: Re: How to determine if a global symbol is defined in .so and hence needs to be output to the binary as undefined

Mayank Kumar <mayank@microsoft.com> writes:

> While creating a binary usinf ld, I want to determine if a symbol is
> completely defined in another .so and hence needs to be output to a
> binary as undefined.  What is the best way to achieve this or how is
> this handled in elf format.

In ELF this is handled in elf_link_output_extsym, in the case for
bfd_link_hash_defined where input_sec->output_section == NULL.

But COFF/PE uses completely different code.  You can't just blindly
copy the ELF code.  You have to understand how the COFF/PE code is
supposed to work.  The approximately equivalent COFF code is
_bfd_coff_write_global_sym.

Ian



More information about the Binutils mailing list