Issue an error for read-only segment with dynamic IFUNC relocations
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 13 Aug 2015 11:31:38 +0000 (04:31 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 13 Aug 2015 11:31:38 +0000 (04:31 -0700)
commit8efa2874ab298f3923f4127340da119435f87c39
tree09065381bc362db4d84940bfcc95cec64cc3fe42
parent4ab90a7a90ccf8a671f139c1c6387ba8028e6011
Issue an error for read-only segment with dynamic IFUNC relocations

To load an ELF binary with DT_TEXTREL tag, the dynamic linker calls
__mprotect on the read-only segment with PROT_READ|PROT_WRITE before
applying dynamic relocation.  It leads to segfault when performing
IFUNC relocations since the read-only segment has no execute permission.
This patch changes x86 linker to issue an error for read-only segment
with dynamic IFUNC relocations.  Other backends with IFUNC support
may need a similar change.

bfd/

PR ld/18801
* elf32-i386.c (elf_i386_size_dynamic_sections): Issue an error
for read-only segment with dynamic IFUNC relocations.
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.

ld/testsuite/

PR ld/18801
* ld-i386/i386.exp: Run pr18801.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pr18801.d: New file.
* ld-i386/pr18801.s: Likewise.
* ld-x86-64/pr18801.d: Likewise.
* ld-x86-64/pr18801.s: Likewise.
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr18801.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr18801.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr18801.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr18801.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp
This page took 0.043506 seconds and 4 git commands to generate.