Browse Source
R_386_GOTOFF/R_X86_64_GOTOFF64 relocation shouldn't be used against protected data symbol on x86 since with copy relocation, address of protected data defined in the shared library may be external. This patch will break building shared libraries with protected data symbols using GCCs older than GCC 5 without the bug fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 GCC backport request should be made in the GCC bug report above. bfd/ PR ld/pr17709 * elf32-i386.c (elf_i386_relocate_section): Also check R_386_GOTOFF against protected data symbol when building shared library. * elf64-x86-64.c (elf_x86_64_relocate_section): Also check R_X86_64_GOTOFF64 against protected data symbol when building shared library. ld/testsuite/ PR ld/pr17709 * ld-i386/protected6.d: New file. * ld-i386/protected6.s: Likewise. * ld-x86-64/protected6.d: Likewise. * ld-x86-64/protected6.s: Likewise. * ld-x86-64/protected7.d: Likewise. * ld-x86-64/protected7.s: Likewise. * ld-x86-64/protected7a.d: Likewise. * ld-x86-64/protected7b.d: Likewise.gdb-7.10-branch
13 changed files with 100 additions and 13 deletions
@ -0,0 +1,3 @@ |
|||
#as: --32 |
|||
#ld: -shared -melf_i386 |
|||
#error: .*relocation R_386_GOTOFF against protected data `foo' can not be used when making a shared object |
|||
@ -0,0 +1,14 @@ |
|||
.data |
|||
.protected foo |
|||
.globl foo |
|||
.align 4 |
|||
.type foo, @object |
|||
.size foo, 4 |
|||
foo: |
|||
.long 1 |
|||
.text |
|||
.globl bar |
|||
.type bar, @function |
|||
bar: |
|||
movl foo@GOTOFF(%ecx), %eax |
|||
.size bar, .-bar |
|||
@ -0,0 +1,3 @@ |
|||
#as: --64 |
|||
#ld: -shared -melf_x86_64 |
|||
#error: .*relocation R_X86_64_GOTOFF64 against protected data `foo' can not be used when making a shared object |
|||
@ -0,0 +1,14 @@ |
|||
.protected foo |
|||
.globl foo |
|||
.data |
|||
.align 4 |
|||
.type foo, @object |
|||
.size foo, 4 |
|||
foo: |
|||
.long 1 |
|||
.text |
|||
.globl bar |
|||
.type bar, @function |
|||
bar: |
|||
movabsq $foo@GOTOFF, %rax |
|||
.size bar, .-bar |
|||
@ -0,0 +1,12 @@ |
|||
.text |
|||
.globl foo |
|||
.protected foo |
|||
.type foo, @function |
|||
foo: |
|||
ret |
|||
.size foo, .-foo |
|||
.globl bar |
|||
.type bar, @function |
|||
bar: |
|||
movabsq $foo@GOTOFF, %rax |
|||
.size bar, .-bar |
|||
@ -0,0 +1,4 @@ |
|||
#source: protected7.s |
|||
#as: --64 |
|||
#ld: -shared -melf_x86_64 |
|||
#error: .*relocation R_X86_64_GOTOFF64 against protected function `foo' can not be used when making a shared object |
|||
@ -0,0 +1,6 @@ |
|||
#source: protected7.s |
|||
#as: --64 |
|||
#ld: -shared -Bsymbolic -melf_x86_64 |
|||
#readelf: -r |
|||
|
|||
There are no relocations in this file. |
|||
Loading…
Reference in new issue