This is the mail archive of the binutils@sources.redhat.com 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]

Patch proposal for ld/pe-dll.c


Hello,

There seem to be a slight problem in pe-dll.c in ld :

If a global data or bss is defined in an object and ld is subsequently used
to create an import library, the .data$7 is relocated to the wrong symbol.
As a consequence, the __head_xxxx symbol is no longer used and strip with
--strip-unneeded will remove it's definition, leading to various problems
(linker failures and/or runtime failures).

This happens because the import library builder does not define a stub
function for that symbol as it not necessary for data or bss globals.
However, it changes the order in which symbols are defined and the
subsequent invocation of quick_reloc addresses the wrong symbol. (this is
visible by doing a objdump of the import library. The segments defining
function imports relocate .idata$7 with __head_xxx and the segments defining
data imports relocate .idata$7 with __imp_xxx)

Here is the proposed patch for ld/pe-dll.c (from the 2003/09/21 Snapshot)
<patch>
1783,1784d1782
<       if (! exp->flag_data)
< 	quick_symbol (abfd, "", exp->internal_name, "", tx, BSF_GLOBAL, 0);
1786a1785,1786
>       if (! exp->flag_data)
> 	quick_symbol (abfd, "", exp->internal_name, "", tx, BSF_GLOBAL, 0);
1793a1794,1795
>       quick_symbol (abfd, U ("_head_"), dll_symname, "", UNDSEC,
> 		    BSF_GLOBAL, 0);
1797,1798d1798
<       quick_symbol (abfd, U ("_head_"), dll_symname, "", UNDSEC,
< 		    BSF_GLOBAL, 0);
1841c1841
<   quick_reloc (abfd, 0, BFD_RELOC_RVA, 6);
---
>   quick_reloc (abfd, 0, BFD_RELOC_RVA, 5);
</patch>

Thanks,

--Ivan


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