https://sourceware.org/bugzilla/show_bug.cgi?id=19147
Bug ID: 19147 Summary: readelf -n does not print all NT_FILE notes (off by one) Product: binutils Version: 2.26 (HEAD) Status: NEW Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: ppluzhnikov at google dot com Target Milestone: --- Test: cat t.c #include <stdlib.h> int main() { abort(); } gcc -static t.c && gdb -q ./a.out (gdb) r Starting program: /tmp/a.out Program received signal SIGABRT, Aborted. 0x0000000000444749 in raise () (gdb) info proc map process 133253 Mapped address spaces: Start Addr End Addr Size Offset objfile 0x400000 0x4bf000 0xbf000 0x0 /tmp/a.out 0x6be000 0x6c1000 0x3000 0xbe000 /tmp/a.out 0x6c1000 0x6e7000 0x26000 0x0 [heap] 0x7ffff7ffd000 0x7ffff7fff000 0x2000 0x0 [vdso] 0x7ffffffde000 0x7ffffffff000 0x21000 0x0 [stack] 0xffffffffff600000 0xffffffffff601000 0x1000 0x0 [vsyscall] Note that there are two mappings, and when the kernel saves a core dump, the file count is 2. Yet 'readelf -n /tmp/core.133445' prints only one of them: Displaying notes found at file offset 0x00000200 with length 0x000009b8: Owner Data size Description CORE 0x00000150 NT_PRSTATUS (prstatus structure) CORE 0x00000088 NT_PRPSINFO (prpsinfo structure) CORE 0x00000080 NT_SIGINFO (siginfo_t data) CORE 0x00000130 NT_AUXV (auxiliary vector) CORE 0x00000064 NT_FILE (mapped files) Page size: 4096 Start End Page Offset 0x0000000000400000 0x00000000004bf000 0x0000000000000000 /tmp/a.out CORE 0x00000200 NT_FPREGSET (floating point registers) LINUX 0x00000340 NT_X86_XSTATE (x86 XSAVE extended state) The fix is trivial: diff --git a/binutils/readelf.c b/binutils/readelf.c index e8c215d..22cec2c 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -15151,7 +15151,7 @@ print_core_note (Elf_Internal_Note *pnote) (int) (4 + 2 * addr_size), _("End"), (int) (4 + 2 * addr_size), _("Page Offset")); filenames = descdata + count * 3 * addr_size; - while (--count > 0) + while (count-- > 0) { bfd_vma start, end, file_ofs; With the fix: build/binutils/readelf -n /tmp/core.133445 Displaying notes found at file offset 0x00000200 with length 0x000009b8: Owner Data size Description CORE 0x00000150 NT_PRSTATUS (prstatus structure) CORE 0x00000088 NT_PRPSINFO (prpsinfo structure) CORE 0x00000080 NT_SIGINFO (siginfo_t data) CORE 0x00000130 NT_AUXV (auxiliary vector) CORE 0x00000064 NT_FILE (mapped files) Page size: 4096 Start End Page Offset 0x0000000000400000 0x00000000004bf000 0x0000000000000000 /tmp/a.out 0x00000000006be000 0x00000000006c1000 0x00000000000000be /tmp/a.out CORE 0x00000200 NT_FPREGSET (floating point registers) LINUX 0x00000340 NT_X86_XSTATE (x86 XSAVE extended state) -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils