From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Support debuginfo files with empty group sections.
Date: Fri, 9 Sep 2022 11:02:56 +0000 (GMT) [thread overview]
Message-ID: <20220909110256.DB4A338582BF@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=efc1521e40b67f2eac4f5f425731195d385fa127
commit efc1521e40b67f2eac4f5f425731195d385fa127
Author: Nick Clifton <nickc@redhat.com>
Date: Fri Sep 9 12:01:08 2022 +0100
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.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elf.c | 6 +++++-
binutils/ChangeLog | 6 ++++++
binutils/objcopy.c | 15 ++++++++++++---
4 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a0e1e87ea26..c618d817ff9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-09 Nick Clifton <nickc@redhat.com>
+
+ PR 29532
+ * elf.c (setup_group): Do not return false if there is no group
+ information available.
+
2022-09-02 Aaron Merey <amerey@redhat.com>
* aout-target.h (MY_find_nearest_line_with_alt): New macro.
diff --git a/bfd/elf.c b/bfd/elf.c
index 1f427e40a44..2eb2a97370a 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -830,7 +830,11 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
/* xgettext:c-format */
_bfd_error_handler (_("%pB: no group info for section '%pA'"),
abfd, newsect);
- return false;
+ /* PR 29532: Return true here, even though the group info has not been
+ read. Separate debug info files can have empty group sections, but
+ we do not want this to prevent them from being loaded as otherwise
+ GDB will not be able to use them. */
+ return true;
}
return true;
}
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 5f8403b158b..3cac2353e3b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-09 Nick Clifton <nickc@redhat.com>
+
+ PR 29532
+ * objcopy.c (setup_section): Leave group sections intact when
+ creating separate debuginfo files.
+
2022-09-08 Nick Clifton <nickc@redhat.com>
PR 29523
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 1118a2256a4..75992e8a3f7 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);
reply other threads:[~2022-09-09 11:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220909110256.DB4A338582BF@sourceware.org \
--to=nickc@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).