This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: Check EI_OSABI for ELF/HPPA.


On Sun, Jun 03, 2001 at 11:56:48AM +0930, Alan Modra wrote:
> On Sat, Jun 02, 2001 at 11:15:19AM -0700, H . J . Lu wrote:
> > 	* elf32-hppa.c (elf32_hppa_object_p): Check ELFOSABI_LINUX
> > 	and ELFOSABI_HPUX.
> 
> OK.
> 
> > 	* elf64-hppa.c (elf64_hppa_object_p): Check ELFOSABI_LINUX
> > 	and ELFOSABI_HPUX/EI_ABIVERSION.
> 
> OK, but it may be better to leave out the ABIVERSION check.  The
> OSABI byte is sufficient to distinguish the two varieties.
> 

I checked in the following patch.


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): Likewise.

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/03 02:37:56
@@ -358,8 +358,22 @@ 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)
+	return false;
+    }
+
+  flags = i_ehdrp->e_flags;
   switch (flags & (EF_PARISC_ARCH | EF_PARISC_WIDE))
     {
     case EFA_PARISC_1_0:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]