This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Properly detect OpenBSD/hppa executables


For some reason, binutils marks PA-RISC ELF files as HP-UX on
everything except GNU/Linux.  As a result, OpenBSD/hppa executables
aren't recognized properly.  This patch fixes that by looking at
OS-specific notes for ELFOSABI_HPUX just like we do for ELFOSABI_NONE.

I'm not sure whether binutils is wrong in using ELFOSABI_HPUX; if
OpenBSD is using the same OS-specific extensions as HP-UX, the setting
is legitimate.  In any case, there will be binaries out there with the
ELFOSABI_HPUX setting, and it would be nice if we'de recognize them
properly.

If there are no objections, I'll check this in in a week or so.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* osabi.c: Update copyright year.
	(generic_elf_osabi_sniffer): Tweak comment.  Look for OS-specific
	notes if EI_OSABI is set to ELFOSABI_HPUX.

Index: osabi.c
===================================================================
RCS file: /cvs/src/src/gdb/osabi.c,v
retrieving revision 1.27
diff -u -p -r1.27 osabi.c
--- osabi.c 22 Jan 2004 21:56:34 -0000 1.27
+++ osabi.c 26 Jun 2004 10:12:41 -0000
@@ -1,5 +1,6 @@
 /* OS ABI variant handling for GDB.
-   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -501,10 +502,11 @@ generic_elf_osabi_sniffer (bfd *abfd)
   switch (elfosabi)
     {
     case ELFOSABI_NONE:
-      /* When elfosabi is ELFOSABI_NONE (0), then the ELF structures in the
-         file are conforming to the base specification for that machine
-	 (there are no OS-specific extensions).  In order to determine the
-	 real OS in use we must look for OS notes that have been added.  */
+      /* When the EI_OSABI field in the ELF header is ELFOSABI_NONE
+         (0), then the ELF structures in the file are conforming to
+         the base specification for that machine (there are no
+         OS-specific extensions).  In order to determine the real OS
+         in use we must look for OS-specific notes.  */
       bfd_map_over_sections (abfd,
 			     generic_elf_osabi_sniff_abi_tag_sections,
 			     &osabi);
@@ -531,7 +533,14 @@ generic_elf_osabi_sniffer (bfd *abfd)
       break;
 
     case ELFOSABI_HPUX:
+      /* For some reason the default value for the EI_OSABI field is
+         ELFOSABI_HPUX for all PA-RISC targets (with the exception of
+         GNU/Linux).  We use HP-UX ELF as the default, but let any
+         OS-specific notes override this.  */
       osabi = GDB_OSABI_HPUX_ELF;
+      bfd_map_over_sections (abfd,
+			     generic_elf_osabi_sniff_abi_tag_sections,
+			     &osabi);
       break;
     }
 


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