From: Alan Modra <amodra@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] ARC e_flags vs. objcopy
Date: Tue, 16 Apr 2024 23:56:12 +0000 (GMT) [thread overview]
Message-ID: <20240416235612.3377A3858CDB@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f6a18d1f55da5820fa1462950704d209a4c41817
commit f6a18d1f55da5820fa1462950704d209a4c41817
Author: Alan Modra <amodra@gmail.com>
Date: Wed Apr 17 08:06:05 2024 +0930
ARC e_flags vs. objcopy
While the patch that Nick reverted in commit 3f6a060c7543 was in the
source, "FAIL: objcopy executable (pr25662)" was seen on ARC. The
failure was triggered by the .ARC.attributes section being removed by
the linker script. When a file lacking this section is copied by
objcopy, e_flags from the input is copied to the output (in this case
the value 0x406), but arc_elf_final_write_processing then logical-ors
in 0x300 when Tag_ARC_ABI_osver is not found.
* elf32-arc.c (arc_elf_final_write_processing): Don't ignore
existing e_flags for objcopy.
Diff:
---
bfd/elf32-arc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 7e94373773b..bd182996654 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1045,9 +1045,6 @@ static bool
arc_elf_final_write_processing (bfd *abfd)
{
unsigned long emf;
- int osver = bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC,
- Tag_ARC_ABI_osver);
- flagword e_flags = elf_elfheader (abfd)->e_flags & ~EF_ARC_OSABI_MSK;
switch (bfd_get_mach (abfd))
{
@@ -1062,12 +1059,15 @@ arc_elf_final_write_processing (bfd *abfd)
elf_elfheader (abfd)->e_machine = emf;
/* Record whatever is the current syscall ABI version. */
+ int osver = bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC,
+ Tag_ARC_ABI_osver);
+ flagword e_flags = elf_elfheader (abfd)->e_flags;
if (osver)
- e_flags |= ((osver & 0x0f) << 8);
- else
+ e_flags = (e_flags & ~EF_ARC_OSABI_MSK) | ((osver & 0x0f) << 8);
+ else if ((e_flags & EF_ARC_OSABI_MSK) == 0)
e_flags |= E_ARC_OSABI_V3;
- elf_elfheader (abfd)->e_flags |= e_flags;
+ elf_elfheader (abfd)->e_flags = e_flags;
return _bfd_elf_final_write_processing (abfd);
}
reply other threads:[~2024-04-16 23:56 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=20240416235612.3377A3858CDB@sourceware.org \
--to=amodra@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).