Bug 26711 - -z ibt and -z shstk are mishandled
Summary: -z ibt and -z shstk are mishandled
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: 2.36
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-06 21:33 UTC by H.J. Lu
Modified: 2020-10-07 14:09 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A testcase (748 bytes, application/octet-stream)
2020-10-06 21:33 UTC, H.J. Lu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2020-10-06 21:33:58 UTC
Created attachment 12891 [details]
A testcase

[hjl@gnu-cfl-2 cet-1]$ make LD=./ld.master
as --64 -defsym __64_bit__=1 -o foo.o foo.s
as --64 -defsym __64_bit__=1 -o bar.o bar.s
as --64 -defsym __64_bit__=1 -o start.o start.s
./ld.master -o x foo.o bar.o start.o -z shstk
./ld.master -o y foo.o start.o -z shstk
./readelf -n x

Displaying notes found in: .note.gnu.property
  Owner                Data size 	Description
  GNU                  0x00000040	NT_GNU_PROPERTY_TYPE_0
      Properties: x86 feature: SHSTK
	<procesor-specific type 0xc0001002 data: 02 00 00 00 >
	x86 feature used: x86
	<procesor-specific type 0xc0010002 data: 00 00 00 00 >
./readelf -n y

Displaying notes found in: .note.gnu.property
  Owner                Data size 	Description
  GNU                  0x00000040	NT_GNU_PROPERTY_TYPE_0
      Properties: x86 feature: SHSTK
	<procesor-specific type 0xc0001002 data: 02 00 00 00 >
	x86 feature used: x86
	<procesor-specific type 0xc0010002 data: 00 00 00 00 >
[hjl@gnu-cfl-2 cet-1]$ 

There should be no

<procesor-specific type 0xc0001002 data: 02 00 00 00 >
Comment 1 Sourceware Commits 2020-10-06 22:48:32 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=574df58f5295ef2728526e6a73b5f429b05f2a8c

commit 574df58f5295ef2728526e6a73b5f429b05f2a8c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Oct 6 15:38:23 2020 -0700

    x86: Properly merge -z ibt and -z shstk
    
    Merge -z ibt and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND, not
    any GNU_PROPERTY_X86_UINT32_AND_XXX properties.
    
    bfd/
    
            PR ld/26711
            * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Merge -z ibt
            and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND.
    
    ld/
    
            PR ld/26711
            * testsuite/ld-i386/i386.exp: Run ld/26711 tests.
            * testsuite/ld-x86-64/x86-64.exp: Likewise.
            * testsuite/ld-i386/pr26711-1.d: Likewise.
            * testsuite/ld-i386/pr26711-2.d: Likewise.
            * testsuite/ld-i386/pr26711-3.d: Likewise.
            * testsuite/ld-x86-64/pr26711-1-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-1.d: Likewise.
            * testsuite/ld-x86-64/pr26711-2-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-2.d: Likewise.
            * testsuite/ld-x86-64/pr26711-3-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-3.d: Likewise.
            * testsuite/ld-x86-64/pr26711.s: Likewise.
Comment 2 Sourceware Commits 2020-10-07 13:51:37 UTC
The binutils-2_35-branch branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=691e341c06659f7161c5b08d092039efe6eae209

commit 691e341c06659f7161c5b08d092039efe6eae209
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Oct 6 15:38:23 2020 -0700

    x86: Properly merge -z ibt and -z shstk
    
    Merge -z ibt and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND, not
    any GNU_PROPERTY_X86_UINT32_AND_XXX properties.
    
    bfd/
    
            PR ld/26711
            * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Merge -z ibt
            and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND.
    
    ld/
    
            PR ld/26711
            * testsuite/ld-i386/i386.exp: Run ld/26711 tests.
            * testsuite/ld-x86-64/x86-64.exp: Likewise.
            * testsuite/ld-i386/pr26711-1.d: Likewise.
            * testsuite/ld-i386/pr26711-2.d: Likewise.
            * testsuite/ld-i386/pr26711-3.d: Likewise.
            * testsuite/ld-x86-64/pr26711-1-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-1.d: Likewise.
            * testsuite/ld-x86-64/pr26711-2-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-2.d: Likewise.
            * testsuite/ld-x86-64/pr26711-3-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-3.d: Likewise.
            * testsuite/ld-x86-64/pr26711.s: Likewise.
    
    (cherry picked from commit 574df58f5295ef2728526e6a73b5f429b05f2a8c)
Comment 3 Sourceware Commits 2020-10-07 13:57:35 UTC
The binutils-2_34-branch branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c1bd3f52c69d00f56f9cb71737396c2651e508d

commit 5c1bd3f52c69d00f56f9cb71737396c2651e508d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Oct 6 15:38:23 2020 -0700

    x86: Properly merge -z ibt and -z shstk
    
    Merge -z ibt and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND, not
    any GNU_PROPERTY_X86_UINT32_AND_XXX properties.
    
    bfd/
    
            PR ld/26711
            * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Merge -z ibt
            and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND.
    
    ld/
    
            PR ld/26711
            * testsuite/ld-i386/i386.exp: Run ld/26711 tests.
            * testsuite/ld-x86-64/x86-64.exp: Likewise.
            * testsuite/ld-i386/pr26711-1.d: Likewise.
            * testsuite/ld-i386/pr26711-2.d: Likewise.
            * testsuite/ld-i386/pr26711-3.d: Likewise.
            * testsuite/ld-x86-64/pr26711-1-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-1.d: Likewise.
            * testsuite/ld-x86-64/pr26711-2-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-2.d: Likewise.
            * testsuite/ld-x86-64/pr26711-3-x32.d: Likewise.
            * testsuite/ld-x86-64/pr26711-3.d: Likewise.
            * testsuite/ld-x86-64/pr26711.s: Likewise.
    
    (cherry picked from commit 574df58f5295ef2728526e6a73b5f429b05f2a8c)
Comment 4 H.J. Lu 2020-10-07 14:09:04 UTC
Fixed for 2.36 and 2.34/2.35 branches.