Module Name: src
Committed By: christos
Date: Wed Mar 29 15:28:42 UTC 2017
Modified Files:
src/external/gpl3/binutils/dist/bfd: elf.c
src/external/gpl3/binutils/dist/binutils: readelf.c
src/external/gpl3/binutils/dist/include/elf: common.h
Log Message:
Teach me about the NetBSD-CORE ELF AuxV note.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/binutils/dist/bfd/elf.c
cvs rdiff -u -r1.17 -r1.18 src/external/gpl3/binutils/dist/binutils/readelf.c
cvs rdiff -u -r1.8 -r1.9 src/external/gpl3/binutils/dist/include/elf/common.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/gpl3/binutils/dist/bfd/elf.c
diff -u src/external/gpl3/binutils/dist/bfd/elf.c:1.7 src/external/gpl3/binutils/dist/bfd/elf.c:1.8
--- src/external/gpl3/binutils/dist/bfd/elf.c:1.7 Wed Oct 26 14:42:52 2016
+++ src/external/gpl3/binutils/dist/bfd/elf.c Wed Mar 29 11:28:42 2017
@@ -8741,6 +8741,22 @@ _bfd_elfcore_make_pseudosection (bfd *ab
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
@@ -9461,18 +9477,7 @@ elfcore_grok_note (bfd *abfd, Elf_Intern
#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",
@@ -9664,18 +9669,7 @@ elfcore_grok_freebsd_note (bfd *abfd, El
return TRUE;
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)
@@ -9721,6 +9715,7 @@ elfcore_grok_netbsd_procinfo (bfd *abfd,
note);
}
+
static bfd_boolean
elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
{
@@ -9729,17 +9724,24 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf
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);
+
+ case NT_NETBSDCORE_AUXV:
+ /* NetBSD-specific Elf Auxiliary Vector data. */
+ return elfcore_make_auxv_note_section (abfd, note, 4);
+
+ 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. */
@@ -9837,18 +9839,7 @@ elfcore_grok_openbsd_note (bfd *abfd, El
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)
{
Index: src/external/gpl3/binutils/dist/binutils/readelf.c
diff -u src/external/gpl3/binutils/dist/binutils/readelf.c:1.17 src/external/gpl3/binutils/dist/binutils/readelf.c:1.18
--- src/external/gpl3/binutils/dist/binutils/readelf.c:1.17 Wed Oct 26 14:42:53 2016
+++ src/external/gpl3/binutils/dist/binutils/readelf.c Wed Mar 29 11:28:42 2017
@@ -15666,10 +15666,15 @@ get_netbsd_elfcore_note_type (unsigned e
{
static char buff[64];
- if (e_type == NT_NETBSDCORE_PROCINFO)
+ switch (e_type)
{
+ case NT_NETBSDCORE_PROCINFO:
/* NetBSD core "procinfo" structure. */
return _("NetBSD procinfo structure");
+ case NT_NETBSDCORE_AUXV:
+ return _("NetBSD ELF auxiliary vector data");
+ default:
+ break;
}
/* As of Jan 2002 there are no other machine-independent notes
Index: src/external/gpl3/binutils/dist/include/elf/common.h
diff -u src/external/gpl3/binutils/dist/include/elf/common.h:1.8 src/external/gpl3/binutils/dist/include/elf/common.h:1.9
--- src/external/gpl3/binutils/dist/include/elf/common.h:1.8 Wed Oct 26 14:43:26 2016
+++ src/external/gpl3/binutils/dist/include/elf/common.h Wed Mar 29 11:28:42 2017
@@ -614,6 +614,7 @@
must start with "NetBSD-CORE". */
#define NT_NETBSDCORE_PROCINFO 1 /* Has a struct procinfo */
+#define NT_NETBSDCORE_AUXV 2 /* Has ELF Auxiliary vector */
#define NT_NETBSDCORE_FIRSTMACH 32 /* start of machdep note types */