summaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2019-06-10 14:41:35 +0100
committerNick Clifton <nickc@redhat.com>2019-06-10 14:41:35 +0100
commit58e07198f34c3a8bb7d64392e8b978a0d741244e (patch)
tree0eb790d1b10a9127593d9202f3e507ccf40615b6 /bfd/elf.c
parent25ce02ee7b7667fb7bb882421ff869c080777bee (diff)
downloadbinutils-gdb-58e07198f34c3a8bb7d64392e8b978a0d741244e.tar.gz
Add support for NetBSD/sh3 core file sections. Merge multiple copies of auxv section creation into one function.
PR 24650 * elf.c (elfcore_make_auxv_note_section): New function. (elfcore_grok_note): Use it. (elfcore_grok_freebsd_note): Likewise. (elfcore_grok_openbsd_note): Likewise. (elfcore_grok_netbsd_note): Likewise. Plus add support for NT_NETBSDCORE_AUXV notes.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c86
1 files changed, 47 insertions, 39 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index b463f1df8b2..2094fca1ff5 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9236,6 +9236,23 @@ _bfd_elfcore_make_pseudosection (bfd *abfd,
return elfcore_maybe_make_sect (abfd, name, sect);
}
+static bfd_boolean
+elfcore_make_auxv_note_section (bfd *abfd, Elf_Internal_Note *note,
+ size_t offs)
+{
+ asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
+ SEC_HAS_CONTENTS);
+
+ if (sect == NULL)
+ return FALSE;
+
+ sect->size = note->descsz - offs;
+ sect->filepos = note->descpos + offs;
+ sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
+
+ return TRUE;
+}
+
/* prstatus_t exists on:
solaris 2.5+
linux 2.[01] + glibc
@@ -10177,18 +10194,7 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
#endif
case NT_AUXV:
- {
- asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
- SEC_HAS_CONTENTS);
-
- if (sect == NULL)
- return FALSE;
- sect->size = note->descsz;
- sect->filepos = note->descpos;
- sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
-
- return TRUE;
- }
+ return elfcore_make_auxv_note_section (abfd, note, 0);
case NT_FILE:
return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.file",
@@ -10434,18 +10440,7 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
note);
case NT_FREEBSD_PROCSTAT_AUXV:
- {
- asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
- SEC_HAS_CONTENTS);
-
- if (sect == NULL)
- return FALSE;
- sect->size = note->descsz - 4;
- sect->filepos = note->descpos + 4;
- sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
-
- return TRUE;
- }
+ return elfcore_make_auxv_note_section (abfd, note, 4);
case NT_X86_XSTATE:
if (note->namesz == 8)
@@ -10509,17 +10504,24 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
if (elfcore_netbsd_get_lwpid (note, &lwp))
elf_tdata (abfd)->core->lwpid = lwp;
- if (note->type == NT_NETBSDCORE_PROCINFO)
+ switch (note->type)
{
+ case NT_NETBSDCORE_PROCINFO:
/* NetBSD-specific core "procinfo". Note that we expect to
find this note before any of the others, which is fine,
since the kernel writes this note out first when it
creates a core file. */
-
return elfcore_grok_netbsd_procinfo (abfd, note);
+#ifdef NT_NETBSDCORE_AUXV
+ case NT_NETBSDCORE_AUXV:
+ /* NetBSD-specific Elf Auxiliary Vector data. */
+ return elfcore_make_auxv_note_section (abfd, note, 4);
+#endif
+ default:
+ break;
}
- /* As of Jan 2002 there are no other machine-independent notes
+ /* As of March 2017 there are no other machine-independent notes
defined for NetBSD core files. If the note type is less
than the start of the machine-dependent note types, we don't
understand it. */
@@ -10547,6 +10549,23 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
return TRUE;
}
+ /* On SuperH, PT_GETREGS == mach+3 and PT_GETFPREGS == mach+5.
+ There's also old PT___GETREGS40 == mach + 1 for old reg
+ structure which lacks GBR. */
+
+ case bfd_arch_sh:
+ switch (note->type)
+ {
+ case NT_NETBSDCORE_FIRSTMACH+3:
+ return elfcore_make_note_pseudosection (abfd, ".reg", note);
+
+ case NT_NETBSDCORE_FIRSTMACH+5:
+ return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+
+ default:
+ return TRUE;
+ }
+
/* On all other arch's, PT_GETREGS == mach+1 and
PT_GETFPREGS == mach+3. */
@@ -10603,18 +10622,7 @@ elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
if (note->type == NT_OPENBSD_AUXV)
- {
- asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
- SEC_HAS_CONTENTS);
-
- if (sect == NULL)
- return FALSE;
- sect->size = note->descsz;
- sect->filepos = note->descpos;
- sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
-
- return TRUE;
- }
+ return elfcore_make_auxv_note_section (abfd, note, 0);
if (note->type == NT_OPENBSD_WCOOKIE)
{