aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-06-22 05:44:37 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-06-22 05:44:53 -0700
commitee2fdd6f36c10ceb84e05c7234983bcfbe6146d5 (patch)
treef8980ac68ae80a5db4c84efaec81d7b35c833da8 /ld
parentf4906a9a7441ef9c2758513420568994a1e7fed3 (diff)
downloadgdb-ee2fdd6f36c10ceb84e05c7234983bcfbe6146d5.zip
gdb-ee2fdd6f36c10ceb84e05c7234983bcfbe6146d5.tar.gz
gdb-ee2fdd6f36c10ceb84e05c7234983bcfbe6146d5.tar.bz2
x86: Support Intel IBT with IBT property and IBT-enable PLT
To support IBT in Intel Control-flow Enforcement Technology (CET) instructions: https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002 #define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0) are added to GNU program properties to indicate that all executable sections are compatible with IBT when ENDBR instruction starts each valid target where an indirect branch instruction can land. GNU_PROPERTY_X86_FEATURE_1_IBT is set on output only if it is set on all relocatable inputs. The followings changes are made to the Procedure Linkage Table (PLT): 1. For 64-bit x86-64, PLT is changed to PLT0: push GOT[1] bnd jmp *GOT[2] nop ... PLTn: endbr64 push namen_reloc_index bnd jmp PLT0 together with the second PLT section: PLTn: endbr64 bnd jmp *GOT[namen_index] nop BND prefix is also added so that IBT-enabled PLT is compatible with MPX. 2. For 32-bit x86-64 (x32) and i386, PLT is changed to PLT0: push GOT[1] jmp *GOT[2] nop ... PLTn: endbr64 # endbr32 for i386. push namen_reloc_index jmp PLT0 together with the second PLT section: PLTn: endbr64 # endbr32 for i386. jmp *GOT[namen_index] nop BND prefix isn't used since MPX isn't supported on x32 and BND registers aren't used in parameter passing on i386. GOT is an array of addresses. Initially, GOT[namen_index] is filled with the address of the ENDBR instruction of the corresponding entry in the first PLT section. The function, namen, is called via the ENDBR instruction in the second PLT entry. GOT[namen_index] is updated to the actual address of the function, namen, at run-time. 2 linker command line options are added: 1. -z ibtplt: Generate IBT-enabled PLT. 2. -z ibt: Generate GNU_PROPERTY_X86_FEATURE_1_IBT in GNU program properties as well as IBT-enabled PLT. bfd/ * elf32-i386.c (elf_i386_lazy_ibt_plt0_entry): New. (elf_i386_lazy_ibt_plt_entry): Likewise. (elf_i386_pic_lazy_ibt_plt0_entry): Likewise. (elf_i386_non_lazy_ibt_plt_entry): Likewise. (elf_i386_pic_non_lazy_ibt_plt_entry): Likewise. (elf_i386_eh_frame_lazy_ibt_plt): Likewise. (elf_i386_lazy_plt_layout): Likewise. (elf_i386_non_lazy_plt_layout): Likewise. (elf_i386_link_hash_entry): Add plt_second. (elf_i386_link_hash_table): Add plt_second and plt_second_eh_frame. (elf_i386_allocate_dynrelocs): Use the second PLT if needed. (elf_i386_size_dynamic_sections): Use .plt.got unwind info for the second PLT. Check the second PLT. (elf_i386_relocate_section): Use the second PLT to resolve PLT reference if needed. (elf_i386_finish_dynamic_symbol): Fill and use the second PLT if needed. (elf_i386_finish_dynamic_sections): Set sh_entsize on the second PLT. Generate unwind info for the second PLT. (elf_i386_plt_type): Add plt_second. (elf_i386_get_synthetic_symtab): Support the second PLT. (elf_i386_parse_gnu_properties): Support GNU_PROPERTY_X86_FEATURE_1_AND. (elf_i386_merge_gnu_properties): Support GNU_PROPERTY_X86_FEATURE_1_AND. If info->ibt is set, turn on GNU_PROPERTY_X86_FEATURE_1_IBT (elf_i386_link_setup_gnu_properties): If info->ibt is set, turn on GNU_PROPERTY_X86_FEATURE_1_IBT. Use IBT-enabled PLT for info->ibtplt, info->ibt or GNU_PROPERTY_X86_FEATURE_1_IBT is set on all relocatable inputs. * elf64-x86-64.c (elf_x86_64_lazy_ibt_plt_entry): New. (elf_x32_lazy_ibt_plt_entry): Likewise. (elf_x86_64_non_lazy_ibt_plt_entry): Likewise. (elf_x32_non_lazy_ibt_plt_entry): Likewise. (elf_x86_64_eh_frame_lazy_ibt_plt): Likewise. (elf_x32_eh_frame_lazy_ibt_plt): Likewise. (elf_x86_64_lazy_ibt_plt): Likewise. (elf_x32_lazy_ibt_plt): Likewise. (elf_x86_64_non_lazy_ibt_plt): Likewise. (elf_x32_non_lazy_ibt_plt): Likewise. (elf_x86_64_get_synthetic_symtab): Support the second PLT. (elf_x86_64_parse_gnu_properties): Support GNU_PROPERTY_X86_FEATURE_1_AND. (elf_x86_64_merge_gnu_properties): Support GNU_PROPERTY_X86_FEATURE_1_AND. If info->ibt is set, turn on GNU_PROPERTY_X86_FEATURE_1_IBT (elf_x86_64_link_setup_gnu_properties): If info->ibt is set, turn on GNU_PROPERTY_X86_FEATURE_1_IBT. Use IBT-enabled PLT for info->ibtplt, info->ibt or GNU_PROPERTY_X86_FEATURE_1_IBT is set on all relocatable inputs. binutils/ * readelf.c (decode_x86_feature): New. (print_gnu_property_note): Call decode_x86_feature on GNU_PROPERTY_X86_FEATURE_1_AND. * testsuite/binutils-all/i386/empty.d: New file. * testsuite/binutils-all/i386/empty.s: Likewise. * testsuite/binutils-all/i386/ibt.d: Likewise. * testsuite/binutils-all/i386/ibt.s: Likewise. * testsuite/binutils-all/x86-64/empty-x32.d: Likewise. * testsuite/binutils-all/x86-64/empty.d: Likewise. * testsuite/binutils-all/x86-64/empty.s: Likewise. * testsuite/binutils-all/x86-64/ibt-x32.d: Likewise. * testsuite/binutils-all/x86-64/ibt.d: Likewise. * testsuite/binutils-all/x86-64/ibt.s: Likewise. include/ * bfdlink.h (bfd_link_info): Add ibtplt and ibt. * elf/common.h (GNU_PROPERTY_X86_FEATURE_1_AND): New. (GNU_PROPERTY_X86_FEATURE_1_IBT): Likewise. ld/ * Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emulparams/cet.sh. * Makefile.in: Regenerated. * NEWS: Mention GNU_PROPERTY_X86_FEATURE_1_IBT, -z ibtplt and -z ibt. * emulparams/cet.sh: New file. * testsuite/ld-i386/ibt-plt-1.d: Likewise. * testsuite/ld-i386/ibt-plt-1.s: Likewise. * testsuite/ld-i386/ibt-plt-2.s: Likewise. * testsuite/ld-i386/ibt-plt-2a.d: Likewise. * testsuite/ld-i386/ibt-plt-2b.d: Likewise. * testsuite/ld-i386/ibt-plt-2c.d: Likewise. * testsuite/ld-i386/ibt-plt-2d.d: Likewise. * testsuite/ld-i386/ibt-plt-3.s: Likewise. * testsuite/ld-i386/ibt-plt-3a.d: Likewise. * testsuite/ld-i386/ibt-plt-3b.d: Likewise. * testsuite/ld-i386/ibt-plt-3c.d: Likewise. * testsuite/ld-i386/ibt-plt-3d.d: Likewise. * testsuite/ld-i386/plt-main-ibt.dd: Likewise. * testsuite/ld-i386/plt-pie-ibt.dd: Likewise. * testsuite/ld-i386/property-x86-empty.s: Likewise. * testsuite/ld-i386/property-x86-ibt.s: Likewise. * testsuite/ld-i386/property-x86-ibt1a.d: Likewise. * testsuite/ld-i386/property-x86-ibt1b.d: Likewise. * testsuite/ld-i386/property-x86-ibt2.d: Likewise. * testsuite/ld-i386/property-x86-ibt3a.d: Likewise. * testsuite/ld-i386/property-x86-ibt3b.d: Likewise. * testsuite/ld-i386/property-x86-ibt4.d: Likewise. * testsuite/ld-i386/property-x86-ibt5.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1.d: Likewise. * testsuite/ld-x86-64/ibt-plt-1.s: Likewise. * testsuite/ld-x86-64/ibt-plt-2.s: Likewise. * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2d.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3.s: Likewise. * testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3b.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3c.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3d.d: Likewise. * testsuite/ld-x86-64/plt-main-ibt-now.rd: Likewise. * testsuite/ld-x86-64/plt-main-ibt-x32.dd: Likewise. * testsuite/ld-x86-64/plt-main-ibt.dd: Likewise. * testsuite/ld-x86-64/property-x86-empty.s: Likewise. * testsuite/ld-x86-64/property-x86-ibt.s: Likewise. * testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt2.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt4.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise. * testsuite/ld-x86-64/property-x86-ibt5.d: Likewise. * emulparams/elf32_x86_64.sh: Source emulparams/cet.sh. (TINY_READONLY_SECTION): Add .plt.sec. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_x86_64.sh: Source emulparams/cet.sh. * ld.texinfo: Document -z ibtplt and -z ibt. * testsuite/ld-i386/i386.exp: Run IBT and IBT PLT tests. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-x86-64/pr21481b.S (check): Updated for x32.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog79
-rw-r--r--ld/Makefile.am3
-rw-r--r--ld/Makefile.in3
-rw-r--r--ld/NEWS9
-rw-r--r--ld/emulparams/cet.sh14
-rw-r--r--ld/emulparams/elf32_x86_64.sh2
-rw-r--r--ld/emulparams/elf_i386.sh2
-rw-r--r--ld/emulparams/elf_x86_64.sh1
-rw-r--r--ld/ld.texinfo9
-rw-r--r--ld/testsuite/ld-i386/i386.exp78
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-1.d51
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-1.s54
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-2.s54
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-2a.d52
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-2b.d9
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-2c.d52
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-2d.d9
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-3.s38
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-3a.d52
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-3b.d5
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-3c.d52
-rw-r--r--ld/testsuite/ld-i386/ibt-plt-3d.d9
-rw-r--r--ld/testsuite/ld-i386/plt-main-ibt.dd7
-rw-r--r--ld/testsuite/ld-i386/plt-pie-ibt.dd7
-rw-r--r--ld/testsuite/ld-i386/property-x86-empty.s27
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt.s27
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt1a.d6
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt1b.d6
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt2.d9
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt3a.d11
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt3b.d11
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt4.d9
-rw-r--r--ld/testsuite/ld-i386/property-x86-ibt5.d9
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-1-x32.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-1.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-1.s45
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2.s45
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2a.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d9
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2b.d9
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2c.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d9
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-2d.d9
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3.s17
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3a-x32.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3a.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3b-x32.d5
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3b.d5
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3c.d43
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d10
-rw-r--r--ld/testsuite/ld-x86-64/ibt-plt-3d.d10
-rw-r--r--ld/testsuite/ld-x86-64/plt-main-ibt-now.rd3
-rw-r--r--ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd7
-rw-r--r--ld/testsuite/ld-x86-64/plt-main-ibt.dd7
-rw-r--r--ld/testsuite/ld-x86-64/pr21481b.S4
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-empty.s27
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt.s27
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt1a-x32.d6
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt1a.d6
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt1b-x32.d6
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt1b.d6
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt2-x32.d9
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt2.d9
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d11
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt3a.d11
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d11
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt3b.d11
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt4-x32.d9
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt4.d9
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt5-x32.d9
-rw-r--r--ld/testsuite/ld-x86-64/property-x86-ibt5.d9
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp182
75 files changed, 1746 insertions, 2 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 94af73d..b3567e1 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,82 @@
+2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emulparams/cet.sh.
+ * Makefile.in: Regenerated.
+ * NEWS: Mention GNU_PROPERTY_X86_FEATURE_1_IBT, -z ibtplt
+ and -z ibt.
+ * emulparams/cet.sh: New file.
+ * testsuite/ld-i386/ibt-plt-1.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-1.s: Likewise.
+ * testsuite/ld-i386/ibt-plt-2.s: Likewise.
+ * testsuite/ld-i386/ibt-plt-2a.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-2b.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-2c.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-2d.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-3.s: Likewise.
+ * testsuite/ld-i386/ibt-plt-3a.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-3b.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-3c.d: Likewise.
+ * testsuite/ld-i386/ibt-plt-3d.d: Likewise.
+ * testsuite/ld-i386/plt-main-ibt.dd: Likewise.
+ * testsuite/ld-i386/plt-pie-ibt.dd: Likewise.
+ * testsuite/ld-i386/property-x86-empty.s: Likewise.
+ * testsuite/ld-i386/property-x86-ibt.s: Likewise.
+ * testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
+ * testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
+ * testsuite/ld-i386/property-x86-ibt2.d: Likewise.
+ * testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
+ * testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
+ * testsuite/ld-i386/property-x86-ibt4.d: Likewise.
+ * testsuite/ld-i386/property-x86-ibt5.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-1.s: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2.s: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-2d.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3.s: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3b.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
+ * testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
+ * testsuite/ld-x86-64/plt-main-ibt-now.rd: Likewise.
+ * testsuite/ld-x86-64/plt-main-ibt-x32.dd: Likewise.
+ * testsuite/ld-x86-64/plt-main-ibt.dd: Likewise.
+ * testsuite/ld-x86-64/property-x86-empty.s: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt.s: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
+ * emulparams/elf32_x86_64.sh: Source emulparams/cet.sh.
+ (TINY_READONLY_SECTION): Add .plt.sec.
+ * emulparams/elf_i386.sh: Likewise.
+ * emulparams/elf_x86_64.sh: Source emulparams/cet.sh.
+ * ld.texinfo: Document -z ibtplt and -z ibt.
+ * testsuite/ld-i386/i386.exp: Run IBT and IBT PLT tests.
+ * testsuite/ld-x86-64/x86-64.exp: Likewise.
+ * testsuite/ld-x86-64/pr21481b.S (check): Updated for x32.
+
2017-06-21 H.J. Lu <hongjiu.lu@intel.com>
PR ld/21090
diff --git a/ld/Makefile.am b/ld/Makefile.am
index b509e23..fcd4c36 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -677,7 +677,8 @@ ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emulparams/plt_unwind.sh \
$(srcdir)/emulparams/extern_protected_data.sh \
$(srcdir)/emulparams/dynamic_undefined_weak.sh \
$(srcdir)/emulparams/reloc_overflow.sh \
- $(srcdir)/emulparams/call_nop.sh
+ $(srcdir)/emulparams/call_nop.sh \
+ $(srcdir)/emulparams/cet.sh
@TDIRS@
diff --git a/ld/Makefile.in b/ld/Makefile.in
index b69d6b8..5e66e02 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -932,7 +932,8 @@ ELF_X86_DEPS = $(ELF_DEPS) $(srcdir)/emulparams/plt_unwind.sh \
$(srcdir)/emulparams/extern_protected_data.sh \
$(srcdir)/emulparams/dynamic_undefined_weak.sh \
$(srcdir)/emulparams/reloc_overflow.sh \
- $(srcdir)/emulparams/call_nop.sh
+ $(srcdir)/emulparams/call_nop.sh \
+ $(srcdir)/emulparams/cet.sh
# We need this for automake to use YLWRAP.
diff --git a/ld/NEWS b/ld/NEWS
index 98055b5..b115843 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,14 @@
-*- text -*-
+* Add support for GNU_PROPERTY_X86_FEATURE_1_IBT in ELF GNU program
+
+* Support for -z ibtplt in the x86 ELF linker to generate IBT-enabled
+ PLT.
+
+* Support for -z ibt in the x86 ELF linker to generate IBT-enabled
+ PLT as well as GNU_PROPERTY_X86_FEATURE_1_IBT in ELF GNU program
+ properties.
+
* Add support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX.
* Add support for ELF GNU program properties.
diff --git a/ld/emulparams/cet.sh b/ld/emulparams/cet.sh
new file mode 100644
index 0000000..62ff105
--- /dev/null
+++ b/ld/emulparams/cet.sh
@@ -0,0 +1,14 @@
+PARSE_AND_LIST_OPTIONS_CET='
+ fprintf (file, _("\
+ -z ibtplt Generate IBT-enabled PLT entries\n\
+ -z ibt Generate GNU_PROPERTY_X86_FEATURE_1_IBT\n"));
+'
+PARSE_AND_LIST_ARGS_CASE_Z_CET='
+ else if (strcmp (optarg, "ibtplt") == 0)
+ link_info.ibtplt = TRUE;
+ else if (strcmp (optarg, "ibt") == 0)
+ link_info.ibt = TRUE;
+'
+
+PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_CET"
+PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_CET"
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
index 9b85239..06a0f3c 100644
--- a/ld/emulparams/elf32_x86_64.sh
+++ b/ld/emulparams/elf32_x86_64.sh
@@ -3,6 +3,7 @@
. ${srcdir}/emulparams/dynamic_undefined_weak.sh
. ${srcdir}/emulparams/reloc_overflow.sh
. ${srcdir}/emulparams/call_nop.sh
+. ${srcdir}/emulparams/cet.sh
SCRIPT_NAME=elf
ELFSIZE=32
OUTPUT_FORMAT="elf32-x86-64"
@@ -24,6 +25,7 @@ IREL_IN_PLT=
# Reuse TINY_READONLY_SECTION which is placed right after .plt section.
TINY_READONLY_SECTION="
.plt.got ${RELOCATING-0} : { *(.plt.got) }
+.plt.sec ${RELOCATING-0} : { *(.plt.sec) }
"
if [ "x${host}" = "x${target}" ]; then
diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
index b08e661..6997d40 100644
--- a/ld/emulparams/elf_i386.sh
+++ b/ld/emulparams/elf_i386.sh
@@ -2,6 +2,7 @@
. ${srcdir}/emulparams/extern_protected_data.sh
. ${srcdir}/emulparams/dynamic_undefined_weak.sh
. ${srcdir}/emulparams/call_nop.sh
+. ${srcdir}/emulparams/cet.sh
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-i386"
CHECK_RELOCS_AFTER_OPEN_INPUT=yes
@@ -20,6 +21,7 @@ IREL_IN_PLT=
# Reuse TINY_READONLY_SECTION which is placed right after .plt section.
TINY_READONLY_SECTION="
.plt.got ${RELOCATING-0} : { *(.plt.got) }
+.plt.sec ${RELOCATING-0} : { *(.plt.sec) }
"
# Linux modify the default library search path to first include
diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index ca6d06c..ad25526 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -3,6 +3,7 @@
. ${srcdir}/emulparams/dynamic_undefined_weak.sh
. ${srcdir}/emulparams/reloc_overflow.sh
. ${srcdir}/emulparams/call_nop.sh
+. ${srcdir}/emulparams/cet.sh
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-x86-64"
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 44ad84b..4f7873c 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1261,6 +1261,15 @@ to a locally defined function, foo, via its GOT slot.
@option{call-nop=suffix-@var{byte}} generates @code{call foo @var{byte}}.
Supported for i386 and x86_64.
+@item ibtplt
+Generate Intel Indirect Branch Tracking (IBT) enabled PLT entries.
+Supported for Linux/i386 and Linux/x86_64.
+
+@item IBT
+Generate GNU_PROPERTY_X86_FEATURE_1_IBT in .note.gnu.property section
+to indicate compatibility with IBT. This also implies @option{ibtplt}.
+Supported for Linux/i386 and Linux/x86_64.
+
@end table
Other keywords are ignored for Solaris compatibility.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 2e3c224..d30dc76 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -420,6 +420,13 @@ run_dump_test "pr20515"
run_dump_test "property-x86-3"
run_dump_test "property-x86-4a"
run_dump_test "property-x86-4b"
+run_dump_test "property-x86-ibt1a"
+run_dump_test "property-x86-ibt1b"
+run_dump_test "property-x86-ibt2"
+run_dump_test "property-x86-ibt3a"
+run_dump_test "property-x86-ibt3b"
+run_dump_test "property-x86-ibt4"
+run_dump_test "property-x86-ibt5"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
@@ -1100,6 +1107,8 @@ if { [isnative]
undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
}
+global NOPIE_LDFLAGS
+
# Must be native with the C compiler and working IFUNC support,
if { [isnative]
&& [check_ifunc_available]
@@ -1156,6 +1165,66 @@ if { [isnative]
"pass.out" \
] \
]
+
+ if { [istarget "i?86-*-linux*"] } {
+ run_cc_link_tests [list \
+ [list \
+ "Build pr21168.so with -z ibtplt" \
+ "-shared -Wl,-z,ibtplt" \
+ "" \
+ { pr21168b.S } \
+ "" \
+ "pr21168-ibt.so" \
+ ] \
+ [list \
+ "Build ifunc-1a with -z ibtplt" \
+ "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
+ tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+ "" \
+ { dummy.c } \
+ {{objdump {-dw} plt-main-ibt.dd}} \
+ "ifunc-1a-ibt" \
+ ] \
+ [list \
+ "Build ifunc-1a with PIE -z ibtplt" \
+ "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
+ tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+ "" \
+ { dummy.c } \
+ {{objdump {-dw} plt-pie-ibt.dd}} \
+ "ifunc-1a-pie-ibt" \
+ ] \
+ ]
+
+ run_ld_link_exec_tests [list \
+ [list \
+ "Run ifunc-1a with -z ibtplt" \
+ "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
+ tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+ "" \
+ { dummy.c } \
+ "ifunc-1a-ibt" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run ifunc-1a with PIE -z ibtplt" \
+ "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
+ tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+ "" \
+ { dummy.c } \
+ "ifunc-1a-pie-ibt" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr21168 with -z ibtplt" \
+ "tmpdir/pr21168a.o tmpdir/pr21168-ibt.so" \
+ "" \
+ { dummy.c } \
+ "pr21168-ibt" \
+ "pass.out" \
+ ] \
+ ]
+ }
}
if { !([istarget "i?86-*-linux*"]
@@ -1206,3 +1275,12 @@ run_ld_link_tests [list \
run_dump_test "pltgot-1"
run_dump_test "pltgot-2"
run_dump_test "pr20830"
+run_dump_test "ibt-plt-1"
+run_dump_test "ibt-plt-2a"
+run_dump_test "ibt-plt-2b"
+run_dump_test "ibt-plt-2c"
+run_dump_test "ibt-plt-2d"
+run_dump_test "ibt-plt-3a"
+run_dump_test "ibt-plt-3b"
+run_dump_test "ibt-plt-3c"
+run_dump_test "ibt-plt-3d"
diff --git a/ld/testsuite/ld-i386/ibt-plt-1.d b/ld/testsuite/ld-i386/ibt-plt-1.d
new file mode 100644
index 0000000..1c90591
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-1.d
@@ -0,0 +1,51 @@
+#as: --32
+#ld: -shared -m elf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1b0 <.plt>:
+ +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\)
+ +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\)
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\)
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 00 00 00 00 push \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmp 1b0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 08 00 00 00 push \$0x8
+ +[a-f0-9]+: e9 d2 ff ff ff jmp 1b0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1e0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+0+1f0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+Disassembly of section .text:
+
+0+200 <foo>:
+ +[a-f0-9]+: 53 push %ebx
+ +[a-f0-9]+: e8 18 00 00 00 call 21e <__x86.get_pc_thunk.bx>
+ +[a-f0-9]+: 81 c3 22 11 00 00 add \$0x1122,%ebx
+ +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
+ +[a-f0-9]+: e8 dc ff ff ff call 1f0 <bar2@plt>
+ +[a-f0-9]+: e8 c7 ff ff ff call 1e0 <bar1@plt>
+ +[a-f0-9]+: 83 c4 08 add \$0x8,%esp
+ +[a-f0-9]+: 5b pop %ebx
+ +[a-f0-9]+: c3 ret
+
+0+21e <__x86.get_pc_thunk.bx>:
+ +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-i386/ibt-plt-1.s b/ld/testsuite/ld-i386/ibt-plt-1.s
new file mode 100644
index 0000000..80e2311
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-1.s
@@ -0,0 +1,54 @@
+ .text
+ .p2align 4,,15
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .cfi_startproc
+ pushl %ebx
+ .cfi_def_cfa_offset 8
+ .cfi_offset 3, -8
+ call __x86.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $8, %esp
+ .cfi_def_cfa_offset 16
+ call bar2@PLT
+ call bar1@PLT
+ addl $8, %esp
+ .cfi_def_cfa_offset 8
+ popl %ebx
+ .cfi_restore 3
+ .cfi_def_cfa_offset 4
+ ret
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .section .note.GNU-stack,"",@progbits
+
+ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+.LFB1:
+ .cfi_startproc
+ movl (%esp), %ebx
+ ret
+ .cfi_endproc
+.LFE1:
+
+ .section ".note.gnu.property", "a"
+ .p2align 2
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+ .p2align 2
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x1
+4:
+ .p2align 2
+5:
diff --git a/ld/testsuite/ld-i386/ibt-plt-2.s b/ld/testsuite/ld-i386/ibt-plt-2.s
new file mode 100644
index 0000000..500fdd2
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-2.s
@@ -0,0 +1,54 @@
+ .text
+ .p2align 4,,15
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .cfi_startproc
+ pushl %ebx
+ .cfi_def_cfa_offset 8
+ .cfi_offset 3, -8
+ call __x86.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $8, %esp
+ .cfi_def_cfa_offset 16
+ call bar2@PLT
+ call bar1@PLT
+ addl $8, %esp
+ .cfi_def_cfa_offset 8
+ popl %ebx
+ .cfi_restore 3
+ .cfi_def_cfa_offset 4
+ ret
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .section .note.GNU-stack,"",@progbits
+
+ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+.LFB1:
+ .cfi_startproc
+ movl (%esp), %ebx
+ ret
+ .cfi_endproc
+.LFE1:
+
+ .section ".note.gnu.property", "a"
+ .p2align 2
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+ .p2align 2
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x0
+4:
+ .p2align 2
+5:
diff --git a/ld/testsuite/ld-i386/ibt-plt-2a.d b/ld/testsuite/ld-i386/ibt-plt-2a.d
new file mode 100644
index 0000000..4881dea
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-2a.d
@@ -0,0 +1,52 @@
+#source: ibt-plt-2.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1b0 <.plt>:
+ +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\)
+ +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\)
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\)
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 00 00 00 00 push \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmp 1b0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 08 00 00 00 push \$0x8
+ +[a-f0-9]+: e9 d2 ff ff ff jmp 1b0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1e0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+0+1f0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+Disassembly of section .text:
+
+0+200 <foo>:
+ +[a-f0-9]+: 53 push %ebx
+ +[a-f0-9]+: e8 18 00 00 00 call 21e <__x86.get_pc_thunk.bx>
+ +[a-f0-9]+: 81 c3 22 11 00 00 add \$0x1122,%ebx
+ +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
+ +[a-f0-9]+: e8 dc ff ff ff call 1f0 <bar2@plt>
+ +[a-f0-9]+: e8 c7 ff ff ff call 1e0 <bar1@plt>
+ +[a-f0-9]+: 83 c4 08 add \$0x8,%esp
+ +[a-f0-9]+: 5b pop %ebx
+ +[a-f0-9]+: c3 ret
+
+0+21e <__x86.get_pc_thunk.bx>:
+ +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-i386/ibt-plt-2b.d b/ld/testsuite/ld-i386/ibt-plt-2b.d
new file mode 100644
index 0000000..740b889
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-2b.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-2.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibtplt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature:
diff --git a/ld/testsuite/ld-i386/ibt-plt-2c.d b/ld/testsuite/ld-i386/ibt-plt-2c.d
new file mode 100644
index 0000000..2ba1d78
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-2c.d
@@ -0,0 +1,52 @@
+#source: ibt-plt-2.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1b0 <.plt>:
+ +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\)
+ +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\)
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\)
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 00 00 00 00 push \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmp 1b0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 08 00 00 00 push \$0x8
+ +[a-f0-9]+: e9 d2 ff ff ff jmp 1b0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1e0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+0+1f0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+Disassembly of section .text:
+
+0+200 <foo>:
+ +[a-f0-9]+: 53 push %ebx
+ +[a-f0-9]+: e8 18 00 00 00 call 21e <__x86.get_pc_thunk.bx>
+ +[a-f0-9]+: 81 c3 22 11 00 00 add \$0x1122,%ebx
+ +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
+ +[a-f0-9]+: e8 dc ff ff ff call 1f0 <bar2@plt>
+ +[a-f0-9]+: e8 c7 ff ff ff call 1e0 <bar1@plt>
+ +[a-f0-9]+: 83 c4 08 add \$0x8,%esp
+ +[a-f0-9]+: 5b pop %ebx
+ +[a-f0-9]+: c3 ret
+
+0+21e <__x86.get_pc_thunk.bx>:
+ +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-i386/ibt-plt-2d.d b/ld/testsuite/ld-i386/ibt-plt-2d.d
new file mode 100644
index 0000000..3e02a62
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-2d.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-2.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-i386/ibt-plt-3.s b/ld/testsuite/ld-i386/ibt-plt-3.s
new file mode 100644
index 0000000..b52f2e7
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-3.s
@@ -0,0 +1,38 @@
+ .text
+ .p2align 4,,15
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .cfi_startproc
+ pushl %ebx
+ .cfi_def_cfa_offset 8
+ .cfi_offset 3, -8
+ call __x86.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $8, %esp
+ .cfi_def_cfa_offset 16
+ call bar2@PLT
+ call bar1@PLT
+ addl $8, %esp
+ .cfi_def_cfa_offset 8
+ popl %ebx
+ .cfi_restore 3
+ .cfi_def_cfa_offset 4
+ ret
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .section .note.GNU-stack,"",@progbits
+
+ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+.LFB1:
+ .cfi_startproc
+ movl (%esp), %ebx
+ ret
+ .cfi_endproc
+.LFE1:
diff --git a/ld/testsuite/ld-i386/ibt-plt-3a.d b/ld/testsuite/ld-i386/ibt-plt-3a.d
new file mode 100644
index 0000000..c2ce3fd
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-3a.d
@@ -0,0 +1,52 @@
+#source: ibt-plt-3.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+190 <.plt>:
+ +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\)
+ +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\)
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\)
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 00 00 00 00 push \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmp 190 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 08 00 00 00 push \$0x8
+ +[a-f0-9]+: e9 d2 ff ff ff jmp 190 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1c0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+0+1d0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+Disassembly of section .text:
+
+0+1e0 <foo>:
+ +[a-f0-9]+: 53 push %ebx
+ +[a-f0-9]+: e8 18 00 00 00 call 1fe <__x86.get_pc_thunk.bx>
+ +[a-f0-9]+: 81 c3 06 11 00 00 add \$0x1106,%ebx
+ +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
+ +[a-f0-9]+: e8 dc ff ff ff call 1d0 <bar2@plt>
+ +[a-f0-9]+: e8 c7 ff ff ff call 1c0 <bar1@plt>
+ +[a-f0-9]+: 83 c4 08 add \$0x8,%esp
+ +[a-f0-9]+: 5b pop %ebx
+ +[a-f0-9]+: c3 ret
+
+0+1fe <__x86.get_pc_thunk.bx>:
+ +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-i386/ibt-plt-3b.d b/ld/testsuite/ld-i386/ibt-plt-3b.d
new file mode 100644
index 0000000..d9b5be2
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-3b.d
@@ -0,0 +1,5 @@
+#source: ibt-plt-3.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibtplt
+#readelf: -n
+
diff --git a/ld/testsuite/ld-i386/ibt-plt-3c.d b/ld/testsuite/ld-i386/ibt-plt-3c.d
new file mode 100644
index 0000000..c2ce3fd
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-3c.d
@@ -0,0 +1,52 @@
+#source: ibt-plt-3.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+190 <.plt>:
+ +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\)
+ +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\)
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\)
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 00 00 00 00 push \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmp 190 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: 68 08 00 00 00 push \$0x8
+ +[a-f0-9]+: e9 d2 ff ff ff jmp 190 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1c0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+0+1d0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fb endbr32
+ +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\)
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\)
+
+Disassembly of section .text:
+
+0+1e0 <foo>:
+ +[a-f0-9]+: 53 push %ebx
+ +[a-f0-9]+: e8 18 00 00 00 call 1fe <__x86.get_pc_thunk.bx>
+ +[a-f0-9]+: 81 c3 06 11 00 00 add \$0x1106,%ebx
+ +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp
+ +[a-f0-9]+: e8 dc ff ff ff call 1d0 <bar2@plt>
+ +[a-f0-9]+: e8 c7 ff ff ff call 1c0 <bar1@plt>
+ +[a-f0-9]+: 83 c4 08 add \$0x8,%esp
+ +[a-f0-9]+: 5b pop %ebx
+ +[a-f0-9]+: c3 ret
+
+0+1fe <__x86.get_pc_thunk.bx>:
+ +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx
+ +[a-f0-9]+: c3 ret
+#pass
diff --git a/ld/testsuite/ld-i386/ibt-plt-3d.d b/ld/testsuite/ld-i386/ibt-plt-3d.d
new file mode 100644
index 0000000..3cf159a
--- /dev/null
+++ b/ld/testsuite/ld-i386/ibt-plt-3d.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-3.s
+#as: --32
+#ld: -shared -m elf_i386 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-i386/plt-main-ibt.dd b/ld/testsuite/ld-i386/plt-main-ibt.dd
new file mode 100644
index 0000000..18240a2
--- /dev/null
+++ b/ld/testsuite/ld-i386/plt-main-ibt.dd
@@ -0,0 +1,7 @@
+#...
+Disassembly of section .plt.got:
+
+[a-f0-9]+ <[_a-z]+@plt>:
+[ ]*[a-f0-9]+: f3 0f 1e fb endbr32
+[ ]*[a-f0-9]+: ff 25 .. .. .. .. jmp +\*0x[a-f0-9]+
+#pass
diff --git a/ld/testsuite/ld-i386/plt-pie-ibt.dd b/ld/testsuite/ld-i386/plt-pie-ibt.dd
new file mode 100644
index 0000000..2dc016c
--- /dev/null
+++ b/ld/testsuite/ld-i386/plt-pie-ibt.dd
@@ -0,0 +1,7 @@
+#...
+Disassembly of section .plt.got:
+
+[a-f0-9]+ <[_a-z]+@plt>:
+[ ]*[a-f0-9]+: f3 0f 1e fb endbr32
+[ ]*[a-f0-9]+: ff a3 .. .. .. .. jmp +\*\-0x[a-f0-9]+\(%ebx\)
+#pass
diff --git a/ld/testsuite/ld-i386/property-x86-empty.s b/ld/testsuite/ld-i386/property-x86-empty.s
new file mode 100644
index 0000000..6a6b517
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-empty.s
@@ -0,0 +1,27 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x0
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-i386/property-x86-ibt.s b/ld/testsuite/ld-i386/property-x86-ibt.s
new file mode 100644
index 0000000..84ee964
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt.s
@@ -0,0 +1,27 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x1
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-i386/property-x86-ibt1a.d b/ld/testsuite/ld-i386/property-x86-ibt1a.d
new file mode 100644
index 0000000..43b272f
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt1a.d
@@ -0,0 +1,6 @@
+#source: property-x86-empty.s
+#source: property-x86-ibt.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
diff --git a/ld/testsuite/ld-i386/property-x86-ibt1b.d b/ld/testsuite/ld-i386/property-x86-ibt1b.d
new file mode 100644
index 0000000..83bf411
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt1b.d
@@ -0,0 +1,6 @@
+#source: property-x86-ibt.s
+#source: property-x86-empty.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
diff --git a/ld/testsuite/ld-i386/property-x86-ibt2.d b/ld/testsuite/ld-i386/property-x86-ibt2.d
new file mode 100644
index 0000000..fbdf4c1
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt2.d
@@ -0,0 +1,9 @@
+#source: property-x86-ibt.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-i386/property-x86-ibt3a.d b/ld/testsuite/ld-i386/property-x86-ibt3a.d
new file mode 100644
index 0000000..4bb35b0
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt3a.d
@@ -0,0 +1,11 @@
+#source: property-x86-3.s
+#source: property-x86-ibt.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: i486, 586, SSE2, SSE3
+ x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-ibt3b.d b/ld/testsuite/ld-i386/property-x86-ibt3b.d
new file mode 100644
index 0000000..418d58a
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt3b.d
@@ -0,0 +1,11 @@
+#source: property-x86-ibt.s
+#source: property-x86-3.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: i486, 586, SSE2, SSE3
+ x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-ibt4.d b/ld/testsuite/ld-i386/property-x86-ibt4.d
new file mode 100644
index 0000000..db14fb9
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt4.d
@@ -0,0 +1,9 @@
+#source: property-x86-empty.s
+#as: --32
+#ld: -r -melf_i386 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-i386/property-x86-ibt5.d b/ld/testsuite/ld-i386/property-x86-ibt5.d
new file mode 100644
index 0000000..652f660
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-ibt5.d
@@ -0,0 +1,9 @@
+#source: start.s
+#as: --32
+#ld: -r -melf_i386 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d
new file mode 100644
index 0000000..6147ab4
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-1.s
+#as: --x32
+#ld: -shared -m elf32_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1c0 <.plt>:
+ +[a-f0-9]+: ff 35 6a 01 20 00 pushq 0x20016a\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: ff 25 6c 01 20 00 jmpq \*0x20016c\(%rip\) # 200338 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1f0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 46 01 20 00 jmpq \*0x200146\(%rip\) # 200340 <bar1>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+0+200 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200348 <bar2>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+210 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 200 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-1.d b/ld/testsuite/ld-x86-64/ibt-plt-1.d
new file mode 100644
index 0000000..dbec3ed
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-1.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-1.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+290 <.plt>:
+ +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+
+Disassembly of section .plt.sec:
+
+0+2c0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 <bar1>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+0+2d0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 <bar2>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+2e0 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-1.s b/ld/testsuite/ld-x86-64/ibt-plt-1.s
new file mode 100644
index 0000000..2ddf3bb
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-1.s
@@ -0,0 +1,45 @@
+ .text
+ .p2align 4,,15
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .cfi_startproc
+ subq $8, %rsp
+ .cfi_def_cfa_offset 16
+ call bar2@PLT
+ addq $8, %rsp
+ .cfi_def_cfa_offset 8
+ jmp bar1@PLT
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .section .note.GNU-stack,"",@progbits
+
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x1
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2.s b/ld/testsuite/ld-x86-64/ibt-plt-2.s
new file mode 100644
index 0000000..e1ea540
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2.s
@@ -0,0 +1,45 @@
+ .text
+ .p2align 4,,15
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .cfi_startproc
+ subq $8, %rsp
+ .cfi_def_cfa_offset 16
+ call bar2@PLT
+ addq $8, %rsp
+ .cfi_def_cfa_offset 8
+ jmp bar1@PLT
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .section .note.GNU-stack,"",@progbits
+
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x0
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d
new file mode 100644
index 0000000..df9dc8e
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-2.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1c0 <.plt>:
+ +[a-f0-9]+: ff 35 6a 01 20 00 pushq 0x20016a\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: ff 25 6c 01 20 00 jmpq \*0x20016c\(%rip\) # 200338 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1f0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 46 01 20 00 jmpq \*0x200146\(%rip\) # 200340 <bar1>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+0+200 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200348 <bar2>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+210 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 200 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2a.d b/ld/testsuite/ld-x86-64/ibt-plt-2a.d
new file mode 100644
index 0000000..0e4f424
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2a.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-2.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+290 <.plt>:
+ +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+
+Disassembly of section .plt.sec:
+
+0+2c0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 <bar1>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+0+2d0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 <bar2>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+2e0 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d
new file mode 100644
index 0000000..e9e5638
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-2.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibtplt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature:
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2b.d b/ld/testsuite/ld-x86-64/ibt-plt-2b.d
new file mode 100644
index 0000000..604db82
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2b.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-2.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibtplt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature:
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d
new file mode 100644
index 0000000..e908804
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-2.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1c0 <.plt>:
+ +[a-f0-9]+: ff 35 6a 01 20 00 pushq 0x20016a\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: ff 25 6c 01 20 00 jmpq \*0x20016c\(%rip\) # 200338 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1f0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 46 01 20 00 jmpq \*0x200146\(%rip\) # 200340 <bar1>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+0+200 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200348 <bar2>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+210 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 200 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2c.d b/ld/testsuite/ld-x86-64/ibt-plt-2c.d
new file mode 100644
index 0000000..0ef1131
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2c.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-2.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+290 <.plt>:
+ +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+
+Disassembly of section .plt.sec:
+
+0+2c0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 <bar1>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+0+2d0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 <bar2>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+2e0 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d
new file mode 100644
index 0000000..b3be904
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-2.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-2d.d b/ld/testsuite/ld-x86-64/ibt-plt-2d.d
new file mode 100644
index 0000000..7226b69
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-2d.d
@@ -0,0 +1,9 @@
+#source: ibt-plt-2.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3.s b/ld/testsuite/ld-x86-64/ibt-plt-3.s
new file mode 100644
index 0000000..299b023
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3.s
@@ -0,0 +1,17 @@
+ .text
+ .p2align 4,,15
+ .globl foo
+ .type foo, @function
+foo:
+.LFB0:
+ .cfi_startproc
+ subq $8, %rsp
+ .cfi_def_cfa_offset 16
+ call bar2@PLT
+ addq $8, %rsp
+ .cfi_def_cfa_offset 8
+ jmp bar1@PLT
+ .cfi_endproc
+.LFE0:
+ .size foo, .-foo
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3a-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-3a-x32.d
new file mode 100644
index 0000000..0f7835d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3a-x32.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-3.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1a0 <.plt>:
+ +[a-f0-9]+: ff 35 52 01 20 00 pushq 0x200152\(%rip\) # 2002f8 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: ff 25 54 01 20 00 jmpq \*0x200154\(%rip\) # 200300 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmpq 1a0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: e9 d2 ff ff ff jmpq 1a0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1d0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 2e 01 20 00 jmpq \*0x20012e\(%rip\) # 200308 <bar1>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+0+1e0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 26 01 20 00 jmpq \*0x200126\(%rip\) # 200310 <bar2>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+1f0 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 1e0 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 1d0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3a.d b/ld/testsuite/ld-x86-64/ibt-plt-3a.d
new file mode 100644
index 0000000..b8f2ebc
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3a.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-3.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibtplt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+250 <.plt>:
+ +[a-f0-9]+: ff 35 ca 01 20 00 pushq 0x2001ca\(%rip\) # 200420 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: f2 ff 25 cb 01 20 00 bnd jmpq \*0x2001cb\(%rip\) # 200428 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 250 <.plt>
+ +[a-f0-9]+: 90 nop
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 250 <.plt>
+ +[a-f0-9]+: 90 nop
+
+Disassembly of section .plt.sec:
+
+0+280 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 a5 01 20 00 bnd jmpq \*0x2001a5\(%rip\) # 200430 <bar1>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+0+290 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 9d 01 20 00 bnd jmpq \*0x20019d\(%rip\) # 200438 <bar2>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+2a0 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 290 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 280 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3b-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-3b-x32.d
new file mode 100644
index 0000000..fb0a834
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3b-x32.d
@@ -0,0 +1,5 @@
+#source: ibt-plt-3.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibtplt
+#readelf: -n
+
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3b.d b/ld/testsuite/ld-x86-64/ibt-plt-3b.d
new file mode 100644
index 0000000..5a3843b
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3b.d
@@ -0,0 +1,5 @@
+#source: ibt-plt-3.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibtplt
+#readelf: -n
+
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d
new file mode 100644
index 0000000..234944d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-3.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+1c0 <.plt>:
+ +[a-f0-9]+: ff 35 6a 01 20 00 pushq 0x20016a\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: ff 25 6c 01 20 00 jmpq \*0x20016c\(%rip\) # 200338 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt>
+ +[a-f0-9]+: 66 90 xchg %ax,%ax
+
+Disassembly of section .plt.sec:
+
+0+1f0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 46 01 20 00 jmpq \*0x200146\(%rip\) # 200340 <bar1>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+0+200 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200348 <bar2>
+ +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+210 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 200 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3c.d b/ld/testsuite/ld-x86-64/ibt-plt-3c.d
new file mode 100644
index 0000000..b299f22
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3c.d
@@ -0,0 +1,43 @@
+#source: ibt-plt-3.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibt
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .plt:
+
+0+290 <.plt>:
+ +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ +[a-f0-9]+: 0f 1f 00 nopl \(%rax\)
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
+ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1
+ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt>
+ +[a-f0-9]+: 90 nop
+
+Disassembly of section .plt.sec:
+
+0+2c0 <bar1@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 <bar1>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+0+2d0 <bar2@plt>:
+ +[a-f0-9]+: f3 0f 1e fa endbr64
+ +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 <bar2>
+ +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\)
+
+Disassembly of section .text:
+
+0+2e0 <foo>:
+ +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp
+ +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 <bar2@plt>
+ +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp
+ +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 <bar1@plt>
+#pass
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d b/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d
new file mode 100644
index 0000000..447e811
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d
@@ -0,0 +1,10 @@
+#source: ibt-plt-3.s
+#as: --x32
+#ld: -shared -m elf32_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
+
diff --git a/ld/testsuite/ld-x86-64/ibt-plt-3d.d b/ld/testsuite/ld-x86-64/ibt-plt-3d.d
new file mode 100644
index 0000000..342626a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/ibt-plt-3d.d
@@ -0,0 +1,10 @@
+#source: ibt-plt-3.s
+#as: --64 -defsym __64_bit__=1
+#ld: -shared -m elf_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
+
diff --git a/ld/testsuite/ld-x86-64/plt-main-ibt-now.rd b/ld/testsuite/ld-x86-64/plt-main-ibt-now.rd
new file mode 100644
index 0000000..2478c1f
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/plt-main-ibt-now.rd
@@ -0,0 +1,3 @@
+#...
+ +\[[ 0-9]+\] \.plt\.sec +.*
+#pass
diff --git a/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd b/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd
new file mode 100644
index 0000000..7b5e174
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd
@@ -0,0 +1,7 @@
+#...
+Disassembly of section .plt.got:
+
+[a-f0-9]+ <[_a-z]+@plt>:
+[ ]*[a-f0-9]+: f3 0f 1e fa endbr64
+[ ]*[a-f0-9]+: ff 25 .. .. 20 00 jmpq +\*0x20....\(%rip\) # ...... <[_a-z]+>
+#pass
diff --git a/ld/testsuite/ld-x86-64/plt-main-ibt.dd b/ld/testsuite/ld-x86-64/plt-main-ibt.dd
new file mode 100644
index 0000000..725f427
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/plt-main-ibt.dd
@@ -0,0 +1,7 @@
+#...
+Disassembly of section .plt.got:
+
+[a-f0-9]+ <[_a-z]+@plt>:
+[ ]*[a-f0-9]+: f3 0f 1e fa endbr64
+[ ]*[a-f0-9]+: f2 ff 25 .. .. 20 00 bnd jmpq \*0x20....\(%rip\) # ...... <[_a-z]+>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr21481b.S b/ld/testsuite/ld-x86-64/pr21481b.S
index 744d86a..583ec77 100644
--- a/ld/testsuite/ld-x86-64/pr21481b.S
+++ b/ld/testsuite/ld-x86-64/pr21481b.S
@@ -10,7 +10,11 @@ check:
cmpl $func1, %eax
jne .L3
movq func1_p@GOTPCREL(%rip), %rdx
+#ifdef __LP64__
cmpq %rax, (%rdx)
+#else
+ cmpl %eax, (%rdx)
+#endif
jne .L3
call *func1@GOTPCREL(%rip)
cmpl $1, %eax
diff --git a/ld/testsuite/ld-x86-64/property-x86-empty.s b/ld/testsuite/ld-x86-64/property-x86-empty.s
new file mode 100644
index 0000000..6a6b517
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-empty.s
@@ -0,0 +1,27 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x0
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt.s b/ld/testsuite/ld-x86-64/property-x86-ibt.s
new file mode 100644
index 0000000..84ee964
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt.s
@@ -0,0 +1,27 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+2: .long 0xc0000002 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x1
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt1a-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt1a-x32.d
new file mode 100644
index 0000000..b215d79d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt1a-x32.d
@@ -0,0 +1,6 @@
+#source: property-x86-empty.s
+#source: property-x86-ibt.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt1a.d b/ld/testsuite/ld-x86-64/property-x86-ibt1a.d
new file mode 100644
index 0000000..50f220c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt1a.d
@@ -0,0 +1,6 @@
+#source: property-x86-empty.s
+#source: property-x86-ibt.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt1b-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt1b-x32.d
new file mode 100644
index 0000000..7361cea
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt1b-x32.d
@@ -0,0 +1,6 @@
+#source: property-x86-ibt.s
+#source: property-x86-empty.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt1b.d b/ld/testsuite/ld-x86-64/property-x86-ibt1b.d
new file mode 100644
index 0000000..7f47db7
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt1b.d
@@ -0,0 +1,6 @@
+#source: property-x86-ibt.s
+#source: property-x86-empty.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt2-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt2-x32.d
new file mode 100644
index 0000000..a0fb614
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt2-x32.d
@@ -0,0 +1,9 @@
+#source: property-x86-ibt.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt2.d b/ld/testsuite/ld-x86-64/property-x86-ibt2.d
new file mode 100644
index 0000000..be3df9c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt2.d
@@ -0,0 +1,9 @@
+#source: property-x86-ibt.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
new file mode 100644
index 0000000..011426f
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
@@ -0,0 +1,11 @@
+#source: property-x86-3.s
+#source: property-x86-ibt.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
new file mode 100644
index 0000000..1b4229a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
@@ -0,0 +1,11 @@
+#source: property-x86-3.s
+#source: property-x86-ibt.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
new file mode 100644
index 0000000..290ed6a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
@@ -0,0 +1,11 @@
+#source: property-x86-ibt.s
+#source: property-x86-3.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
new file mode 100644
index 0000000..1142e03
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
@@ -0,0 +1,11 @@
+#source: property-x86-ibt.s
+#source: property-x86-3.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt4-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt4-x32.d
new file mode 100644
index 0000000..b96abbc
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt4-x32.d
@@ -0,0 +1,9 @@
+#source: property-x86-empty.s
+#as: --x32
+#ld: -r -m elf32_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt4.d b/ld/testsuite/ld-x86-64/property-x86-ibt4.d
new file mode 100644
index 0000000..3f61a76
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt4.d
@@ -0,0 +1,9 @@
+#source: property-x86-empty.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt5-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt5-x32.d
new file mode 100644
index 0000000..5245d0b
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt5-x32.d
@@ -0,0 +1,9 @@
+#source: start.s
+#as: --x32
+#ld: -r -m elf32_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt5.d b/ld/testsuite/ld-x86-64/property-x86-ibt5.d
new file mode 100644
index 0000000..ab74033
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt5.d
@@ -0,0 +1,9 @@
+#source: start.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64 -z ibt
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: IBT
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 21f408d..6cde22f 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -335,6 +335,20 @@ run_dump_test "property-x86-4b"
run_dump_test "property-x86-3-x32"
run_dump_test "property-x86-4a-x32"
run_dump_test "property-x86-4b-x32"
+run_dump_test "property-x86-ibt1a"
+run_dump_test "property-x86-ibt1b"
+run_dump_test "property-x86-ibt1a-x32"
+run_dump_test "property-x86-ibt1b-x32"
+run_dump_test "property-x86-ibt2"
+run_dump_test "property-x86-ibt2-x32"
+run_dump_test "property-x86-ibt3a"
+run_dump_test "property-x86-ibt3b"
+run_dump_test "property-x86-ibt3a-x32"
+run_dump_test "property-x86-ibt3b-x32"
+run_dump_test "property-x86-ibt4"
+run_dump_test "property-x86-ibt4-x32"
+run_dump_test "property-x86-ibt5"
+run_dump_test "property-x86-ibt5-x32"
if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
return
@@ -1350,6 +1364,156 @@ if { [isnative] && [which $CC] != 0 } {
}
}
+ if { [istarget "x86_64-*-linux*"] } {
+ if { [istarget "x86_64-*-linux*-gnux32"] } {
+ set pltdump {{objdump {-drw} plt-main-ibt-x32.dd}}
+ set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt-x32.dd}}
+ } else {
+ set pltdump {{objdump {-drw} plt-main-ibt.dd}}
+ set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt.dd}}
+ }
+ run_cc_link_tests [list \
+ [list \
+ "Build plt-main with -z ibtplt" \
+ "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt" \
+ "" \
+ { plt-main5.c } \
+ $pltdump \
+ "plt-main-ibt" \
+ ] \
+ [list \
+ "Build plt-main with PIE and -z ibtplt" \
+ "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -pie" \
+ "-fPIC" \
+ { plt-main5.c } \
+ $pltdump \
+ "plt-main-pie-ibt" \
+ ] \
+ [list \
+ "Build plt-main with -z ibtplt -z now" \
+ "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -z now" \
+ "" \
+ { plt-main5.c } \
+ $pltsecdump \
+ "plt-main-ibt-now" \
+ ] \
+ [list \
+ "Build plt-main with PIE and -z ibtplt -z now" \
+ "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -z now -pie" \
+ "-fPIC" \
+ { plt-main5.c } \
+ $pltsecdump \
+ "plt-main-pie-ibt-now" \
+ ] \
+ [list \
+ "Build libibtplt-lib.so with -z ibtplt" \
+ "-shared -z ibtplt" \
+ "-fPIC" \
+ { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
+ $pltdump \
+ "libibtplt-lib.so" \
+ ] \
+ [list \
+ "Build libibtplt--now-lib.so with -z ibtplt -z now" \
+ "-shared -z ibtplt -z now" \
+ "-fPIC" \
+ { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
+ $pltdump \
+ "libibtplt-now-lib.so" \
+ ] \
+ ]
+
+ run_ld_link_exec_tests [list \
+ [list \
+ "Run plt-main with -z ibtplt" \
+ "-Wl,--no-as-needed,-z,ibtplt tmpdir/plt-main1.o \
+ tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+ "" \
+ { plt-main5.c } \
+ "plt-main-ibt" \
+ "plt-main.out" \
+ ] \
+ [list \
+ "Run plt-main with PIE and -z ibtplt" \
+ "-Wl,--no-as-needed,-z,ibtplt -pie tmpdir/plt-main1.o \
+ tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+ "" \
+ { plt-main5.c } \
+ "plt-main-pie-ibt" \
+ "plt-main.out" \
+ "-fPIC" \
+ ] \
+ [list \
+ "Run plt-main with -z ibtplt -z now" \
+ "-Wl,--no-as-needed,-z,ibtplt,-z,now tmpdir/plt-main1.o \
+ tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+ "" \
+ { plt-main5.c } \
+ "plt-main-ibt-now" \
+ "plt-main.out" \
+ ] \
+ [list \
+ "Run plt-main with PIE and -z ibtplt -z now" \
+ "-Wl,--no-as-needed,-z,ibtplt,-z,now -pie tmpdir/plt-main1.o \
+ tmpdir/plt-main2.o tmpdir/plt-main3.o \
+ tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+ "" \
+ { plt-main5.c } \
+ "plt-main-pie-ibt-now" \
+ "plt-main.out" \
+ "-fPIC" \
+ ] \
+ [list \
+ "Run plt-main with libibtplt-lib.so -z ibtplt" \
+ "-Wl,--no-as-needed,-z,ibtplt tmpdir/libibtplt-lib.so \
+ tmpdir/libplt-lib.so" \
+ "" \
+ { plt-main5.c } \
+ "plt-main-ibt-lib" \
+ "plt-main.out" \
+ ] \
+ [list \
+ "Run plt-main with libibtplt-lib.so -z ibtplt -z now" \
+ "-Wl,--no-as-needed,-z,ibtplt,-z,now \
+ tmpdir/libibtplt-now-lib.so tmpdir/libplt-lib.so" \
+ "" \
+ { plt-main5.c } \
+ "plt-main-ibt-now-lib" \
+ "plt-main.out" \
+ ] \
+ ]
+
+ if { [check_ifunc_attribute_available] } {
+ run_ld_link_exec_tests [list \
+ [list \
+ "Run pr21481a" \
+ "$NOPIE_LDFLAGS -Wl,-z,ibtplt" \
+ "" \
+ { pr21481a.c pr21481b.S } \
+ "pr21481a" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ [list \
+ "Run pr21481b" \
+ "$NOPIE_LDFLAGS -Wl,-z,ibtplt,-z,now" \
+ "" \
+ { pr21481a.c pr21481b.S } \
+ "pr21481b" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ ]
+ }
+ }
+
undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
undefined_weak "-fPIE" ""
undefined_weak "-fPIE" "-pie"
@@ -1405,3 +1569,21 @@ run_dump_test "pr20830b-now"
run_dump_test "pr21038a-now"
run_dump_test "pr21038b-now"
run_dump_test "pr21038c-now"
+run_dump_test "ibt-plt-1"
+run_dump_test "ibt-plt-1-x32"
+run_dump_test "ibt-plt-2a"
+run_dump_test "ibt-plt-2b"
+run_dump_test "ibt-plt-2c"
+run_dump_test "ibt-plt-2d"
+run_dump_test "ibt-plt-2a-x32"
+run_dump_test "ibt-plt-2b-x32"
+run_dump_test "ibt-plt-2c-x32"
+run_dump_test "ibt-plt-2d-x32"
+run_dump_test "ibt-plt-3a"
+run_dump_test "ibt-plt-3b"
+run_dump_test "ibt-plt-3c"
+run_dump_test "ibt-plt-3d"
+run_dump_test "ibt-plt-3a-x32"
+run_dump_test "ibt-plt-3b-x32"
+run_dump_test "ibt-plt-3c-x32"
+run_dump_test "ibt-plt-3d-x32"