Mark section in a section group with SHF_GROUP

Message ID 20180520143042.GA12918@gmail.com
State New
Headers show
Series
  • Mark section in a section group with SHF_GROUP
Related show

Commit Message

H.J. Lu May 20, 2018, 2:30 p.m.
All sections in a section group should be marked with SHF_GROUP.  But
some tools generate broken objects without SHF_GROUP.  This patch fixes
them up for objcopy and strip.

OK for master?

H.J.
----
	PR binutils/23199
	* elf.c (setup_group): Mark section in a section group with
	SHF_GROUP.
---
 bfd/elf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
2.17.0

Comments

Alan Modra May 21, 2018, 11:31 p.m. | #1
On Sun, May 20, 2018 at 07:30:42AM -0700, H.J. Lu wrote:
> 	PR binutils/23199

> 	* elf.c (setup_group): Mark section in a section group with

> 	SHF_GROUP.


Thanks!  This should go on the branch too, I think.

-- 
Alan Modra
Australia Development Lab, IBM
H.J. Lu May 21, 2018, 11:52 p.m. | #2
On Mon, May 21, 2018 at 4:31 PM, Alan Modra <amodra@gmail.com> wrote:
> On Sun, May 20, 2018 at 07:30:42AM -0700, H.J. Lu wrote:

>>       PR binutils/23199

>>       * elf.c (setup_group): Mark section in a section group with

>>       SHF_GROUP.

>

> Thanks!  This should go on the branch too, I think.

>


I will check it into both master and 2.30 branches.

-- 
H.J.

Patch

diff --git a/bfd/elf.c b/bfd/elf.c
index 47d046fa83..6c66bbca02 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -711,7 +711,15 @@  setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
 			  break;
 			}
 		      if (idx < shnum)
-			dest->shdr = elf_elfsections (abfd)[idx];
+			{
+			  dest->shdr = elf_elfsections (abfd)[idx];
+			  /* PR binutils/23199: All sections in a
+			     section group should be marked with
+			     SHF_GROUP.  But some tools generate
+			     broken objects without SHF_GROUP.  Fix
+			     them up here.  */
+			  dest->shdr->sh_flags |= SHF_GROUP;
+			}
 		      if (idx >= shnum
 			  || dest->shdr->sh_type == SHT_GROUP)
 			{