public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Dynamic Linking issue in coff file format
@ 2007-09-05  7:35 Mayank Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Mayank Kumar @ 2007-09-05  7:35 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Dynamic Linking issue in coff file format
@ 2007-08-31 10:34 Mayank Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Mayank Kumar @ 2007-08-31 10:34 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-05  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-05  7:35 Dynamic Linking issue in coff file format Mayank Kumar
  -- strict thread matches above, loose matches on Subject: below --
2007-08-31 10:34 Mayank Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).