This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Dynamic Linking issue in coff file format


Resending due to no response.

Thanks
Mayank

-----Original Message-----
From: Mayank Kumar
Sent: Friday, August 31, 2007 11:48 AM
To: binutils@sources.redhat.com
Subject: Dynamic Linking issue in coff file format

Hi All
While porting binutils 2.17 to interix, I am facing an issue when linking to libc.so. It is described as follows:-

1: I link a binary with libc.so and that binary accesses a variable from libc.so.

2: Suppose that variable is ___sF, in this case nm output shows me

$ nm binary | grep sF
00046f50 D ___sF

3: This is wrong because the sF is declared in libc.so and hence here it should come as " U ___sF"

4: After debugging inside ld, I see the following:-

        A:coff_link_add_symbols called twice, once for the binary where it reads ___sF as undefined and once for libc.so where it reads ___sF as defined        and adds it to a some symbol table.
        B: _bfd_coff_write_global_sym is called when doing the final linking to write the global symbols. In coff this is handled as , if the output section for a symbol is NULL, then it means that symbol is coming from a .so or is defined there, hence output that symbol as an undefined symbol into the binary.


But in my case, this symbol and infact all symbols(I think data symbols) coming from libc.so get output to the binary as defined since they have an associated output section which is .data.


So my questions are:-
1: How is this case handled in elf and where is the code ?
2: how/where in elf or coff, does the output section for a symbol gets populated and what prevents a global symbol defined in .so to have an output_section.
3: any other thing that you all think I should know to debug and fix this.

Any help/pointers will be appreciated as I am not very familiar with the overall architecture.


Thanks in advance
Mayank


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]