ELF program header table in MiniDebugInfo files
Martin Milata
mmilata at redhat.com
Tue Jun 4 14:19:17 UTC 2013
Hello,
in the process of making ABRT aware of MiniDebugInfo[1] through the
libunwind library, I noticed that the MiniDebugInfo files in Fedora 19
(F18 too) have different ELF program header tables than the
corresponding binaries and separate debuginfo files:
$ eu-readelf -l /usr/bin/cat
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000400040 0x0000000000400040 0x0001f8 0x0001f8 R E 0x8
INTERP 0x000238 0x0000000000400238 0x0000000000400238 0x00001c 0x00001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x00b3e0 0x00b3e0 R E 0x200000
LOAD 0x00bc30 0x000000000060bc30 0x000000000060bc30 0x0006f0 0x001078 RW 0x200000
DYNAMIC 0x00bde8 0x000000000060bde8 0x000000000060bde8 0x0001d0 0x0001d0 RW 0x8
NOTE 0x000254 0x0000000000400254 0x0000000000400254 0x000044 0x000044 R 0x4
GNU_EH_FRAME 0x009a14 0x0000000000409a14 0x0000000000409a14 0x00030c 0x00030c R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
GNU_RELRO 0x00bc30 0x000000000060bc30 0x000000000060bc30 0x0003d0 0x0003d0 R 0x1
(snip)
$ eu-readelf -l /usr/lib/debug/usr/bin/cat.debug
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000400040 0x0000000000400040 0x0001f8 0x0001f8 R E 0x8
INTERP 0x000238 0x0000000000400238 0x0000000000400238 0x00001c 0x00001c R 0x1
[Requesting program interpreter: ]
LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x00ad14 0x00ad14 R E 0x200000
LOAD 0x00bc30 0x000000000060bc30 0x000000000060bc30 0x0006f0 0x001078 RW 0x200000
DYNAMIC 0x00bde8 0x000000000060bde8 0x000000000060bde8 0x0001d0 0x0001d0 RW 0x8
NOTE 0x000254 0x0000000000400254 0x0000000000400254 0x000044 0x000044 R 0x4
GNU_EH_FRAME 0x009a14 0x0000000000409a14 0x0000000000409a14 0x00030c 0x00030c R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
GNU_RELRO 0x00bc30 0x000000000060bc30 0x000000000060bc30 0x0003d0 0x0003d0 R 0x1
(snip)
$ ./extract-elf-section.sh .gnu_debugdata /usr/bin/cat cat.mdi.xz # script attached
$ xzdec cat.mdi.xz > cat.mdi
$ readelf -l cat.mdi
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000400060 0x0000000000400040 0x0001c0 0x0001c0 R E 0x8
INTERP 0x000218 0x0000000000400238 0x0000000000400238 0x000000 0x00001c R 0x1
[Requesting program interpreter: ]
LOAD 0x000000 0x0000000000400020 0x0000000000400000 0x000298 0x00ad14 R E 0x20
LOAD 0x0002b0 0x000000000060bc30 0x000000000060bc30 0x000000 0x001078 RW 0x20
DYNAMIC 0x0002b0 0x000000000060bde8 0x000000000060bde8 0x000000 0x0001d0 RW 0x8
NOTE 0x000274 0x0000000000400270 0x0000000000400254 0x000024 0x000024 R 0x4
GNU_EH_FRAME 0x000298 0x0000000000409a14 0x0000000000409a14 0x000000 0x00030c R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x8
(snip)
My problem is that the virtual address of the first LOAD segment changed.
Libunwind uses this value when resolving addresses to procedure names and
because the addresses in the symbol tables are the same in both debuginfo
files, the unexpected offset (of 0x20 here) causes it to return wrong result.
The addresses are changed by objcopy when removing sections and symbols
[2]. GDB doesn't seem to care. My question is, is the table supposed to
look like this and libunwind needs to be patched, or is it a bug? The
fact that the virtual address and physical address differ seems a bit
weird to me.
Cheers,
Martin Milata
[1] http://fedoraproject.org/wiki/Features/MiniDebugInfo
[2] http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: extract-elf-section.sh
Type: application/x-sh
Size: 403 bytes
Desc: not available
URL: <http://lists.fedoraproject.org/pipermail/devel/attachments/20130604/2d9d8696/attachment.sh>
More information about the devel
mailing list