Teach me about the NetBSD-CORE ELF AuxV note.

This commit is contained in:
christos 2017-03-29 15:28:42 +00:00
parent 9842222b6c
commit 7ef1d3a265
3 changed files with 37 additions and 40 deletions

View File

@ -8741,6 +8741,22 @@ _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
@ -9461,18 +9477,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",
@ -9664,18 +9669,7 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
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, Elf_Internal_Note *note)
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_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);
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, 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)
{

View File

@ -15666,10 +15666,15 @@ get_netbsd_elfcore_note_type (unsigned e_type)
{
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

View File

@ -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 */