PATCH: Check EI_OSABI for ELF/HPPA.
H . J . Lu
hjl@lucon.org
Sat Jun 2 11:15:00 GMT 2001
Binutils won't work on ELF/HPPA unless ELF/HPPA is the default
target since both elf32-hppa-linux and elf32-hppa will match
any ELF/HPPA binaries. This patch seems to work for me. Alan,
can I check it in?
H.J.
-----
2001-06-02 H.J. Lu <hjl@gnu.org>
* elf32-hppa.c (elf32_hppa_object_p): Check ELFOSABI_LINUX
and ELFOSABI_HPUX.
* elf64-hppa.c (elf64_hppa_object_p): Check ELFOSABI_LINUX
and ELFOSABI_HPUX/EI_ABIVERSION.
Index: elf32-hppa.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf32-hppa.c,v
retrieving revision 1.27
diff -u -p -r1.27 elf32-hppa.c
--- elf32-hppa.c 2001/06/02 04:47:13 1.27
+++ elf32-hppa.c 2001/06/02 18:07:12
@@ -1147,8 +1147,22 @@ static boolean
elf32_hppa_object_p (abfd)
bfd *abfd;
{
- unsigned int flags = elf_elfheader (abfd)->e_flags;
+ Elf_Internal_Ehdr * i_ehdrp;
+ unsigned int flags;
+ i_ehdrp = elf_elfheader (abfd);
+ if (strcmp (bfd_get_target (abfd), "elf32-hppa-linux") == 0)
+ {
+ if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX)
+ return false;
+ }
+ else
+ {
+ if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX)
+ return false;
+ }
+
+ flags = i_ehdrp->e_flags;
switch (flags & (EF_PARISC_ARCH | EF_PARISC_WIDE))
{
case EFA_PARISC_1_0:
Index: elf64-hppa.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf64-hppa.c,v
retrieving revision 1.1.1.10
diff -u -p -r1.1.1.10 elf64-hppa.c
--- elf64-hppa.c 2001/02/03 22:52:36 1.1.1.10
+++ elf64-hppa.c 2001/06/02 18:06:50
@@ -358,8 +358,23 @@ static boolean
elf64_hppa_object_p (abfd)
bfd *abfd;
{
- unsigned int flags = elf_elfheader (abfd)->e_flags;
+ Elf_Internal_Ehdr * i_ehdrp;
+ unsigned int flags;
+ i_ehdrp = elf_elfheader (abfd);
+ if (strcmp (bfd_get_target (abfd), "elf64-hppa-linux") == 0)
+ {
+ if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX)
+ return false;
+ }
+ else
+ {
+ if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX
+ || i_ehdrp->e_ident[EI_ABIVERSION] != 1)
+ return false;
+ }
+
+ flags = i_ehdrp->e_flags;
switch (flags & (EF_PARISC_ARCH | EF_PARISC_WIDE))
{
case EFA_PARISC_1_0:
More information about the Binutils
mailing list