This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Reject BE8 input
- From: Paul Brook <paul at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Sat, 7 Jun 2008 00:19:43 +0100
- Subject: Reject BE8 input
I recently encountered a misconfigured arm toolchain where some objects had
been created with ld -r --be8. The final link doesn't notice that these
objects have already been byteswapped, and created broken binaries.
I considered making ld ignore --be8 when -r was specified. However there are
plausible use cases for this functionality. The most obvious being Linux
kernel modules, I doubt the kernel folks would appreciate having to
re-implement BE8 byteswapping.
The patch below makes ld fail loudly when it encounters a BE8 object. The
AAELF says that the BE8 flag is only valid on executable files, so we're
entitled to reject them.
Tested on arm-none-eabi
Applied to CVS head.
Paul
2008-06-06 Paul Brook <paul@codesourcery.com>
bfd/
* elf32-arm.c (elf32_arm_merge_private_bfd_data): Reject BE8 input.
Index: bfd/elf32-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/bfd/elf32-arm.c,v
retrieving revision 1.145
diff -u -p -r1.145 elf32-arm.c
--- bfd/elf32-arm.c 23 May 2008 13:53:26 -0000 1.145
+++ bfd/elf32-arm.c 6 Jun 2008 23:05:05 -0000
@@ -8378,6 +8378,17 @@ elf32_arm_merge_private_bfd_data (bfd *
in_flags = elf_elfheader (ibfd)->e_flags;
out_flags = elf_elfheader (obfd)->e_flags;
+ /* In theory there is no reason why we couldn't handle this. However
+ in practice it isn't even close to working and there is no real
+ reason to want it. */
+ if (EF_ARM_EABI_VERSION (in_flags) >= EF_ARM_EABI_VER4
+ && (in_flags & EF_ARM_BE8))
+ {
+ _bfd_error_handler (_("ERROR: %B is already in final BE8 format"),
+ ibfd);
+ return FALSE;
+ }
+
if (!elf_flags_init (obfd))
{
/* If the input is the default architecture and had the default