Index: llvm/include/llvm/BinaryFormat/ELF.h =================================================================== --- llvm/include/llvm/BinaryFormat/ELF.h +++ llvm/include/llvm/BinaryFormat/ELF.h @@ -1602,6 +1602,13 @@ NT_FREEBSD_PROCSTAT_AUXV = 16, }; +// NetBSD core note types. +enum { + NT_NETBSDCORE_PROCINFO = 1, + NT_NETBSDCORE_AUXV = 2, + NT_NETBSDCORE_LWPSTATUS = 24, +}; + // OpenBSD core note types. enum { NT_OPENBSD_PROCINFO = 10, Index: llvm/lib/ObjectYAML/ELFYAML.cpp =================================================================== --- llvm/lib/ObjectYAML/ELFYAML.cpp +++ llvm/lib/ObjectYAML/ELFYAML.cpp @@ -155,6 +155,10 @@ ECase(NT_FREEBSD_PROCSTAT_OSREL); ECase(NT_FREEBSD_PROCSTAT_PSSTRINGS); ECase(NT_FREEBSD_PROCSTAT_AUXV); + // NetBSD core note types. + ECase(NT_NETBSDCORE_PROCINFO); + ECase(NT_NETBSDCORE_AUXV); + ECase(NT_NETBSDCORE_LWPSTATUS); // OpenBSD core note types. ECase(NT_OPENBSD_PROCINFO); ECase(NT_OPENBSD_AUXV); Index: llvm/test/tools/llvm-readobj/ELF/note-netbsd-core.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-readobj/ELF/note-netbsd-core.test @@ -0,0 +1,54 @@ +## Test that note values are interpreted correctly for NetBSD core files. +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU --strict-whitespace +# RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM --strict-whitespace + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_CORE +Sections: + - Name: .note.foo + Type: SHT_NOTE + Notes: + - Name: NetBSD-CORE + Type: NT_NETBSDCORE_PROCINFO + - Name: NetBSD-CORE + Type: NT_NETBSDCORE_AUXV + - Name: NetBSD-CORE + Type: NT_NETBSDCORE_LWPSTATUS + +ProgramHeaders: + - Type: PT_NOTE + FirstSec: .note.foo + LastSec: .note.foo + +# GNU: Displaying notes found at file offset 0x00000078 with length 0x00000048: +# GNU-NEXT: Owner Data size Description +# GNU-NEXT: NetBSD-CORE 0x00000000 NT_NETBSDCORE_PROCINFO (procinfo structure) +# GNU-NEXT: NetBSD-CORE 0x00000000 NT_NETBSDCORE_AUXV (ELF auxiliary vector data) +# GNU-NEXT: NetBSD-CORE 0x00000000 PT_LWPSTATUS (ptrace_lwpstatus structure) + +# LLVM: Notes [ +# LLVM-NEXT: NoteSection { +# LLVM-NEXT: Name: +# LLVM-NEXT: Offset: 0x78 +# LLVM-NEXT: Size: 0x48 +# LLVM-NEXT: Note { +# LLVM-NEXT: Owner: NetBSD-CORE +# LLVM-NEXT: Data size: 0x0 +# LLVM-NEXT: Type: NT_NETBSDCORE_PROCINFO (procinfo structure) +# LLVM-NEXT: } +# LLVM-NEXT: Note { +# LLVM-NEXT: Owner: NetBSD-CORE +# LLVM-NEXT: Data size: 0x0 +# LLVM-NEXT: Type: NT_NETBSDCORE_AUXV (ELF auxiliary vector data) +# LLVM-NEXT: } +# LLVM-NEXT: Note { +# LLVM-NEXT: Owner: NetBSD-CORE +# LLVM-NEXT: Data size: 0x0 +# LLVM-NEXT: Type: PT_LWPSTATUS (ptrace_lwpstatus structure) +# LLVM-NEXT: } +# LLVM-NEXT: } +# LLVM-NEXT: ] Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -5333,6 +5333,12 @@ "NT_FREEBSD_FEATURE_CTL (FreeBSD feature control)"}, }; +const NoteType NetBSDCoreNoteTypes[] = { + {ELF::NT_NETBSDCORE_PROCINFO, "NT_NETBSDCORE_PROCINFO (procinfo structure)"}, + {ELF::NT_NETBSDCORE_AUXV, "NT_NETBSDCORE_AUXV (ELF auxiliary vector data)"}, + {ELF::NT_NETBSDCORE_LWPSTATUS, "PT_LWPSTATUS (ptrace_lwpstatus structure)"}, +}; + const NoteType OpenBSDCoreNoteTypes[] = { {ELF::NT_OPENBSD_PROCINFO, "NT_OPENBSD_PROCINFO (procinfo structure)"}, {ELF::NT_OPENBSD_AUXV, "NT_OPENBSD_AUXV (ELF auxiliary vector data)"}, @@ -5453,6 +5459,12 @@ return FindNote(FreeBSDNoteTypes); } } + if (Name.startswith("NetBSD-CORE") && ELFType == ELF::ET_CORE) { + StringRef Result = FindNote(NetBSDCoreNoteTypes); + if (!Result.empty()) + return Result; + return FindNote(CoreNoteTypes); + } if (Name.startswith("OpenBSD") && ELFType == ELF::ET_CORE) { // OpenBSD also places the generic core notes in the OpenBSD namespace. StringRef Result = FindNote(OpenBSDCoreNoteTypes);