This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] bfd: support section groups with preceding SHF_GROUP sections
- From: Alan Modra <amodra at gmail dot com>
- To: "Jose E. Marchesi" <jose dot marchesi at oracle dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 7 Jun 2017 00:15:33 +0930
- Subject: Re: [PATCH] bfd: support section groups with preceding SHF_GROUP sections
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
On Tue, Jun 06, 2017 at 09:01:02AM +0200, Jose E. Marchesi wrote:
> 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.
I'm sure that used to work at one point. Hmm, by the look of it,
broken by git commit 06614111d. So the following would fix the
diff --git a/bfd/elf.c b/bfd/elf.c
index bab1e16..3ffd409 100644
@@ -2424,7 +2424,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
if (hdr->contents != NULL)
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents;
- unsigned int n_elt = hdr->sh_size / sizeof (* idx);
+ unsigned int n_elt = hdr->sh_size / GRP_ENTRY_SIZE;
if (n_elt == 0)
But I like your patch better if you also delete all of the above
hdr->contents != NULL code, which I think should then be unnecessary.
Ok to commit with that change. (Please check that what I'm
suggesting is sane first!)
Australia Development Lab, IBM