non-PIC references to __ehdr_start in pie and shared
authorAlan Modra <amodra@gmail.com>
Wed, 15 Jan 2014 11:20:55 +0000 (21:50 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 15 Jan 2014 11:53:16 +0000 (22:23 +1030)
commit4199e3b8669d0a36448687850374fdc2ad7240b6
treea7c11cbb939cda37c5e69363093c3ad0866b7df9
parentbb4142cf49651ddcb0e00f6aaf451272c4c9977d
non-PIC references to __ehdr_start in pie and shared

Rather than hacking every backend to not discard dynamic relocations
against an undefined hidden __ehdr_start, make it appear to be defined
early.  We want __ehdr_start hidden before size_dynamic_sections so
that it isn't put in .dynsym, but we do need the dynamic relocations
for a PIE or shared library with a non-PIC reference.  Defining it
early is wrong if we don't actually define the symbol later to its
proper value.  (In some cases we want to leave the symbol undefined,
for example, when the ELF header isn't loaded, and we don't have this
infomation available in before_allocation.)

ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Define
__ehdr_start before size_dynamic_sections and restore afterwards.
ld/testsuite/
* ld-elf/ehdr_start-shared.d: New.
* ld-elf/ehdr_start-userdef.d: xfail frv.
* ld-elf/ehdr_start-weak.d: Likewise.
* ld-elf/ehdr_start.d: Likewise.
ld/ChangeLog
ld/emultempl/elf32.em
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/ehdr_start-shared.d [new file with mode: 0644]
ld/testsuite/ld-elf/ehdr_start-userdef.d
ld/testsuite/ld-elf/ehdr_start-weak.d
ld/testsuite/ld-elf/ehdr_start.d