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: [PATCH] bfd: support section groups with preceding SHF_GROUP sections


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
problem.

diff --git a/bfd/elf.c b/bfd/elf.c
index bab1e16..3ffd409 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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;
 	  asection *s;
 
 	  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!)

-- 
Alan Modra
Australia Development Lab, IBM


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