x86: Add GNU_PROPERTY_X86_UINT32_VALID

The older linker treats .note.gnu.property section as a generic note
and just concatenates all .note.gnu.property sections from the input
to the output.  On CET-enabled OS, the output of the older linker is
marked as CET enabled, but in fact, it is not CET enabled and it crashes
on CET-enabled machines.

This patch defines GNU_PROPERTY_X86_UINT32_VALID.  Linker is updated to
set the GNU_PROPERTY_X86_UINT32_VALID bit in GNU property note for
non-relocatable output to differentiate outputs from the older linker.

bfd/

	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Mask out the
	GNU_PROPERTY_X86_UINT32_VALID bit.
	(_bfd_x86_elf_link_fixup_gnu_properties): Set the
	GNU_PROPERTY_X86_UINT32_VALID bit for non-relocatable output.

binutils/

	* readelf.c (print_gnu_property_note): Check the
	GNU_PROPERTY_X86_UINT32_VALID bit for invalid GNU property note.

include/

	* elf/common.h (GNU_PROPERTY_X86_UINT32_VALID): New.
This commit is contained in:
H.J. Lu
2018-08-24 04:37:45 -07:00
parent 772758ac42
commit aa7bca9b2e
6 changed files with 66 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2018-08-24 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (print_gnu_property_note): Check the
GNU_PROPERTY_X86_UINT32_VALID bit for invalid GNU property note.
2018-08-23 Alan Modra <amodra@gmail.com>
* readelf.c (get_ppc64_symbol_other): Return NULL if st_other

View File

@ -17067,30 +17067,56 @@ print_gnu_property_note (Filedata * filedata, Elf_Internal_Note * pnote)
|| filedata->file_header.e_machine == EM_IAMCU
|| filedata->file_header.e_machine == EM_386)
{
unsigned int bitmask;
if (datasz == 4)
{
bitmask = byte_get (ptr, 4);
if (filedata->file_header.e_type == ET_EXEC
|| filedata->file_header.e_type == ET_DYN)
{
if ((bitmask & GNU_PROPERTY_X86_UINT32_VALID))
bitmask &= ~GNU_PROPERTY_X86_UINT32_VALID;
else
printf ("Invalid ");
}
}
else
bitmask = 0;
switch (type)
{
case GNU_PROPERTY_X86_ISA_1_USED:
printf ("x86 ISA used: ");
if (datasz != 4)
printf (_("<corrupt length: %#x> "), datasz);
printf (_("x86 ISA used: <corrupt length: %#x> "),
datasz);
else
decode_x86_isa (byte_get (ptr, 4));
{
printf ("x86 ISA used: ");
decode_x86_isa (bitmask);
}
goto next;
case GNU_PROPERTY_X86_ISA_1_NEEDED:
printf ("x86 ISA needed: ");
if (datasz != 4)
printf (_("<corrupt length: %#x> "), datasz);
printf (_("x86 ISA needed: <corrupt length: %#x> "),
datasz);
else
decode_x86_isa (byte_get (ptr, 4));
{
printf ("x86 ISA needed: ");
decode_x86_isa (bitmask);
}
goto next;
case GNU_PROPERTY_X86_FEATURE_1_AND:
printf ("x86 feature: ");
if (datasz != 4)
printf (_("<corrupt length: %#x> "), datasz);
printf (_("x86 feature: <corrupt length: %#x> "),
datasz);
else
decode_x86_feature (type, byte_get (ptr, 4));
{
printf ("x86 feature: ");
decode_x86_feature (type, bitmask);
}
goto next;
default: