Bug 23515 - Empty GNU_PROPERTY_X86_FEATURE_1_AND isn't removed
Summary: Empty GNU_PROPERTY_X86_FEATURE_1_AND isn't removed
Status: REOPENED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: 2.32
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-12 00:23 UTC by H.J. Lu
Modified: 2018-11-26 20:25 UTC (History)
0 users

See Also:
Host:
Target: i386,x86-64
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2018-08-12 00:23:33 UTC
[hjl@gnu-tools-1 tmp]$ cat x.s
	.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:
[hjl@gnu-tools-1 tmp]$ gcc -c -m32 x.s
[hjl@gnu-tools-1 tmp]$ ld -shared -m elf_i386 x.o
[hjl@gnu-tools-1 tmp]$ readelf -n x.o

Displaying notes found in: .note.gnu.property
  Owner                 Data size	Description
  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
      Properties: x86 feature: 
[hjl@gnu-tools-1 tmp]$
Comment 1 cvs-commit@gcc.gnu.org 2018-08-17 10:56:03 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=bfb1e8c15a6b7d02cd0b9a124d01722a07ebf09a

commit bfb1e8c15a6b7d02cd0b9a124d01722a07ebf09a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Aug 17 03:54:05 2018 -0700

    x86: Remove empty X86_FEATURE_1_AND property
    
    There is no need to generate .note.gnu.property section with empty
    X86_FEATURE_1_AND property.  This patch adds fixup_gnu_properties
    to ELF linker backend so that x86 backend can remove it.
    
    bfd/
    
    	PR ld/23515
    	* elf-bfd.h (elf_backend_data): Add fixup_gnu_properties.
    	* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Call
    	backend fixup_gnu_properties if it isn't NULL.  Discard
    	.note.gnu.property section if all properties have been removed.
    	* elfxx-target.h (elf_backend_fixup_gnu_properties): New.
    	(elfNN_bed): Initialize fixup_gnu_properties.
    	* elfxx-x86.c (_bfd_x86_elf_link_fixup_gnu_properties): New
    	function.
    	* elfxx-x86.h (_bfd_x86_elf_link_fixup_gnu_properties): New
    	prototype.
    	(elf_backend_fixup_gnu_properties): New.
    
    ld/
    
    	PR ld/23515
    	* testsuite/ld-i386/ibt-plt-2a.d: Updated.
    	* testsuite/ld-i386/ibt-plt-2b.d: 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.
Comment 2 H.J. Lu 2018-11-09 13:56:06 UTC
Fixed for 2.32.
Comment 3 H.J. Lu 2018-11-26 20:25:21 UTC
We should keep empty X86_FEATURE_1_AND property.