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] |
[This time with the patch...] On Sat, Sep 11, 2010 at 12:16 AM, Cary Coutant <ccoutant@google.com> wrote: > When building a PIE executable with mixed PIC and non-PIC input files, > a non-PIC call to a shared library function will result in a dynamic > relocation on the call. If there is also a PIC call to the same > symbol, a PLT entry will have been created, and the logic for > determining if a dynamic relocation is necessary will erroneously > return false. If the non-PIC call precedes the PIC call, > Symbol::needs_dynamic_reloc() will return true during scanning (before > the PIC call is seen), and false when applying relocations (after the > PIC call was scanned). For targets that use REL relocations (namely > i386), this causes gold to apply the static relocation instead of > leaving the original addend intact. This patch fixes the test in > needs_dynamic_reloc() to check for output_is_position_independent > instead of shared. > > In addition, a non-PIC reference to data in a shared library will > result in the creation of a COPY relocation, but no dynamic relocation > for the reference to the new home. I checked how Gnu ld behaves, and > it does not appear to make COPY relocs for PIE executables. This patch > also changes Symbol::may_need_copy_reloc() to test for > output_is_position_independent. > > The new test case covers both of these problems. > > Tested on i386 and x86_64 (although x86_64 doesn't run the non-PIC-in-PIE test). > > OK? > > -cary > > > ? ? ? ?* symtab.h (Symbol::needs_dynamic_reloc): Non-PIC calls from > ? ? ? ?position-independent executables to shared libraries need dynamic > ? ? ? ?relocations. > ? ? ? ?(Symbol::may_need_copy_reloc): Do not generate COPY relocs in > ? ? ? ?position-independent executables. > ? ? ? ?* testsuite/Makefile.am (two_file_mixed_pie_test): New test. > ? ? ? ?* testsuite/Makefile.in: Regenerate. >
Attachment:
gold-pie-patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |