[rfa/hpux] Handle core files better for hppa64-hp-hpux11.11

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[rfa/hpux] Handle core files better for hppa64-hp-hpux11.11

Randolph Chung
The attached patch improves the handling of core files for
hppa64-hp-hpux11.11. Together with some other gdb patches this will
allow gdb to handle core files for this target. (see corefiles/2026)

For the first bit, on this target, HPUX apparently generates ELF Core
files that have OSABI=SYSV, and even though it is a 64-bit file, it
doesn't set the wide bit for the machine type.

Pls apply if ok.

randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

2005-11-17  Randolph Chung  <[hidden email]>

        * elf64-hppa.c (elf64_hppa_object_p): Properly recognize corefiles under
        hppa64-hp-hpux11.11.
        (elf64_hppa_section_from_phdr): New function.
        (elf_backend_section_from_phdr): Define.

Index: elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.65
diff -u -p -r1.65 elf64-hppa.c
--- elf64-hppa.c 14 Aug 2005 01:01:32 -0000 1.65
+++ elf64-hppa.c 17 Nov 2005 01:23:50 -0000
@@ -387,7 +387,10 @@ elf64_hppa_object_p (abfd)
     }
   else
     {
-      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX)
+      /* HPUX produces binaries with OSABI=HPUX,
+ but the kernel produces corefiles with OSABI=SysV.  */
+      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX &&
+  i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
  return FALSE;
     }
 
@@ -399,7 +402,10 @@ elf64_hppa_object_p (abfd)
     case EFA_PARISC_1_1:
       return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 11);
     case EFA_PARISC_2_0:
-      return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 20);
+      if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64)
+        return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);
+      else
+        return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 20);
     case EFA_PARISC_2_0 | EF_PARISC_WIDE:
       return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);
     }
@@ -2653,6 +2659,36 @@ static const struct bfd_elf_special_sect
   { NULL,      0, 0, 0,            0 }
 };
 
+/* Support HP specific sections for core files.  */
+static bfd_boolean
+elf64_hppa_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int index,
+                              const char *typename)
+{
+  if (hdr->p_type == PT_HP_CORE_PROC)
+    {
+      int sig;
+
+      if (bfd_seek (abfd, hdr->p_offset, SEEK_SET) != 0)
+        return FALSE;
+      if (bfd_bread (&sig, 4, abfd) != 4)
+        return FALSE;
+
+      elf_tdata (abfd)->core_signal = sig;
+
+      /* gdb uses the ".reg" section to read register contents.  */
+      if (!_bfd_elfcore_make_pseudosection (abfd, ".reg", hdr->p_filesz,
+      hdr->p_offset))
+        return FALSE;
+    }
+
+  if (hdr->p_type == PT_HP_CORE_LOADABLE
+      || hdr->p_type == PT_HP_CORE_STACK
+      || hdr->p_type == PT_HP_CORE_MMF)
+    hdr->p_type = PT_LOAD;
+
+  return _bfd_elf_make_section_from_phdr (abfd, hdr, index, typename);
+}
+
 /* The hash bucket size is the standard one, namely 4.  */
 
 const struct elf_size_info hppa64_elf_size_info =
@@ -2751,6 +2787,7 @@ const struct elf_size_info hppa64_elf_si
 #define elf_backend_rela_normal 1
 #define elf_backend_special_sections elf64_hppa_special_sections
 #define elf_backend_action_discarded elf_hppa_action_discarded
+#define elf_backend_section_from_phdr   elf64_hppa_section_from_phdr
 
 #include "elf64-target.h"
 
Reply | Threaded
Open this post in threaded view
|

Re: [rfa/hpux] Handle core files better for hppa64-hp-hpux11.11

John David Anglin-4
> Pls apply if ok.

Done.  I made some minor formatting changes.

Thanks,
Dave
--
J. David Anglin                                  [hidden email]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)