From 29700bfff45955f1323573a8270625d38e9bdbb6 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 13 Oct 2020 05:21:53 -0700
Subject: [PATCH] gold: Discard .note.gnu.property section

Discard .note.gnu.property section since it changes the expected section
order.

	PR gold/23503
	* testsuite/Makefile.am (justsyms_lib): Pass
	-T $(srcdir)/justsyms_lib.t to gold.
	* testsuite/Makefile.in: Regenerated.
	* testsuite/justsyms_lib.t: New file.
	* testsuite/script_test_10.t: Discard .note.gnu.property section.
---
 gold/ChangeLog                  |  9 +++++++++
 gold/testsuite/Makefile.am      |  2 +-
 gold/testsuite/Makefile.in      |  2 +-
 gold/testsuite/justsyms_lib.t   | 28 ++++++++++++++++++++++++++++
 gold/testsuite/script_test_10.t |  1 +
 5 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 gold/testsuite/justsyms_lib.t

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 41fe6e033e9..b9f6f9e43c5 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,12 @@
+2020-10-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR gold/23503
+	* testsuite/Makefile.am (justsyms_lib): Pass
+	-T $(srcdir)/justsyms_lib.t to gold.
+	* testsuite/Makefile.in: Regenerated.
+	* testsuite/justsyms_lib.t: New file.
+	* testsuite/script_test_10.t: Discard .note.gnu.property section.
+
 2020-10-13  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 026d1010b0b..c2692f96776 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -2044,7 +2044,7 @@ MOSTLYCLEANFILES += justsyms_lib
 justsyms_lib.o: justsyms_lib.c
 	$(COMPILE) -c -o $@ $<
 justsyms_lib: justsyms_lib.o gcctestdir/ld
-	gcctestdir/ld -o $@ -z norelro -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
+	gcctestdir/ld -o $@ -z norelro -T $(srcdir)/justsyms_lib.t -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
 
 check_PROGRAMS += binary_test
 MOSTLYCLEANFILES += binary.txt
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 35c442ee8b7..7f2e0dcd562 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -8834,7 +8834,7 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_lib.o: justsyms_lib.c
 @GCC_TRUE@@NATIVE_LINKER_TRUE@	$(COMPILE) -c -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_lib: justsyms_lib.o gcctestdir/ld
-@GCC_TRUE@@NATIVE_LINKER_TRUE@	gcctestdir/ld -o $@ -z norelro -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@	gcctestdir/ld -o $@ -z norelro -T $(srcdir)/justsyms_lib.t -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
 # Copy the file to the build directory to avoid worrying about the
 # full pathname in the generated symbols.
 @GCC_TRUE@@NATIVE_LINKER_TRUE@binary.txt: $(srcdir)/binary.in
diff --git a/gold/testsuite/justsyms_lib.t b/gold/testsuite/justsyms_lib.t
new file mode 100644
index 00000000000..632f7cde24d
--- /dev/null
+++ b/gold/testsuite/justsyms_lib.t
@@ -0,0 +1,28 @@
+/* justsyms_lib.t -- test --just-symbols for gold.
+
+   Copyright (C) 2018 Free Software Foundation, Inc.
+
+   This file is part of gold.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+SECTIONS
+{
+  .text : { *(.text) }
+  .data : { *(.data) }
+  .bss : { *(.bss) }
+  /DISCARD/ : { *(.note.gnu.property) }
+}
diff --git a/gold/testsuite/script_test_10.t b/gold/testsuite/script_test_10.t
index eff0b05f4b5..a9fc72ddc02 100644
--- a/gold/testsuite/script_test_10.t
+++ b/gold/testsuite/script_test_10.t
@@ -30,5 +30,6 @@ SECTIONS
   .sec3 : { *(.sec3) }
   .data : { *(.data) }
   .bss : { *(.bss) }
+  /DISCARD/ : { *(.note.gnu.property) }
 }