This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: big endian i86
H.J. Lu wrote:
On Thu, May 08, 2008 at 01:57:26PM +0100, Nathan Sidwell wrote:
Hi,
I have a bug report about i86-ld allowing you to create big endian i86 modules with:
ld -EB ....
The linker produces no errors, but the resultant file is marked with
unknown architecture, and is pretty useless :) Is there a rationale for
not issuing an error at link time? I notice elf32-i386.c lacks a
You may want to take a look at closest_target_match in ldlang.c.
It matches -EB any with big endian ELF target like elf64-big
or elf32-big. I think closest_target_match is too simple for ELF
target. We should at least check one or more of arch,
elf_machine_code, elf_size_info.
How about having closest_target_match ignore elf{32,64}-{big,little} ? Those
vectors are only added so you can do _something_ with the wrong endianness (as
bfd/config.bfd tells us):
# If we support any ELF target, then automatically add support for the
# generic ELF targets. This permits an objdump with some ELF support
# to be used on an arbitrary ELF file for anything other than
# relocation information.
but without relocation processing, there's not much linking you can do.
ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2008-05-13 Nathan Sidwell <nathan@codesourcery.com>
* ldlang.c (closest_target_match): Ignore generic elf vectors.
Index: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.284
diff -c -3 -p -r1.284 ldlang.c
*** ldlang.c 28 Apr 2008 12:45:33 -0000 1.284
--- ldlang.c 13 May 2008 14:53:56 -0000
*************** name_compare (char *first, char *second)
*** 2653,2659 ****
stricpy (copy1, first);
stricpy (copy2, second);
! /* Remove size and endian strings from the name. */
strcut (copy1, "big");
strcut (copy1, "little");
strcut (copy2, "big");
--- 2653,2659 ----
stricpy (copy1, first);
stricpy (copy2, second);
! /* Remove endian strings from the name. */
strcut (copy1, "big");
strcut (copy1, "little");
strcut (copy2, "big");
*************** closest_target_match (const bfd_target *
*** 2699,2704 ****
--- 2699,2711 ----
if (target->flavour != original->flavour)
return 0;
+ /* Ignore generic big and little endian elf vectors. */
+ if ((!memcmp (target->name, "elf32", 5)
+ || !memcmp (target->name, "elf64", 5))
+ && (!strcmp (target->name + 5, "-big")
+ || !strcmp (target->name + 5, "-little")))
+ return 0;
+
/* If we have not found a potential winner yet, then record this one. */
if (winner == NULL)
{