forked from Imagelibrary/binutils-gdb
x86: Always treat protected symbols as local
Since linker never generates dynamic relocation for protected symbol in:
__attribute__((visibility("protected"))) int my_data;
int *
func (void)
{
return &my_data;
}
we should always treat protected symbols as local.
bfd/
PR ld/33260
* elfxx-x86.h (COPY_INPUT_RELOC_P): Always treat protected symbols
as local.
ld/
PR ld/33260
* testsuite/ld-i386/i386-export-class.rd: Updated.
* testsuite/ld-i386/i386-export-class.xd: Likewise.
* testsuite/ld-i386/i386.exp: Run pr33260-2.
* testsuite/ld-i386/pr33260-2.d: New file.
* testsuite/ld-i386/pr33260-2.s: Likewise.
* testsuite/ld-i386/pr33260.d: Remove "-z indirect-extern-access".
* testsuite/ld-x86-64/pr33260-x32.d: Likewise.
* testsuite/ld-x86-64/pr33260.d: Likewise.
* testsuite/ld-x86-64/pr33260-2-x32.d: New file.
* testsuite/ld-x86-64/pr33260-2.d: Likewise.
* testsuite/ld-x86-64/pr33260-2.s: Likewise.
* testsuite/ld-x86-64/x86-64-64-export-class.rd: Updated.
* testsuite/ld-x86-64/x86-64-x32-export-class.rd: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr33260-2 and
pr33260-2-x32.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -225,15 +225,14 @@
|
||||
|
||||
/* TRUE if this input relocation should be copied to output. H->dynindx
|
||||
may be -1 if this symbol was marked to become local. STV_PROTECTED
|
||||
symbols with indirect external access are local. */
|
||||
symbols are local. */
|
||||
#define COPY_INPUT_RELOC_P(IS_X86_64, INFO, H, R_TYPE) \
|
||||
((H) != NULL \
|
||||
&& (H)->dynindx != -1 \
|
||||
&& (X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
|
||||
|| !(bfd_link_executable (INFO) \
|
||||
|| SYMBOLIC_BIND ((INFO), (H)) \
|
||||
|| ((INFO)->indirect_extern_access > 0 \
|
||||
&& ELF_ST_VISIBILITY ((H)->other) == STV_PROTECTED)) \
|
||||
|| ELF_ST_VISIBILITY ((H)->other) == STV_PROTECTED) \
|
||||
|| !(H)->def_regular))
|
||||
|
||||
/* TRUE if this is actually a static link, or it is a -Bsymbolic link
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
* Offset * Info * Type * Sym\. *Value * Sym\. * Name
|
||||
12340000 00000008 R_386_RELATIVE *
|
||||
12340010 00000008 R_386_RELATIVE *
|
||||
12340020 00000008 R_386_RELATIVE *
|
||||
12340040 00000008 R_386_RELATIVE *
|
||||
12340050 00000008 R_386_RELATIVE *
|
||||
12340060 00000008 R_386_RELATIVE *
|
||||
12340070 00000008 R_386_RELATIVE *
|
||||
12340080 00000008 R_386_RELATIVE *
|
||||
12340090 00000008 R_386_RELATIVE *
|
||||
12340000 [0-9a-f]+01 R_386_32 123400a0 protected_baz
|
||||
12340040 [0-9a-f]+01 R_386_32 123400a0 protected_foo
|
||||
12340050 [0-9a-f]+01 R_386_32 123400a0 protected_bar
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
Hex dump of section '\.data':
|
||||
0x12340000 00000000 00000000 00000000 00000000 .*
|
||||
0x12340000 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340010 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340020 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340030 00000000 00000000 00000000 00000000 .*
|
||||
0x12340040 00000000 00000000 00000000 00000000 .*
|
||||
0x12340050 00000000 00000000 00000000 00000000 .*
|
||||
0x12340040 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340050 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340060 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340070 a0003412 00000000 00000000 00000000 .*
|
||||
0x12340080 a0003412 00000000 00000000 00000000 .*
|
||||
|
||||
@@ -521,6 +521,7 @@ run_dump_test "pr30787"
|
||||
run_dump_test "pr31047"
|
||||
run_dump_test "pr32191"
|
||||
run_dump_test "pr33260"
|
||||
run_dump_test "pr33260-2"
|
||||
|
||||
if { !([istarget "i?86-*-linux*"]
|
||||
|| [istarget "i?86-*-gnu*"]
|
||||
|
||||
6
ld/testsuite/ld-i386/pr33260-2.d
Normal file
6
ld/testsuite/ld-i386/pr33260-2.d
Normal file
@@ -0,0 +1,6 @@
|
||||
#source: pr33260-2.s
|
||||
#as: -mrelax-relocations=yes --32
|
||||
#ld: -melf_i386 -shared
|
||||
#readelf: -r --wide
|
||||
|
||||
There are no relocations in this file.
|
||||
30
ld/testsuite/ld-i386/pr33260-2.s
Normal file
30
ld/testsuite/ld-i386/pr33260-2.s
Normal file
@@ -0,0 +1,30 @@
|
||||
.text
|
||||
.p2align 4
|
||||
.globl my_func
|
||||
.type my_func, @function
|
||||
my_func:
|
||||
.cfi_startproc
|
||||
call __x86.get_pc_thunk.ax
|
||||
addl $_GLOBAL_OFFSET_TABLE_, %eax
|
||||
movl my_data@GOT(%eax), %eax
|
||||
ret
|
||||
.cfi_endproc
|
||||
.size my_func, .-my_func
|
||||
.protected my_data
|
||||
.globl my_data
|
||||
.bss
|
||||
.align 4
|
||||
.type my_data, @object
|
||||
.size my_data, 4
|
||||
my_data:
|
||||
.zero 4
|
||||
.section .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
|
||||
.globl __x86.get_pc_thunk.ax
|
||||
.hidden __x86.get_pc_thunk.ax
|
||||
.type __x86.get_pc_thunk.ax, @function
|
||||
__x86.get_pc_thunk.ax:
|
||||
.cfi_startproc
|
||||
movl (%esp), %eax
|
||||
ret
|
||||
.cfi_endproc
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
@@ -1,6 +1,6 @@
|
||||
#source: pr33260.s
|
||||
#as: -mrelax-relocations=yes --32
|
||||
#ld: -melf_i386 -shared -z indirect-extern-access
|
||||
#ld: -melf_i386 -shared
|
||||
#readelf: -r --wide
|
||||
|
||||
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
|
||||
|
||||
6
ld/testsuite/ld-x86-64/pr33260-2-x32.d
Normal file
6
ld/testsuite/ld-x86-64/pr33260-2-x32.d
Normal file
@@ -0,0 +1,6 @@
|
||||
#source: pr33260-2.s
|
||||
#as: -mrelax-relocations=yes --x32
|
||||
#ld: -melf32_x86_64 -shared
|
||||
#readelf: -r --wide
|
||||
|
||||
There are no relocations in this file.
|
||||
6
ld/testsuite/ld-x86-64/pr33260-2.d
Normal file
6
ld/testsuite/ld-x86-64/pr33260-2.d
Normal file
@@ -0,0 +1,6 @@
|
||||
#source: pr33260-2.s
|
||||
#as: -mrelax-relocations=yes --64
|
||||
#ld: -melf_x86_64 -shared
|
||||
#readelf: -r --wide
|
||||
|
||||
There are no relocations in this file.
|
||||
19
ld/testsuite/ld-x86-64/pr33260-2.s
Normal file
19
ld/testsuite/ld-x86-64/pr33260-2.s
Normal file
@@ -0,0 +1,19 @@
|
||||
.text
|
||||
.p2align 4
|
||||
.globl my_func
|
||||
.type my_func, @function
|
||||
my_func:
|
||||
.cfi_startproc
|
||||
movq my_data@GOTPCREL(%rip), %rax
|
||||
ret
|
||||
.cfi_endproc
|
||||
.size my_func, .-my_func
|
||||
.protected my_data
|
||||
.globl my_data
|
||||
.bss
|
||||
.align 4
|
||||
.type my_data, @object
|
||||
.size my_data, 4
|
||||
my_data:
|
||||
.zero 4
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
@@ -1,6 +1,6 @@
|
||||
#source: pr33260.s
|
||||
#as: -mrelax-relocations=yes --x32
|
||||
#ld: -melf32_x86_64 -shared -z indirect-extern-access
|
||||
#ld: -melf32_x86_64 -shared
|
||||
#readelf: -r --wide
|
||||
|
||||
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#source: pr33260.s
|
||||
#as: -mrelax-relocations=yes --64 -defsym __x86_64__=1
|
||||
#ld: -melf_x86_64 -shared -z indirect-extern-access
|
||||
#ld: -melf_x86_64 -shared
|
||||
#readelf: -r --wide
|
||||
|
||||
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
* Offset * Info * Type * Sym\. *Value * Sym\. * Name * \+ * Addend
|
||||
000012340000 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340010 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340020 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340040 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340050 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340060 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340070 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340080 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340090 000000000008 R_X86_64_RELATIVE 123400a0
|
||||
000012340000 [0-9a-f]+00000001 R_X86_64_64 00000000123400a0 protected_baz \+ 0
|
||||
000012340040 [0-9a-f]+00000001 R_X86_64_64 00000000123400a0 protected_foo \+ 0
|
||||
000012340050 [0-9a-f]+00000001 R_X86_64_64 00000000123400a0 protected_bar \+ 0
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries:
|
||||
* Offset * Info * Type * Sym\. *Value * Sym\. * Name * \+ * Addend
|
||||
12340000 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340010 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340020 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340040 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340050 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340060 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340070 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340080 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340090 00000008 R_X86_64_RELATIVE 123400a0
|
||||
12340000 [0-9a-f]+0a R_X86_64_32 123400a0 protected_baz \+ 0
|
||||
12340040 [0-9a-f]+0a R_X86_64_32 123400a0 protected_foo \+ 0
|
||||
12340050 [0-9a-f]+0a R_X86_64_32 123400a0 protected_bar \+ 0
|
||||
|
||||
@@ -566,6 +566,8 @@ run_dump_test "pr32591-4-x32"
|
||||
run_dump_test "pr32809"
|
||||
run_dump_test "pr33260"
|
||||
run_dump_test "pr33260-x32"
|
||||
run_dump_test "pr33260-2"
|
||||
run_dump_test "pr33260-2-x32"
|
||||
|
||||
if { ![skip_sframe_tests] } {
|
||||
run_dump_test "sframe-simple-1"
|
||||
|
||||
Reference in New Issue
Block a user