From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 3377A3858CDB; Tue, 16 Apr 2024 23:56:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3377A3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713311772; bh=AuzsW+UyBKLrEwiWSl3qW9KSlL6jSNgxRcCURX4Y7Bo=; h=From:To:Subject:Date:From; b=pjhAnee/CXIBp7oj+SnIoxDIfW0uUdIKrTPMUW7UwQtzzEl6ROO8GBH/PjhRkHBGM JRwkXVu7ks8sXgz/jvIgOLBuGaEp7wikiEPAdeuBOzIQicEKKeBml1r8M2OC/2rI4Q eFdjngn0Qcvwu+brESS7HepXpY0Gvnp+5OE4jhyM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] ARC e_flags vs. objcopy X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 59497587af9e1c5f029ab0bb106103dab30a5f5d X-Git-Newrev: f6a18d1f55da5820fa1462950704d209a4c41817 Message-Id: <20240416235612.3377A3858CDB@sourceware.org> Date: Tue, 16 Apr 2024 23:56:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df6a18d1f55da= 5820fa1462950704d209a4c41817 commit f6a18d1f55da5820fa1462950704d209a4c41817 Author: Alan Modra Date: Wed Apr 17 08:06:05 2024 +0930 ARC e_flags vs. objcopy =20 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. =20 * 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 =3D bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, - Tag_ARC_ABI_osver); - flagword e_flags =3D elf_elfheader (abfd)->e_flags & ~EF_ARC_OSABI_MSK; =20 switch (bfd_get_mach (abfd)) { @@ -1062,12 +1059,15 @@ arc_elf_final_write_processing (bfd *abfd) elf_elfheader (abfd)->e_machine =3D emf; =20 /* Record whatever is the current syscall ABI version. */ + int osver =3D bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, + Tag_ARC_ABI_osver); + flagword e_flags =3D elf_elfheader (abfd)->e_flags; if (osver) - e_flags |=3D ((osver & 0x0f) << 8); - else + e_flags =3D (e_flags & ~EF_ARC_OSABI_MSK) | ((osver & 0x0f) << 8); + else if ((e_flags & EF_ARC_OSABI_MSK) =3D=3D 0) e_flags |=3D E_ARC_OSABI_V3; =20 - elf_elfheader (abfd)->e_flags |=3D e_flags; + elf_elfheader (abfd)->e_flags =3D e_flags; return _bfd_elf_final_write_processing (abfd); }