+2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_merge_gnu_properties): If info->shstk
+ is set, turn on GNU_PROPERTY_X86_FEATURE_1_SHSTK.
+ (elf_i386_link_setup_gnu_properties): If info->shstk is set,
+ turn on GNU_PROPERTY_X86_FEATURE_1_IBT.
+ * elf64-x86-64.c (elf_x86_64_merge_gnu_properties): If
+ info->shstk is set, turn on GNU_PROPERTY_X86_FEATURE_1_SHSTK.
+ (elf_x86_64_link_setup_gnu_properties): If info->shstk is set,
+ turn on GNU_PROPERTY_X86_FEATURE_1_IBT.
+
2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_lazy_ibt_plt0_entry): New.
features = 0;
if (info->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (info->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
number = aprop->u.number;
- /* Add GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
aprop->u.number = (number & bprop->u.number) | features;
updated = number != (unsigned int) aprop->u.number;
/* Remove the property if all feature bits are cleared. */
features = 0;
if (info->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (info->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
if (features)
{
- /* Add GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
if (aprop != NULL)
{
number = aprop->u.number;
features = 0;
if (info->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (info->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
if (features)
{
- /* Turn on GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Turn on GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
bfd *ebfd = NULL;
elf_property *prop;
prop = _bfd_elf_get_property (pbfd,
GNU_PROPERTY_X86_FEATURE_1_AND,
4);
- /* Add GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
prop->u.number |= features;
prop->pr_kind = property_number;
break;
features = 0;
if (info->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (info->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
number = aprop->u.number;
- /* Add GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
aprop->u.number = (number & bprop->u.number) | features;
updated = number != (unsigned int) aprop->u.number;
/* Remove the property if all feature bits are cleared. */
features = 0;
if (info->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (info->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
if (features)
{
- /* Add GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
if (aprop != NULL)
{
number = aprop->u.number;
features = 0;
if (info->ibt)
features = GNU_PROPERTY_X86_FEATURE_1_IBT;
+ if (info->shstk)
+ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
if (features)
{
- /* Turn on GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Turn on GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
bfd *ebfd = NULL;
elf_property *prop;
prop = _bfd_elf_get_property (pbfd,
GNU_PROPERTY_X86_FEATURE_1_AND,
4);
- /* Add GNU_PROPERTY_X86_FEATURE_1_IBT. */
+ /* Add GNU_PROPERTY_X86_FEATURE_1_IBT and
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */
prop->u.number |= features;
prop->pr_kind = property_number;
break;
+2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * readelf.c (decode_x86_feature): Decode
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK.
+ * testsuite/binutils-all/i386/shstk.d: New file.
+ * testsuite/binutils-all/i386/shstk.s: Likewise.
+ * testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
+ * testsuite/binutils-all/x86-64/shstk.d: Likewise.
+ * testsuite/binutils-all/x86-64/shstk.s: Likewise.
+
2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (decode_x86_feature): New.
abort ();
}
break;
+ case GNU_PROPERTY_X86_FEATURE_1_SHSTK:
+ switch (type)
+ {
+ case GNU_PROPERTY_X86_FEATURE_1_AND:
+ printf ("SHSTK");
+ break;
+ default:
+ /* This should never happen. */
+ abort ();
+ }
+ break;
default:
printf (_("<unknown: %x>"), bit);
break;
--- /dev/null
+#PROG: objcopy
+#as: --32
+#objcopy:
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+ .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 0x2
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
--- /dev/null
+#source: shstk.s
+#PROG: objcopy
+#as: --x32
+#objcopy:
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+#PROG: objcopy
+#as: --64 -defsym __64_bit__=1
+#objcopy:
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+ .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 0x2
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
+2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * bfdlink.h (bfd_link_info): Add shstk.
+ * elf/common.h (GNU_PROPERTY_X86_FEATURE_1_SHSTK): New.
+
2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
* bfdlink.h (bfd_link_info): Add ibtplt and ibt.
/* TRUE if GNU_PROPERTY_X86_FEATURE_1_IBT should be generated. */
unsigned int ibt: 1;
+ /* TRUE if GNU_PROPERTY_X86_FEATURE_1_SHSTK should be generated. */
+ unsigned int shstk: 1;
+
/* TRUE if generation of .interp/PT_INTERP should be suppressed. */
unsigned int nointerp: 1;
#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 17)
#define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0)
+#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1)
/* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */
#define GNU_ABI_TAG_LINUX 0
+2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * NEWS: Mention -z shstk and GNU_PROPERTY_X86_FEATURE_1_SHSTK.
+ * emulparams/cet.sh (PARSE_AND_LIST_OPTIONS_CET): Add "-z shstk".
+ (PARSE_AND_LIST_ARGS_CASE_Z_CET): Support "-z shstk".
+ * ld.texinfo: Document -z shstk.
+ * testsuite/ld-i386/i386.exp: Run SHSTK tests.
+ * testsuite/ld-x86-64/x86-64.exp: Likewise.
+ * testsuite/ld-i386/property-x86-shstk.s: New file.
+ * testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
+ * testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
+ * testsuite/ld-i386/property-x86-shstk2.d: Likewise.
+ * testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
+ * testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
+ * testsuite/ld-i386/property-x86-shstk4.d: Likewise.
+ * testsuite/ld-i386/property-x86-shstk5.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk.s: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
+ * testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
+
2017-06-22 H.J. Lu <hongjiu.lu@intel.com>
* Makefile.am (ELF_X86_DEPS): Add $(srcdir)/emulparams/cet.sh.
-*- text -*-
+* Support for -z shstk in the x86 ELF linker to generate
+ GNU_PROPERTY_X86_FEATURE_1_SHSTK in ELF GNU program properties.
+
+* Add support for GNU_PROPERTY_X86_FEATURE_1_SHSTK in ELF GNU program
+ properties in the x86 ELF linker.
+
* Add support for GNU_PROPERTY_X86_FEATURE_1_IBT in ELF GNU program
+ properties in the x86 ELF linker.
* Support for -z ibtplt in the x86 ELF linker to generate IBT-enabled
PLT.
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"));
+ -z ibt Generate GNU_PROPERTY_X86_FEATURE_1_IBT\n\
+ -z shstk Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK\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;
+ else if (strcmp (optarg, "shstk") == 0)
+ link_info.shstk = TRUE;
'
PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_CET"
to indicate compatibility with IBT. This also implies @option{ibtplt}.
Supported for Linux/i386 and Linux/x86_64.
+@item shstk
+Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in .note.gnu.property section
+to indicate compatibility with Intel Shadow Stack. Supported for
+Linux/i386 and Linux/x86_64.
+
@end table
Other keywords are ignored for Solaris compatibility.
run_dump_test "property-x86-ibt3b"
run_dump_test "property-x86-ibt4"
run_dump_test "property-x86-ibt5"
+run_dump_test "property-x86-shstk1a"
+run_dump_test "property-x86-shstk1b"
+run_dump_test "property-x86-shstk2"
+run_dump_test "property-x86-shstk3a"
+run_dump_test "property-x86-shstk3b"
+run_dump_test "property-x86-shstk4"
+run_dump_test "property-x86-shstk5"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
--- /dev/null
+ .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 0x2
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
--- /dev/null
+#source: property-x86-empty.s
+#source: property-x86-shstk.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
--- /dev/null
+#source: property-x86-shstk.s
+#source: property-x86-empty.s
+#as: --32
+#ld: -r -melf_i386
+#readelf: -n
+
--- /dev/null
+#source: property-x86-shstk.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: SHSTK
--- /dev/null
+#source: property-x86-3.s
+#source: property-x86-shstk.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
--- /dev/null
+#source: property-x86-shstk.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
--- /dev/null
+#source: property-x86-empty.s
+#as: --32
+#ld: -r -melf_i386 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+#source: start.s
+#as: --32
+#ld: -r -melf_i386 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+ .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 0x2
+4:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+5:
--- /dev/null
+#source: property-x86-empty.s
+#source: property-x86-shstk.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
--- /dev/null
+#source: property-x86-empty.s
+#source: property-x86-shstk.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
--- /dev/null
+#source: property-x86-shstk.s
+#source: property-x86-empty.s
+#as: --x32
+#ld: -r -m elf32_x86_64
+#readelf: -n
+
--- /dev/null
+#source: property-x86-shstk.s
+#source: property-x86-empty.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64
+#readelf: -n
+
--- /dev/null
+#source: property-x86-shstk.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: SHSTK
--- /dev/null
+#source: property-x86-shstk.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: SHSTK
--- /dev/null
+#source: property-x86-3.s
+#source: property-x86-shstk.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
--- /dev/null
+#source: property-x86-3.s
+#source: property-x86-shstk.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
--- /dev/null
+#source: property-x86-shstk.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
--- /dev/null
+#source: property-x86-shstk.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
--- /dev/null
+#source: property-x86-empty.s
+#as: --x32
+#ld: -r -m elf32_x86_64 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+#source: property-x86-empty.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+#source: start.s
+#as: --x32
+#ld: -r -m elf32_x86_64 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
--- /dev/null
+#source: start.s
+#as: --64 -defsym __64_bit__=1
+#ld: -r -melf_x86_64 -z shstk
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 feature: SHSTK
run_dump_test "property-x86-ibt4-x32"
run_dump_test "property-x86-ibt5"
run_dump_test "property-x86-ibt5-x32"
+run_dump_test "property-x86-shstk1a"
+run_dump_test "property-x86-shstk1b"
+run_dump_test "property-x86-shstk1a-x32"
+run_dump_test "property-x86-shstk1b-x32"
+run_dump_test "property-x86-shstk2"
+run_dump_test "property-x86-shstk2-x32"
+run_dump_test "property-x86-shstk3a"
+run_dump_test "property-x86-shstk3b"
+run_dump_test "property-x86-shstk3a-x32"
+run_dump_test "property-x86-shstk3b-x32"
+run_dump_test "property-x86-shstk4"
+run_dump_test "property-x86-shstk4-x32"
+run_dump_test "property-x86-shstk5"
+run_dump_test "property-x86-shstk5-x32"
if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
return