Bug 24721 - -Map generates corrupt .note.gnu.property section
Summary: -Map generates corrupt .note.gnu.property section
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.33
: P2 normal
Target Milestone: 2.33
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-21 22:29 UTC by H.J. Lu
Modified: 2019-08-02 15:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2019-06-21 22:29:51 UTC
[hjl@gnu-cfl-1 ld]$ cat x.c
void
foo (void)
{
}
[hjl@gnu-cfl-1 ld]$ cat y.c
void
bar (void)
{
}
[hjl@gnu-cfl-1 ld]$ gcc -fPIC -c -fcf-protection x.c -Wa,-mx86-used-note=no
[hjl@gnu-cfl-1 ld]$ gcc -fPIC -c  y.c -Wa,-mx86-used-note=no
[hjl@gnu-cfl-1 ld]$ ld -shared -o foo.so -Map libfoo.map y.o x.o 
[hjl@gnu-cfl-1 ld]$ readelf -n foo.so

Displaying notes found in: .note.gnu.property
  Owner                 Data size	Description
  GNU                  0x00000000	NT_GNU_PROPERTY_TYPE_0
      Properties: <corrupt GNU_PROPERTY_TYPE, size = 0>
[hjl@gnu-cfl-1 ld]$
Comment 1 H.J. Lu 2019-06-24 18:04:22 UTC
The fix has been posted at

https://sourceware.org/ml/binutils/2019-06/msg00190.html
Comment 2 Sourceware Commits 2019-06-24 18:10:33 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=f93ab3a0b8039a1667a666f013cca50b03d67f9b

commit f93ab3a0b8039a1667a666f013cca50b03d67f9b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jun 24 11:08:40 2019 -0700

    elf: Remove the property after reporting its removal
    
    commit d2ef37ebd9f771d06edf1fdea37970f60b242b2d
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Fri Dec 7 08:30:30 2018 -0800
    
        elf: Report property change when merging properties
    
    failed to remove the property after reporting it has been removed.  This
    patch corrects it.
    
    bfd/
    
    	PR ld/24721
    	* elf-properties.c (elf_merge_gnu_property_list): Remove the
    	property after reporting property removal.
    
    ld/
    
    	PR ld/24721
    	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
    	* testsuite/ld-x86-64/pr24721-x32.d: New file.
    	* testsuite/ld-x86-64/pr24721.d: Likewise.
    	* testsuite/ld-x86-64/pr24721.map: Likewise.
    	* testsuite/ld-x86-64/pr24721a.s: Likewise.
    	* testsuite/ld-x86-64/pr24721b.s: Likewise.
Comment 3 Sourceware Commits 2019-06-24 18:15:26 UTC
The binutils-2_32-branch branch has been updated by H.J. Lu <hjl@sourceware.org>:

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

commit df010caac3b33b1d38b6d67024091854c3f77c77
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jun 24 11:08:40 2019 -0700

    elf: Remove the property after reporting its removal
    
    commit d2ef37ebd9f771d06edf1fdea37970f60b242b2d
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Fri Dec 7 08:30:30 2018 -0800
    
        elf: Report property change when merging properties
    
    failed to remove the property after reporting it has been removed.  This
    patch corrects it.
    
    bfd/
    
    	PR ld/24721
    	* elf-properties.c (elf_merge_gnu_property_list): Remove the
    	property after reporting property removal.
    
    ld/
    
    	PR ld/24721
    	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/24721 tests.
    	* testsuite/ld-x86-64/pr24721-x32.d: New file.
    	* testsuite/ld-x86-64/pr24721.d: Likewise.
    	* testsuite/ld-x86-64/pr24721.map: Likewise.
    	* testsuite/ld-x86-64/pr24721a.s: Likewise.
    	* testsuite/ld-x86-64/pr24721b.s: Likewise.
    
    (cherry picked from commit f93ab3a0b8039a1667a666f013cca50b03d67f9b)
Comment 4 H.J. Lu 2019-06-24 19:05:15 UTC
Fixed for 2.33 and 2.32 branch.