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: PR22451, strip no longer works on older object files


On Mon, Nov 20, 2017 at 6:27 AM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Nov 20, 2017 at 05:50:04AM -0800, H.J. Lu wrote:
>> On Mon, Nov 20, 2017 at 5:40 AM, Alan Modra <amodra@gmail.com> wrote:
>> > Setting SHF_GROUP unconditionally on rel/rela sections associated with
>> > SHF_GROUP sections fails badly with objcopy/strip and ld -r if the
>> > input file SHT_GROUP section didn't specify the rel/rela sections.
>> > This patch rearranges where SHF_GROUP is set for rel/rela sections.
>> >
>> >         PR 22451
>> >         PR 22460
>> >         * elf.c (_bfd_elf_init_reloc_shdr): Delete "sec_hdr" parameter
>> >         and leave rel_hdr->sh_flags zero.  Update calls.
>> >         (bfd_elf_set_group_contents): Check input rel/rela SHF_GROUP
>> >         flag when !gas before adding rel/rela section to group.  Set
>> >         output rel/rela SHF_GROUP flags.
>> >
>>
>> Can we add an assembler command-line option to get  back the old
>> behavior?  It can be used to generate a testcase for this patch.   It
>> may be useful in other places.
>
> I don't see the need for a testcase.  Yes, we like to be backward
> compatible with older buggy object files, but it isn't something that
> we need to keep forever (which is what a testcase would imply).
> That's not to say backward compatibility in this case will be lost.
> My patch didn't add some hack that I or some future maintainer will
> want to remove:  It just moved where SHF_GROUP was set for rel/rela
> sections.

We need to be able to handle the older object files.   I checked
in this testcase.


-- 
H.J.
From d6251545e230b243abe60e334bb3f78c5e564fa1 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 21 Nov 2017 13:41:10 -0800
Subject: [PATCH] Add a test for PR binutils/22451

Check in the object file generated from the older assembler as a
compressed file.

	PR binutils/22451
	* testsuite/binutils-all/x86-64/objects.exp: New file.
	* testsuite/binutils-all/x86-64/pr22451.o.bz2: Likewise.
---
 binutils/ChangeLog                                 |   6 ++
 binutils/testsuite/binutils-all/x86-64/objects.exp |  62 +++++++++++++++++++++
 .../testsuite/binutils-all/x86-64/pr22451.o.bz2    | Bin 0 -> 297 bytes
 3 files changed, 68 insertions(+)
 create mode 100644 binutils/testsuite/binutils-all/x86-64/objects.exp
 create mode 100644 binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 126e696b8b..53d85072f0 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR binutils/22451
+	* testsuite/binutils-all/x86-64/objects.exp: New file.
+	* testsuite/binutils-all/x86-64/pr22451.o.bz2: Likewise.
+
 2017-11-21  Claudiu Zissulescu  <claziss@synopsys.com>
 
 	* testsuite/binutils-all/arc/objdump.exp: Update pattern matching
diff --git a/binutils/testsuite/binutils-all/x86-64/objects.exp b/binutils/testsuite/binutils-all/x86-64/objects.exp
new file mode 100644
index 0000000000..ba8e928bcb
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/objects.exp
@@ -0,0 +1,62 @@
+# Expect script for x86-64 object tests.
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+#
+# 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.
+
+if {!([istarget "x86_64-*-linux*"]
+      || [istarget "x86_64-*-nacl*"])
+    || [is_remote host]} {
+    return
+}
+
+global OBJCOPY
+global OBJCOPYFLAGS
+global READELF
+set tempfile tmpdir/x86-64-object-temp.o
+set copyfile tmpdir/x86-64-object-copy.o
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.o.bz2]]
+foreach t $test_list {
+    # We need to strip the ".bz2", but can leave the dirname.
+    set test $subdir/[file tail $t]
+    set testname [file rootname $test]
+    verbose $testname
+    if {[catch "system \"bzip2 -dc $t > $tempfile\""] != 0} {
+	untested "bzip2 -dc ($testname)"
+	continue
+    }
+    set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $tempfile $copyfile"]
+    if ![string equal "" $got] then {
+	fail "objcopy ($testname)"
+    } else {
+	set got [remote_exec host "$READELF -a $tempfile" "" "/dev/null" "${tempfile}.out"]
+	if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+	    fail "objcopy ($testname)"
+	    continue
+	}
+	set got [remote_exec host "$READELF -a $copyfile" "" "/dev/null" "${copyfile}.out"]
+	if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+	    fail "objcopy ($testname)"
+	    continue
+	}
+	set got [binutils_run cmp "${tempfile}.out ${copyfile}.out"]
+	if ![string equal "" $got] then {
+	    fail "objcopy ($testname)"
+	    continue
+	}
+	pass "objcopy ($testname)"
+    }
+}
diff --git a/binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2 b/binutils/testsuite/binutils-all/x86-64/pr22451.o.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..0ba17628303746deb188076611811b293c640c73
GIT binary patch
literal 297
zcmV+^0oMLPT4*^jL0KkKS<5k^JOBX`|CE3F=t?MsU;$4=NRYqh-(Y}1KmafR_6X(x
z34j2Y00000H8g28JsBo|&;S4c01r?|kqA#yA*Lab>NFZM4KxR+8eB>##8I9YD9A4(
zBrCGI#&*PldS;j;6y-rvxkoJ|A8UO1vF<eRWWPDESS*(e$cm*Z>9S%)4?{|qywH$u
z=Yw^rG@D5_*p_T?0BN@^z6!cY<>a2+{b|%+VTY?FlcAcdfH`zE2`U*&5eldx^gzba
zMuthHDj4M<n6?rj_>EtGg(P#{j4u|gy7{iFn%|bQg6ZaLHk~D{eV*qMxl!^#`n?O5
vm6U0$o#FpN#DAI^hcrkSY#S5spzyd6us}-i=LOocoA|quDZ+$?S&b3k<RF7h

literal 0
HcmV?d00001

-- 
2.14.3


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