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: PR21167, relocation sections not included in groups


On 10/4/17, Alan Modra <amodra@gmail.com> wrote:
> This fixes a wart I've known about for years, but haven't done
> anything about because BFD treats relocation sections as an adjunct to
> the section they relocate.  SHF_GROUP on the section thus implicitly
> applies to its relocation section(s), but it is an error that the
> reloc sections aren't explicitly part of the group.
>
> Like many patches to gas, this wasn't as straightforward as it could
> be due to a number of backends, i386, cr16 and others, removing relocs
> in tc_get_reloc rather than marking them as "done" earlier in
> md_apply_reloc.  So it isn't possible for the group support to
> reliably detect the presence of relocs by looking at fixups earlier
> than write_relocs.  However the group support needs to create
> signature symbols, and that must be done before the symbol table is
> frozen, before write_relocs.  So split off the group sizing from
> elf_adjust_symtab and put it in elf_frob_file_after_relocs.
>
> The patch does cause a whole lot of regressions for nds32.
> nds32le-elf  +FAIL: copy removing group member
> nds32le-elf  +FAIL: strip with section group 2
> nds32le-elf  +FAIL: strip with section group 5
> nds32le-elf  +FAIL: strip with section group 7
> nds32le-elf  +FAIL: strip with section group 9
> nds32le-elf  +FAIL: group section
> nds32le-elf  +FAIL: group section with multiple sections of same name
> nds32le-elf  +FAIL: automatic section group b
> nds32le-elf  +FAIL: mbind sections
> nds32le-elf  +FAIL: ld-elf/group10
> nds32le-elf  +FAIL: ld-elf/group2
> nds32le-elf  +FAIL: ld-elf/group4
> nds32le-elf  +FAIL: ld-elf/group5
> nds32le-elf  +FAIL: ld-elf/group6
> nds32le-elf  +FAIL: ld-elf/group7
> nds32le-elf  +FAIL: ld-elf/group8a
> nds32le-elf  +FAIL: ld-elf/group8b
> nds32le-elf  +FAIL: ld-elf/group9a
> nds32le-elf  +FAIL: ld-elf/group9b
>
> They are all due to nds32 adding R_NDS32_RELAX_ENTRY relocs, so all
> the groups include extra sections.  I'm loathe to relax the pattern
> matching to allow random extra sections since some of the tests are
> testing that sections are properly removed from groups.  And xfailing
> them all for nds32 isn't ideal for the port.  If nds32 gas had a
> --no-relax option (matching the no_relax directive) then you could
> arrange to pass --no-relax for nds32 on these tests.  That's more than
> just a little bit of work so I'm punting this to the port maintainers.
>
> bfd/
> 	PR 21167
> 	* elf.c (_bfd_elf_setup_sections): Don't trim reloc sections from
> 	groups.
> 	(_bfd_elf_init_reloc_shdr): Pass sec_hdr, use it to copy SHF_GROUP
> 	flag from section.
> 	(elf_fake_sections): Adjust calls.  Exit immediately on failure.
> 	(bfd_elf_set_group_contents): Add associated reloc section indices
> 	to group contents
> gas/
> 	PR 21167
> 	* config/obj-elf.c (struct group_list): Delete elt_count.
> 	(groups): New static.
> 	(build_group_lists): Don't count elements.
> 	(elf_adjust_symtab): Use groups rather than auto list.  Set up
> 	pointer from group member to SHT_GROUP section.  Don't size
> 	SHT_GROUP section or clean up here..
> 	(elf_frob_file_after_relocs): ..do so here instead.
> 	* testsuite/gas/arc/jli-1.d,
> 	* testsuite/gas/elf/groupautob.d,
> 	* testsuite/gas/mips/compact-eh-eb-2.d,
> 	* testsuite/gas/mips/compact-eh-eb-5.d,
> 	* testsuite/gas/mips/compact-eh-el-2.d,
> 	* testsuite/gas/mips/compact-eh-el-5.d: Adjust.
> ld/
> 	PR 21167
> 	* testsuite/ld-elf/group9b.d: Adjust for relocs included in group.
>

I am checking in this patch to add an assembler test.

-- 
H.J.
From e9decd072f21693559175d49b6601543fe489d72 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 4 Oct 2017 18:01:47 -0700
Subject: [PATCH] Add an assembler test for PR gas/21167

	PR gas/21167
	* testsuite/gas/elf/elf.exp: Run group3.
	* testsuite/gas/elf/group3.d: New file.
	* testsuite/gas/elf/group3.s: Likewise.
---
 gas/ChangeLog                  | 7 +++++++
 gas/testsuite/gas/elf/elf.exp  | 1 +
 gas/testsuite/gas/elf/group3.d | 7 +++++++
 gas/testsuite/gas/elf/group3.s | 7 +++++++
 4 files changed, 22 insertions(+)
 create mode 100644 gas/testsuite/gas/elf/group3.d
 create mode 100644 gas/testsuite/gas/elf/group3.s

diff --git a/gas/ChangeLog b/gas/ChangeLog
index c112d86094..df8edc1dc4 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR gas/21167
+	* testsuite/gas/elf/elf.exp: Run group3.
+	* testsuite/gas/elf/group3.d: New file.
+	* testsuite/gas/elf/group3.s: Likewise.
+
 2017-10-05  Alan Modra  <amodra@gmail.com>
 
 	PR 21167
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 6737486296..8b9e1e8c26 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -122,6 +122,7 @@ if { [is_elf_format] } then {
     run_dump_test "group1a"
     run_dump_test "group1b"
     run_dump_test "group2"
+    run_dump_test "group3"
     case $target_triplet in {
 	{ hppa64*-*-hpux* } { }
 	{ riscv*-*-* } { }
diff --git a/gas/testsuite/gas/elf/group3.d b/gas/testsuite/gas/elf/group3.d
new file mode 100644
index 0000000000..80390e51c1
--- /dev/null
+++ b/gas/testsuite/gas/elf/group3.d
@@ -0,0 +1,7 @@
+#readelf: -g --wide
+
+COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 3 sections:
+   \[Index\]    Name
+   \[[ 0-9]+\]   \.foo
+   \[[ 0-9]+\]   \.bar
+   \[[ 0-9]+\]   \.rela?\.bar
diff --git a/gas/testsuite/gas/elf/group3.s b/gas/testsuite/gas/elf/group3.s
new file mode 100644
index 0000000000..bece65a225
--- /dev/null
+++ b/gas/testsuite/gas/elf/group3.s
@@ -0,0 +1,7 @@
+	.section .foo,"axG",%progbits,foo,comdat
+	.globl	foo
+	.type	foo,%function
+foo:
+	.byte	1
+	.section .bar,"aG",%progbits,foo,comdat
+	.dc.a	foo
-- 
2.13.6


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