[PATCH] bfd: support section groups with preceding SHF_GROUP sections
Jose E. Marchesi
jose.marchesi@oracle.com
Tue Jun 6 07:01:00 GMT 2017
GAS always places section groups (SHT_GROUP) before the rest of the
sections in the output file. However, other assemblers may place
section groups after the group members.
Example in the object attached, xdfdh.o:
COMDAT group section [ 12] `.group.__cg_vis_memcpy' [__cg_vis_memcpy]
contains 1 sections:
[Index] Name
[ 4] .text.__cg_vis_memcpy
Note how .text.__cg_vis_memcpy (idx 4) is placed before
.group.__cg_vis_memcpy (idx 12).
This is not handled properly by BFD. The patch below makes sure to
create BFD sections for all the SHT_GROUP sections in the input file
before processing SHF_GROUP sections.
Tested in sparc64-linux-gnu and x86_64-linux-gnu.
No regressions.
PS: I looked into creating a test for this, but couldn't find a way to
create such an object file with GAS, nor to reorder the sections.
Adding a binary object to the LD testsuite is probably a no-no. Any
suggestion?
2017-06-05 Jose E. Marchesi <jose.marchesi@oracle.com>
* elf.c (setup_group): Make sure BFD sections are created for all
group sections in the input file when processing SHF_GROUP
sections.
diff --git a/bfd/elf.c b/bfd/elf.c
index 34d39c5..1cc0952 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -636,6 +636,11 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
unsigned char *src;
Elf_Internal_Group *dest;
+ /* Make sure the group section has a BFD section
+ attached to it. */
+ if (!bfd_section_from_shdr (abfd, i))
+ return FALSE;
+
/* Add to list of sections. */
elf_tdata (abfd)->group_sect_ptr[num_group] = shdr;
num_group += 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xdfdh.o
Type: application/x-object
Size: 8896 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20170606/48867e29/attachment.bin>
More information about the Binutils
mailing list