public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Check EI_OSABI for ELF/HPPA.
@ 2001-06-02 11:15 H . J . Lu
  2001-06-02 19:25 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: H . J . Lu @ 2001-06-02 11:15 UTC (permalink / raw)
  To: amodra; +Cc: binutils

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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Check EI_OSABI for ELF/HPPA.
  2001-06-02 11:15 PATCH: Check EI_OSABI for ELF/HPPA H . J . Lu
@ 2001-06-02 19:25 ` Alan Modra
  2001-06-02 19:43   ` H . J . Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2001-06-02 19:25 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils

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.

Thanks for fixing this.  I've been aware of the problem for some time
but never got annoyed enough to fix it, as it only affects cross-tools
and can be worked around by giving the target explicitly on the
command line.

-- 
Alan Modra

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Check EI_OSABI for ELF/HPPA.
  2001-06-02 19:25 ` Alan Modra
@ 2001-06-02 19:43   ` H . J . Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H . J . Lu @ 2001-06-02 19:43 UTC (permalink / raw)
  To: binutils

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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-02 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-02 11:15 PATCH: Check EI_OSABI for ELF/HPPA H . J . Lu
2001-06-02 19:25 ` Alan Modra
2001-06-02 19:43   ` H . J . Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).