This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[resent] [patch] bfd: Core files with p_filesz < p_memsz (build-id)
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: Roland McGrath <roland at redhat dot com>
- Date: Sun, 29 Jul 2007 22:56:25 +0200
- Subject: [resent] [patch] bfd: Core files with p_filesz < p_memsz (build-id)
- References: <20070728191354.GA14892@host0.dyn.jankratochvil.net>
The original mail got corrupted, resent here (thanks for the notice, Daniel).
The patch here is broken - the followup mails are:
http://sourceware.org/ml/binutils/2007-07/msg00516.html
with the corrected patch at:
http://sourceware.org/ml/binutils/2007-07/msg00520.html
------------------------------------------------------------------------------
Hi,
there is now a pending patch for Linux kernels producing core files with the
first page of the ELF file for the build-id note identification.
So far BFD handled either p_filesz == 0 or p_filesz == p_memsz. Patch handles
the case 0 < p_filesz < p_memsz (p_filesz == PAGE_SIZE for the build-id case).
`0 < p_filesz < p_memsz' meaning was so far undefined for the ET_CORE files.
Regards,
Jan
New build-id enhanced Linux kernels produce core files:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
NOTE 0x000660 0x0000000000000000 0x0000000000000000 0x000324 0x000000 0x0
LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x001000 0x0b1000 R E 0x1000
^^^^^^^^ ^^^^^^^^
LOAD 0x002000 0x00000000006b1000 0x0000000000000000 0x00a000 0x00a000 RW 0x1000
BFD-patched gdb `info files'
0x0000000000400000 - 0x0000000000401000 is load1
0x00000000006b1000 - 0x00000000006bb000 is load2
0x0000000000419f00 <main+0>: push %r15
0x0000000000419f02 <main+2>: push %r14
BROKEN: original gdb `info files' (it sees the code sections zeroed)
0x0000000000400000 - 0x0000000000401000 is load1a
0x0000000000401000 - 0x00000000004b1000 is load1b
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0x00000000006b1000 - 0x00000000006bb000 is load2
0x0000000000419f00 <main+0>: add %al,(%rax)
0x0000000000419f02 <main+2>: add %al,(%rax)
(as 0x419f00 >= 0x401000)
Legacy kernel core files:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
NOTE 0x000660 0x0000000000000000 0x0000000000000000 0x000324 0x000000 0x0
LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x000000 0x0b1000 R E 0x1000
^^^^^^^^ ^^^^^^^^
LOAD 0x001000 0x00000000006b1000 0x0000000000000000 0x00a000 0x00a000 RW 0x1000
original gdb `info files'
0x00000000006b1000 - 0x00000000006bb000 is load2
0x0000000000419f00 <main+0>: push %r15
0x0000000000419f02 <main+2>: push %r14
2007-07-28 Jan Kratochvil <jan.kratochvil@redhat.com>
* bfd/elf.c (_bfd_elf_new_section_hook): New comment for ET_CORE files
with p_filesz shorter than p_memsz. The data/bss split case has been
restricted only for non-ET_CORE files.
--- bfd/elf.c 26 Jul 2007 18:15:46 -0000 1.401
+++ bfd/elf.c 28 Jul 2007 19:00:08 -0000
@@ -2225,6 +2225,9 @@ _bfd_elf_new_section_hook (bfd *abfd, as
by the difference between the two sizes. In effect, the segment is split
into it's initialized and uninitialized parts.
+ This notion does not apply in ET_CORE files, where a shorter p_filesz means
+ that the data is not available in the dump.
+
*/
bfd_boolean
@@ -2239,8 +2242,8 @@ _bfd_elf_make_section_from_phdr (bfd *ab
size_t len;
int split;
- split = ((hdr->p_memsz > 0)
- && (hdr->p_filesz > 0)
+ split = (abfd->format != bfd_core
+ && (hdr->p_memsz > 0) && (hdr->p_filesz > 0)
&& (hdr->p_memsz > hdr->p_filesz));
sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : "");
len = strlen (namebuf) + 1;