From: Jan Beulich <jbeulich@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] objcopy: check input flavor before setting PE/COFF section alignment
Date: Fri, 26 Apr 2024 12:23:57 +0000 (GMT) [thread overview]
Message-ID: <20240426122357.75D783858402@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fde04116b4b835fa9ec3b3497fcac4e4a0637e2
commit 6fde04116b4b835fa9ec3b3497fcac4e4a0637e2
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Apr 26 14:23:14 2024 +0200
objcopy: check input flavor before setting PE/COFF section alignment
coff_section_data() and elf_section_data() use the same underlying
field. The pointer being non-NULL therefore isn't sufficient to know
that pei_section_data() can validly be used on the incoming object.
Apparently in 64-bit-host builds the resulting memory corruption is
benign, whereas in 32-bit-host builds a segmentation fault occurs upon
de-referencing pei_section_data()'s return value.
Diff:
---
binutils/objcopy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index e8ca1374935..26f9d4a0f26 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4317,6 +4317,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
if (p != NULL)
alignment = p->alignment;
else if (pe_section_alignment != (bfd_vma) -1
+ && bfd_get_flavour (ibfd) == bfd_target_coff_flavour
&& bfd_get_flavour (obfd) == bfd_target_coff_flavour)
{
alignment = power_of_two (pe_section_alignment);
reply other threads:[~2024-04-26 12:23 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=20240426122357.75D783858402@sourceware.org \
--to=jbeulich@sourceware.org \
--cc=binutils-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).