aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2022-09-09 12:01:08 +0100
committerNick Clifton <nickc@redhat.com>2022-09-09 12:01:55 +0100
commitefc1521e40b67f2eac4f5f425731195d385fa127 (patch)
tree236c17a4bc11b46d06c38a82cfb1869e2354b423 /binutils/objcopy.c
parent1daabcc746e7d2f04ab190b49aec9abb020f29aa (diff)
downloadgdb-efc1521e40b67f2eac4f5f425731195d385fa127.zip
gdb-efc1521e40b67f2eac4f5f425731195d385fa127.tar.gz
gdb-efc1521e40b67f2eac4f5f425731195d385fa127.tar.bz2
Support debuginfo files with empty group sections.
PR 29532 bfd * elf.c (setup_group): Do not return false if there is no group information available. bionutils* objcopy.c (setup_section): Leave group sections intact when creating separate debuginfo files.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 1118a22..75992e8 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4084,17 +4084,26 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
&& (flags & (SEC_ALLOC | SEC_GROUP)) != 0
&& !is_nondebug_keep_contents_section (ibfd, isection))
{
- flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP);
+ flagword remove = SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP;
+
if (bfd_get_flavour (obfd) == bfd_target_elf_flavour)
{
- make_nobits = true;
+ /* PR 29532: Copy group sections intact as otherwise we end up with
+ empty groups. This prevents separate debug info files from
+ being used with GDB, if they were based upon files that
+ originally contained groups. */
+ if (flags & SEC_GROUP)
+ remove = SEC_LOAD;
+ else
+ make_nobits = true;
/* Twiddle the input section flags so that it seems to
elf.c:copy_private_bfd_data that section flags have not
changed between input and output sections. This hack
prevents wholesale rewriting of the program headers. */
- isection->flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP);
+ isection->flags &= ~remove;
}
+ flags &= ~remove;
}
osection = bfd_make_section_anyway_with_flags (obfd, name, flags);