Re: Help with debugging LD_PRELOADed shared C libraries

Thomas Ackermann
2006-07-13T18:55:47Z

Am Do 13.07.2006 19:40 schrieb Daniel Jacobowitz <drow@false.org>:
> It looks to me as if your kernel did not write out the _DYNAMIC
> segment
> for some reason. What does "readelf -l core" say? How about "readelf
> -l application"?

Did not know this command :)

Here´s the output, the one from the core ends with an error: "readelf:
Error: Unable to read in 0x78 bytes of dynamic section"
I think, this is the important part of below - beside the fact, that
your way of core-creation did not work :-|

readelf -l mybin

Elf file type is EXEC (Executable file)
Entry point 0x804a820
There are 5 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x08048034 0x08048034 0x000a0 0x000a0 R E 0x4
INTERP 0x0000d4 0x080480d4 0x080480d4 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
LOAD 0x000000 0x08048000 0x08048000 0x0ad47 0x0ad47 R E 0x1000
LOAD 0x00ad60 0x08053d60 0x08053d60 0x091f4 0x0b8c8 RW 0x1000
DYNAMIC 0x013eb4 0x0805ceb4 0x0805ceb4 0x000a0 0x000a0 RW 0x4

Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .hash .dynsym .dynstr .rel.got .rel.bss .rel.plt .init .plt
.text .fini .rodata
03 .data .gcc_except_table .eh_frame .ctors .dtors .got .dynamic .bss
04 .dynamic

Now the core:

readelf -l core

Elf file type is CORE (Core file)
Entry point 0x0
There are 99 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
NOTE 0x000c94 0x00000000 0x00000000 0x009d0 0x00000 0
LOAD 0x002000 0x08048000 0x00000000 0x00000 0x0b000 R E 0x1000
LOAD 0x002000 0x08053000 0x00000000 0x0a000 0x0a000 RWE 0x1000
LOAD 0x00c000 0x0805d000 0x00000000 0x23ec000 0x23ec000 RWE 0x1000
LOAD 0x23f8000 0x40000000 0x00000000 0x00000 0x16000 R E 0x1000
LOAD 0x23f8000 0x40016000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x23fa000 0x40018000 0x00000000 0x00000 0x02000 R E 0x1000
LOAD 0x23fa000 0x4001a000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0x23fb000 0x4001b000 0x00000000 0x00000 0x01000 R E 0x1000
LOAD 0x23fb000 0x4001c000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0x23fc000 0x4001d000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0x23fd000 0x4001e000 0x00000000 0x00000 0x01000 R E 0x1000
LOAD 0x23fd000 0x4001f000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0x23fe000 0x40020000 0x00000000 0x00000 0x01000 R E 0x1000
LOAD 0x23fe000 0x40021000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x2400000 0x4002d000 0x00000000 0x00000 0x02000 R E 0x1000
LOAD 0x2400000 0x4002f000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x2402000 0x40031000 0x00000000 0x00000 0x0e000 R E 0x1000
LOAD 0x2402000 0x4003f000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x2404000 0x40041000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x2406000 0x40043000 0x00000000 0x00000 0x21000 R E 0x1000
LOAD 0x2406000 0x40064000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x2408000 0x40066000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0x2409000 0x40067000 0x00000000 0x00000 0x10f000 R E 0x1000
LOAD 0x2409000 0x40176000 0x00000000 0x00000 0x01000 0x1000
LOAD 0x2409000 0x40177000 0x00000000 0x00000 0x01000 R E 0x1000
LOAD 0x2409000 0x40178000 0x00000000 0x03000 0x03000 RWE 0x1000
LOAD 0x240c000 0x4017b000 0x00000000 0x03000 0x03000 RWE 0x1000
LOAD 0x240f000 0x4017e000 0x00000000 0x00000 0xd4000 R E 0x1000
LOAD 0x240f000 0x40252000 0x00000000 0x1b000 0x1b000 RWE 0x1000
LOAD 0x242a000 0x4026d000 0x00000000 0x499000 0x499000 RWE 0x1000
LOAD 0x28c3000 0x40706000 0x00000000 0x00000 0x8c000 R E 0x1000
LOAD 0x28c3000 0x40792000 0x00000000 0x2a000 0x2a000 RWE 0x1000
LOAD 0x28ed000 0x407bc000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0x28ee000 0x407bd000 0x00000000 0x00000 0x1aa000 R E 0x1000
LOAD 0x28ee000 0x40967000 0x00000000 0x47000 0x47000 RWE 0x1000
LOAD 0x2935000 0x409ae000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0x2937000 0x409b0000 0x00000000 0x00000 0x1f000 R E 0x1000
LOAD 0x2937000 0x409cf000 0x00000000 0x0b000 0x0b000 RWE 0x1000
LOAD 0x2942000 0x409da000 0x00000000 0x05000 0x05000 RWE 0x1000
LOAD 0x2947000 0x409f1000 0x00000000 0x8084000 0x8084000 RWE 0x1000
LOAD 0xa9cb000 0x48c59000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xa9cc000 0x48c5b000 0x00000000 0x00000 0x03000 R E 0x1000
LOAD 0xa9cc000 0x48c5e000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xa9cd000 0x48c5f000 0x00000000 0x00000 0x0e000 R E 0x1000
LOAD 0xa9cd000 0x48c6d000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xa9ce000 0x48c6e000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xa9cf000 0x4969d000 0x00000000 0x00000 0x08000 R E 0x1000
LOAD 0xa9cf000 0x496a5000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0xa9d1000 0x496a7000 0x00000000 0x00000 0xc5000 R E 0x1000
LOAD 0xa9d1000 0x4976c000 0x00000000 0x0b000 0x0b000 RWE 0x1000
LOAD 0xa9dc000 0x49777000 0x00000000 0x72000 0x72000 RWE 0x1000
LOAD 0xaa4e000 0x497e9000 0x00000000 0x00000 0x110000 R E 0x1000
LOAD 0xaa4e000 0x498f9000 0x00000000 0x33000 0x33000 RWE 0x1000
LOAD 0xaa81000 0x4992c000 0x00000000 0x43000 0x43000 RWE 0x1000
LOAD 0xaac4000 0x4996f000 0x00000000 0x00000 0x37000 R E 0x1000
LOAD 0xaac4000 0x499a6000 0x00000000 0x10000 0x10000 RWE 0x1000
LOAD 0xaad4000 0x499b6000 0x00000000 0x0e000 0x0e000 RWE 0x1000
LOAD 0xaae2000 0x499c4000 0x00000000 0x00000 0x45000 R E 0x1000
LOAD 0xaae2000 0x49a09000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0xaae4000 0x49a0b000 0x00000000 0x00000 0x09000 R E 0x1000
LOAD 0xaae4000 0x49a14000 0x00000000 0x05000 0x05000 RWE 0x1000
LOAD 0xaae9000 0x49a19000 0x00000000 0x17000 0x17000 RWE 0x1000
LOAD 0xab00000 0x49a31000 0x00000000 0x00000 0x07000 R E 0x1000
LOAD 0xab00000 0x49a38000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xab01000 0x49a39000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xab02000 0x49a3a000 0x00000000 0x00000 0x13000 R E 0x1000
LOAD 0xab02000 0x49a4d000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xab03000 0x49a4e000 0x00000000 0x03000 0x03000 RWE 0x1000
LOAD 0xab06000 0x49a51000 0x00000000 0x00000 0x28000 R E 0x1000
LOAD 0xab06000 0x49a79000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xab07000 0x49a7a000 0x00000000 0x03000 0x03000 RWE 0x1000
LOAD 0xab0a000 0x49a7d000 0x00000000 0x00000 0x45000 R E 0x1000
LOAD 0xab0a000 0x49ac2000 0x00000000 0xdc000 0xdc000 RWE 0x1000
LOAD 0xabe6000 0x49b9e000 0x00000000 0x06000 0x06000 RWE 0x1000
LOAD 0xabec000 0x49bae000 0x00000000 0x00000 0x10000 R E 0x1000
LOAD 0xabec000 0x49bbe000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xabed000 0x49bcf000 0x00000000 0x00000 0x09000 R E 0x1000
LOAD 0xabed000 0x49bd8000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xabee000 0x49bd9000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xabef000 0x49bda000 0x00000000 0x00000 0x0c000 R E 0x1000
LOAD 0xabef000 0x49be6000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xabf0000 0x49be7000 0x00000000 0x69000 0x69000 RWE 0x1000
LOAD 0xac59000 0x49c50000 0x00000000 0x00000 0x7f000 R E 0x1000
LOAD 0xac59000 0x49ccf000 0x00000000 0x38000 0x38000 RWE 0x1000
LOAD 0xac91000 0x49d07000 0x00000000 0xc1000 0xc1000 RWE 0x1000
LOAD 0xad52000 0x49dd2000 0x00000000 0x00000 0x3a000 R E 0x1000
LOAD 0xad52000 0x49e0c000 0x00000000 0x11000 0x11000 RWE 0x1000
LOAD 0xad63000 0x49e1d000 0x00000000 0x29000 0x29000 RWE 0x1000
LOAD 0xad8c000 0x49f24000 0x00000000 0x01000 0x01000 RWE 0x1000
LOAD 0xad8d000 0x49f2e000 0x00000000 0x00000 0x04000 R E 0x1000
LOAD 0xad8d000 0x49f32000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0xad8f000 0x49f34000 0x00000000 0x00000 0x0f000 R E 0x1000
LOAD 0xad8f000 0x49f43000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0xad91000 0x49f45000 0x00000000 0x02000 0x02000 RWE 0x1000
LOAD 0xad93000 0xbffa4000 0x00000000 0x5c000 0x5c000 RWE 0x1000
LOAD 0xadef000 0xffffe000 0x00000000 0x01000 0x01000 R E 0x1000
DYNAMIC 0xadef578 0xffffe578 0x00000000 0x00078 0x00078 R 0x4
GNU_EH_FRAME 0xadef448 0xffffe448 0x00000000 0x00024 0x00024 R 0x4
readelf: Error: Unable to read in 0x78 bytes of dynamic section

And this is from the shared lib:

readelf -l mylib.so

Elf file type is DYN (Shared object file)
Entry point 0xb20
There are 4 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x016dc 0x016dc R E 0x1000
LOAD 0x0016dc 0x000026dc 0x000026dc 0x005b4 0x005e8 RW 0x1000
DYNAMIC 0x0016f0 0x000026f0 0x000026f0 0x000c8 0x000c8 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4

Section to Segment mapping:
Segment Sections...
00 .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt
.init .plt .text .fini .rodata .eh_frame
01 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
02 .dynamic
03

> cat&
> killall -ABRT <pid of cat>

Hmm...

Does not work:

austria:~ # cat&
[1] 20914
austria:~ # killall -ABRT 20914
20914: no process killed

[1]+ Stopped cat

But the application does create a core-file :-/

austria:~ # ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 8063
virtual memory (kbytes, -v) unlimited