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
extract-elf-section.sh
Description: Bourne shell script
-- devel mailing list [email protected] https://admin.fedoraproject.org/mailman/listinfo/devel
