mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
6f365fda85
If GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS is set on any input relocatable files: 1. Don't generate copy relocations. 2. Turn off extern_protected_data since it implies GNU_PROPERTY_NO_COPY_ON_PROTECTED. 3. Treate reference to protected symbols with indirect external access as local. 4. Set GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS on output. 5. When generating executable, clear this bit when there are non-GOT or non-PLT relocations in input relocatable files without the bit set. 6. Add -z [no]indirect-extern-access to control indirect external access. bfd/ * elf-bfd (elf_obj_tdata): Add has_indirect_extern_access. (elf_has_indirect_extern_access): New. * elf-properties.c (_bfd_elf_parse_gnu_properties): Set elf_has_indirect_extern_access and elf_has_no_copy_on_protected when seeing GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. (elf_write_gnu_propertie): Add an argument to pass link_info. Set needed_1_p for GNU_PROPERTY_1_NEEDED in memory. (_bfd_elf_link_setup_gnu_properties): Handle GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS for -z indirect-extern-access. Set nocopyreloc to true and extern_protected_data to false for indirect external access. (_bfd_elf_convert_gnu_properties): Updated. * elf32-i386.c (elf_i386_check_relocs): Set non_got_ref_without_indirect_extern_access on legacy non-GOT or non-PLT references. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. * elflink.c (_bfd_elf_symbol_refs_local_p): Return true for STV_PROTECTED symbols with indirect external access. * elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Clear indirect_extern_access for legacy non-GOT/non-PLT references. * elfxx-x86.h (elf_x86_link_hash_entry): Add non_got_ref_without_indirect_extern_access. include/ * bfdlink.h (bfd_link_info): Add indirect_extern_access and needed_1_p. Change nocopyreloc to int. ld/ * NEWS: Mention -z [no]indirect-extern-access * ld.texi: Document -z [no]indirect-extern-access * ldmain.c (main): Initialize link_info.indirect_extern_access to -1. * emulparams/extern_protected_data.sh: Support -z [no]indirect-extern-access. * testsuite/ld-elf/indirect-extern-access-1.rd: New file * testsuite/ld-elf/indirect-extern-access-1a.c: Likewise. * testsuite/ld-elf/indirect-extern-access-1b.c: Likewise. * testsuite/ld-elf/indirect-extern-access-2.rd: Likewise. * testsuite/ld-elf/indirect-extern-access-2a.c: Likewise. * testsuite/ld-elf/indirect-extern-access-2b.c: Likewise. * testsuite/ld-elf/indirect-extern-access-3.rd: Likewise. * testsuite/ld-elf/indirect-extern-access.S: Likewise. * testsuite/ld-elf/property-1_needed-1b.d: Likewise. * testsuite/ld-elf/property-1_needed-1c.d: Likewise. * testsuite/ld-x86-64/indirect-extern-access.rd: Likewise. * testsuite/ld-x86-64/protected-data-1.h: Likewise. * testsuite/ld-x86-64/protected-data-1a.c: Likewise. * testsuite/ld-x86-64/protected-data-1b.c: Likewise. * testsuite/ld-x86-64/protected-data-2a.S: Likewise. * testsuite/ld-x86-64/protected-data-2b.S: Likewise. * testsuite/ld-x86-64/protected-func-2a.S: Likewise. * testsuite/ld-x86-64/protected-func-2b.S: Likewise. * testsuite/ld-x86-64/protected-func-2c.c: Likewise. * testsuite/ld-elf/linux-x86.exp: Run test with GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. * testsuite/ld-x86-64/x86-64.exp: Run tests for protected function and data with indirect external access.
69 lines
1.3 KiB
ArmAsm
69 lines
1.3 KiB
ArmAsm
.text
|
|
.p2align 4
|
|
.protected protected_func_1a
|
|
.globl protected_func_1a
|
|
.type protected_func_1a, @function
|
|
protected_func_1a:
|
|
.LFB0:
|
|
.cfi_startproc
|
|
movl $1, %eax
|
|
ret
|
|
.cfi_endproc
|
|
.LFE0:
|
|
.size protected_func_1a, .-protected_func_1a
|
|
.p2align 4
|
|
.protected protected_func_1b
|
|
.globl protected_func_1b
|
|
.type protected_func_1b, @function
|
|
protected_func_1b:
|
|
.LFB1:
|
|
.cfi_startproc
|
|
movl $2, %eax
|
|
ret
|
|
.cfi_endproc
|
|
.LFE1:
|
|
.size protected_func_1b, .-protected_func_1b
|
|
.p2align 4
|
|
.globl protected_func_1a_p
|
|
.type protected_func_1a_p, @function
|
|
protected_func_1a_p:
|
|
.LFB2:
|
|
.cfi_startproc
|
|
leaq protected_func_1a(%rip), %rax
|
|
ret
|
|
.cfi_endproc
|
|
.LFE2:
|
|
.size protected_func_1a_p, .-protected_func_1a_p
|
|
.p2align 4
|
|
.globl protected_func_1b_p
|
|
.type protected_func_1b_p, @function
|
|
protected_func_1b_p:
|
|
.LFB3:
|
|
.cfi_startproc
|
|
leaq protected_func_1b(%rip), %rax
|
|
ret
|
|
.cfi_endproc
|
|
.LFE3:
|
|
.size protected_func_1b_p, .-protected_func_1b_p
|
|
.section .note.GNU-stack,"",@progbits
|
|
#ifdef __LP64__
|
|
# define ALIGN 3
|
|
#else
|
|
# define ALIGN 2
|
|
#endif
|
|
.section ".note.gnu.property", "a"
|
|
.p2align ALIGN
|
|
.long 1f - 0f /* name length */
|
|
.long 5f - 2f /* data length */
|
|
.long 5 /* note type */
|
|
0: .asciz "GNU" /* vendor name */
|
|
1:
|
|
.p2align ALIGN
|
|
2: .long 0xb0008000 /* pr_type. */
|
|
.long 4f - 3f /* pr_datasz. */
|
|
3:
|
|
.long 0x1
|
|
4:
|
|
.p2align ALIGN
|
|
5:
|