This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: garbage collect debug sections when no alloc sections are kept


On Fri, May 19, 2017 at 1:19 AM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, May 18, 2017 at 07:26:33AM -0700, H.J. Lu wrote:
>> On Thu, May 18, 2017 at 6:36 AM, Alan Modra <amodra@gmail.com> wrote:
>> >         * elflink.c (_bfd_elf_gc_mark_extra_sections): Don't keep
>> >         debug and special sections when no alloc sections in an object
>> >         are kept.
>>
>> This doesn't work on .note.gnu.property section since it has SEC_ALLOC:
>
> True.  Let's omit notes too.  Committing.
>
> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
> index a85199a..a5ec80a 100644
> --- a/bfd/ChangeLog
> +++ b/bfd/ChangeLog
> @@ -1,3 +1,9 @@
> +2017-05-19  Alan Modra  <amodra@gmail.com>
> +
> +       * elflink.c (_bfd_elf_gc_mark_extra_sections): Don't keep
> +       debug and special sections when no non-note alloc sections in an
> +       object are kept.
> +
>  2017-05-18  Alan Modra  <amodra@gmail.com>
>

I am checking these tests.

-- 
H.J.
From 92f7d783c1038841beacaba28a5f5d740a5ccad6 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 19 May 2017 08:36:06 -0700
Subject: [PATCH] x86: Add GC testcases with property sections

Verify that debug section is removed by garbage collection when there
is a .note.gnu.property section.

	* testsuite/ld-i386/i386.exp: Run property-x86-4a and
	property-x86-4b.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/property-x86-4a.d: New file.
	* testsuite/ld-i386/property-x86-4a.s: Likewise.
	* testsuite/ld-i386/property-x86-4b.d: Likewise.
	* testsuite/ld-i386/property-x86-4b.s: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.s: Likewise.
	* testsuite/ld-x86-64/property-x86-4b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4b.s: Likewise.
---
 ld/ChangeLog                             | 14 ++++++++++++++
 ld/testsuite/ld-i386/i386.exp            |  2 ++
 ld/testsuite/ld-i386/property-x86-4a.d   | 10 ++++++++++
 ld/testsuite/ld-i386/property-x86-4a.s   |  5 +++++
 ld/testsuite/ld-i386/property-x86-4b.d   | 10 ++++++++++
 ld/testsuite/ld-i386/property-x86-4b.s   | 20 ++++++++++++++++++++
 ld/testsuite/ld-x86-64/property-x86-4a.d | 10 ++++++++++
 ld/testsuite/ld-x86-64/property-x86-4a.s |  5 +++++
 ld/testsuite/ld-x86-64/property-x86-4b.d | 10 ++++++++++
 ld/testsuite/ld-x86-64/property-x86-4b.s | 20 ++++++++++++++++++++
 ld/testsuite/ld-x86-64/x86-64.exp        |  2 ++
 11 files changed, 108 insertions(+)
 create mode 100644 ld/testsuite/ld-i386/property-x86-4a.d
 create mode 100644 ld/testsuite/ld-i386/property-x86-4a.s
 create mode 100644 ld/testsuite/ld-i386/property-x86-4b.d
 create mode 100644 ld/testsuite/ld-i386/property-x86-4b.s
 create mode 100644 ld/testsuite/ld-x86-64/property-x86-4a.d
 create mode 100644 ld/testsuite/ld-x86-64/property-x86-4a.s
 create mode 100644 ld/testsuite/ld-x86-64/property-x86-4b.d
 create mode 100644 ld/testsuite/ld-x86-64/property-x86-4b.s

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 838f3cb..f6063f5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,17 @@
+2017-05-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* testsuite/ld-i386/i386.exp: Run property-x86-4a and
+	property-x86-4b.
+	* testsuite/ld-x86-64/x86-64.exp: Likewise.
+	* testsuite/ld-i386/property-x86-4a.d: New file.
+	* testsuite/ld-i386/property-x86-4a.s: Likewise.
+	* testsuite/ld-i386/property-x86-4b.d: Likewise.
+	* testsuite/ld-i386/property-x86-4b.s: Likewise.
+	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
+	* testsuite/ld-x86-64/property-x86-4a.s: Likewise.
+	* testsuite/ld-x86-64/property-x86-4b.d: Likewise.
+	* testsuite/ld-x86-64/property-x86-4b.s: Likewise.
+
 2017-05-19  Georg-Johann Lay  <avr@gjlay.de>
 
 	PR ld/21472
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 0118f24..a92bd91 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -418,6 +418,8 @@ run_dump_test "pr20253-4c"
 run_dump_test "pr20253-5"
 run_dump_test "pr20515"
 run_dump_test "property-x86-3"
+run_dump_test "property-x86-4a"
+run_dump_test "property-x86-4b"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/property-x86-4a.d b/ld/testsuite/ld-i386/property-x86-4a.d
new file mode 100644
index 0000000..53c0b04
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-4a.d
@@ -0,0 +1,10 @@
+#source: property-x86-4a.s
+#source: property-x86-4b.s
+#as: --32
+#ld: -m elf_i386 --gc-sections --entry=main
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size	Description
+  GNU                  0x00000008	NT_GNU_PROPERTY_TYPE_0
+      Properties: no copy on protected 
diff --git a/ld/testsuite/ld-i386/property-x86-4a.s b/ld/testsuite/ld-i386/property-x86-4a.s
new file mode 100644
index 0000000..21846af
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-4a.s
@@ -0,0 +1,5 @@
+	.text
+	.globl  main
+	.type   main, @function
+main:
+	ret
diff --git a/ld/testsuite/ld-i386/property-x86-4b.d b/ld/testsuite/ld-i386/property-x86-4b.d
new file mode 100644
index 0000000..2184ac9
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-4b.d
@@ -0,0 +1,10 @@
+#source: property-x86-4a.s
+#source: property-x86-4b.s
+#as: --32
+#ld: -m elf_i386 --gc-sections --entry=main
+#readelf: -S --wide
+
+#failif
+#...
+ +\[ [0-9]\] .debug_info.*
+#...
diff --git a/ld/testsuite/ld-i386/property-x86-4b.s b/ld/testsuite/ld-i386/property-x86-4b.s
new file mode 100644
index 0000000..83aaf3e
--- /dev/null
+++ b/ld/testsuite/ld-i386/property-x86-4b.s
@@ -0,0 +1,20 @@
+	.section .debug_info,"",@progbits
+	.hidden t.c.4903c230
+	.globl t.c.4903c230
+t.c.4903c230:
+	.byte 0x28
+
+	.section ".note.gnu.property", "a"
+	.p2align 2
+	.long 1f - 0f		/* name length.  */
+	.long 3f - 2f		/* data length.  */
+	/* NT_GNU_PROPERTY_TYPE_0 */
+	.long 5			/* note type.  */
+0:	.asciz "GNU"		/* vendor name.  */
+1:	.p2align 2
+2:
+	/* GNU_PROPERTY_NO_COPY_ON_PROTECTED */
+	.long 2			/* pr_type.  */
+	.long 0			/* pr_datasz.  */
+	.p2align 2
+3:
diff --git a/ld/testsuite/ld-x86-64/property-x86-4a.d b/ld/testsuite/ld-x86-64/property-x86-4a.d
new file mode 100644
index 0000000..50be0b7
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-4a.d
@@ -0,0 +1,10 @@
+#source: property-x86-4a.s
+#source: property-x86-4b.s
+#as: --64
+#ld: -m elf_x86_64 --gc-sections --entry=main
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size	Description
+  GNU                  0x00000008	NT_GNU_PROPERTY_TYPE_0
+      Properties: no copy on protected 
diff --git a/ld/testsuite/ld-x86-64/property-x86-4a.s b/ld/testsuite/ld-x86-64/property-x86-4a.s
new file mode 100644
index 0000000..21846af
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-4a.s
@@ -0,0 +1,5 @@
+	.text
+	.globl  main
+	.type   main, @function
+main:
+	ret
diff --git a/ld/testsuite/ld-x86-64/property-x86-4b.d b/ld/testsuite/ld-x86-64/property-x86-4b.d
new file mode 100644
index 0000000..194dd6c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-4b.d
@@ -0,0 +1,10 @@
+#source: property-x86-4a.s
+#source: property-x86-4b.s
+#as: --64
+#ld: -m elf_x86_64 --gc-sections --entry=main
+#readelf: -S --wide
+
+#failif
+#...
+ +\[ [0-9]\] .debug_info.*
+#...
diff --git a/ld/testsuite/ld-x86-64/property-x86-4b.s b/ld/testsuite/ld-x86-64/property-x86-4b.s
new file mode 100644
index 0000000..3da1055
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/property-x86-4b.s
@@ -0,0 +1,20 @@
+	.section .debug_info,"",@progbits
+	.hidden t.c.4903c230
+	.globl t.c.4903c230
+t.c.4903c230:
+	.byte 0x28
+
+	.section ".note.gnu.property", "a"
+	.p2align 3
+	.long 1f - 0f		/* name length.  */
+	.long 3f - 2f		/* data length.  */
+	/* NT_GNU_PROPERTY_TYPE_0 */
+	.long 5			/* note type.  */
+0:	.asciz "GNU"		/* vendor name.  */
+1:	.p2align 3
+2:
+	/* GNU_PROPERTY_NO_COPY_ON_PROTECTED */
+	.long 2			/* pr_type.  */
+	.long 0			/* pr_datasz.  */
+	.p2align 3
+3:
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index e7f7326..ebb55f3 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -330,6 +330,8 @@ run_dump_test "pr19969"
 run_dump_test "pr20093-1"
 run_dump_test "pr20093-2"
 run_dump_test "property-x86-3"
+run_dump_test "property-x86-4a"
+run_dump_test "property-x86-4b"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return
-- 
2.9.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]