Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu23.04/x86_64: /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2: unable to find lowest load address. #15

Closed
Rtoax opened this issue May 7, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Rtoax
Copy link
Owner

Rtoax commented May 7, 2024

See also #14

@Rtoax Rtoax added the bug Something isn't working label May 7, 2024
@Rtoax
Copy link
Owner Author

Rtoax commented May 7, 2024

ulpatch/tests/hello$ sudo ./test.sh -u patch-pthread.ulp -d
...
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from , addr 7f0cd6b75000
15:29:11 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from , addr 7f0cd6b8c000
15:29:11 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2, addr 7f0cd6b8e000
15:29:11 [DEBUG][task.c vma_peek_phdr:451] 7f0cd6b8e000 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 is ELF
15:29:11 [DEBUG][task.c vma_peek_phdr:500] peek phdr from target addr 7f0cd6b8e040, len 616
15:29:11 [DEBUG][task.c vma_peek_phdr:578] Get /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 voffset 1000
15:29:11 [DEBUG][task.c vma_peek_phdr:578] Get /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 voffset 29000
15:29:11 [DEBUG][task.c vma_peek_phdr:578] Get /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 voffset 33a20
15:29:11 [ INFO][task.c vma_peek_phdr:628] /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 vma start 7f0cd6b8e000, load_offset 7f0cd6b8e000
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2, addr 7f0cd6b8f000
15:29:11 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2, addr 7f0cd6bb7000
15:29:11 [DEBUG][task.c vma_peek_phdr:451] 7f0cd6bb7000 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 is ELF
15:29:11 [DEBUG][task.c vma_peek_phdr:500] peek phdr from target addr 7f0cd6bb7016, len 504
15:29:11 [ERROR][task.c vma_peek_phdr:591][Bad file descriptor] /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2: unable to find lowest load address.
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2, addr 7f0cd6bc1000
15:29:11 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2, addr 7f0cd6bc3000
15:29:11 [DEBUG][ehdr.c ehdr_magic_ok:20] Wrong ELF magic
15:29:11 [ WARN][task.c vma_peek_phdr:416] not support stack
15:29:11 [ WARN][task.c vma_peek_phdr:416] not support vvar
15:29:11 [DEBUG][task.c vma_peek_phdr:438] Peek a phdr from [vdso], addr 7ffc6afa2000
15:29:11 [DEBUG][task.c vma_peek_phdr:451] 7ffc6afa2000 [vdso] is ELF
15:29:11 [DEBUG][task.c vma_peek_phdr:500] peek phdr from target addr 7ffc6afa2040, len 224
15:29:11 [ INFO][task.c vma_peek_phdr:628] [vdso] vma start 7ffc6afa2000, load_offset 7ffc6afa2000
15:29:11 [ WARN][task.c vma_peek_phdr:416] not support vsyscall
15:29:11 [DEBUG][task.c load_self_vma_symbols:731] hello undef symbol: sleep 0
15:29:11 [DEBUG][task.c load_self_vma_symbols:731] hello undef symbol: sleep@GLIBC_2.2.5 0
15:29:11 [DEBUG][task.c load_self_vma_symbols:731] hello undef symbol: signal 0
15:29:11 [DEBUG][task.c load_self_vma_symbols:731] hello undef symbol: signal@GLIBC_2.2.5 0
15:29:11 [DEBUG][task.c load_self_vma_symbols:744] SELF routine 127f
15:29:11 [DEBUG][task.c task_vma_link_symbol:707] hello: add symbol routine addr 127f success.
15:29:11 [DEBUG][task.c load_self_vma_symbols:744] SELF sig_handler 11f9
15:29:11 [DEBUG][task.c task_vma_link_symbol:707] hello: add symbol sig_handler addr 11f9 success.
15:29:11 [DEBUG][task.c load_self_vma_symbols:731] hello undef symbol: puts 0
15:29:11 [DEBUG][task.c load_self_vma_symbols:731] hello undef symbol: puts@GLIBC_2.2.5 0

@Rtoax Rtoax self-assigned this May 7, 2024
@Rtoax
Copy link
Owner Author

Rtoax commented May 7, 2024

/proc/PID/maps

$ cat /proc/$(pidof hello)/maps
561a233d9000-561a233da000 r--p 00000000 fc:02 798333                     /home/rongtao/Git/ulpatch/tests/hello/hello
561a233da000-561a233db000 r-xp 00001000 fc:02 798333                     /home/rongtao/Git/ulpatch/tests/hello/hello
561a233db000-561a233dc000 r--p 00002000 fc:02 798333                     /home/rongtao/Git/ulpatch/tests/hello/hello
561a233dc000-561a233dd000 r--p 00002000 fc:02 798333                     /home/rongtao/Git/ulpatch/tests/hello/hello
561a233dd000-561a233de000 rw-p 00003000 fc:02 798333                     /home/rongtao/Git/ulpatch/tests/hello/hello
561a23425000-561a23446000 rw-p 00000000 00:00 0                          [heap]
7f6a499fd000-7f6a499fe000 ---p 00000000 00:00 0 
7f6a499fe000-7f6a4a1fe000 rw-p 00000000 00:00 0 
7f6a4a1fe000-7f6a4a1ff000 ---p 00000000 00:00 0 
7f6a4a1ff000-7f6a4a9ff000 rw-p 00000000 00:00 0 
7f6a4a9ff000-7f6a4aa00000 ---p 00000000 00:00 0 
7f6a4aa00000-7f6a4b200000 rw-p 00000000 00:00 0 
7f6a4b200000-7f6a4b222000 r--p 00000000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7f6a4b222000-7f6a4b39a000 r-xp 00022000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7f6a4b39a000-7f6a4b3f2000 r--p 0019a000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7f6a4b3f2000-7f6a4b3f6000 r--p 001f1000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7f6a4b3f6000-7f6a4b3f8000 rw-p 001f5000 fc:02 4325769                    /usr/lib/x86_64-linux-gnu/libc.so.6
7f6a4b3f8000-7f6a4b405000 rw-p 00000000 00:00 0 
7f6a4b5be000-7f6a4b5c1000 rw-p 00000000 00:00 0 
7f6a4b5d5000-7f6a4b5d7000 rw-p 00000000 00:00 0 
7f6a4b5d7000-7f6a4b5d8000 r--p 00000000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f6a4b5d8000-7f6a4b600000 r-xp 00001000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f6a4b600000-7f6a4b60a000 r--p 00029000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f6a4b60a000-7f6a4b60c000 r--p 00033000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f6a4b60c000-7f6a4b60e000 rw-p 00035000 fc:02 4325753                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7ffe432cd000-7ffe432ee000 rw-p 00000000 00:00 0                          [stack]
7ffe433bc000-7ffe433c0000 r--p 00000000 00:00 0                          [vvar]
7ffe433c0000-7ffe433c2000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]

ultask

$ sudo ultask -p $(pidof hello) --dump-vma 7f6a4b600000-7f6a4b60a000 -o a.elf
/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2: unable to find lowest load address(ffffffffffffffff).
      TYPE:            Start              End   Perm Role
                       pgoff          Voffset Name
        ld: 00007f6a4b600000-00007f6a4b60a000   r--p E-P-
            0000000000029000 0000000000029000 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
            load_offset = 0x0
ELF Header:
 Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
 Class:                             ELF64
 Data:                              2's complement, little endian
 Version:                           1 (current)
 OS/ABI:                            UNIX - System V
 ABI Version:                       0
 Type:                              No file type
 Machine:                           No machine type
 Version:                           0x0
 Entry point address:               0x0
 Start of program headers:          22 (bytes into file)
 Start of section headers:          26 (bytes into file)
 Flags:                             0x5
 Size of this header:               0 (bytes)
 Size of program headers:           0 (bytes)
 Number of program headers:         9
 Size of section headers:           0 (bytes)
 Number of section headers:         0
 Section header string table index: 0

hexdump

$ hexdump -C a.elf | more
00000000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  16 00 00 00 00 00 00 00  1a 00 00 00 00 00 00 00  |................|
00000030  05 00 00 00 00 00 00 00  09 00 00 00 00 00 00 00  |................|
00000040  2f 6c 69 62 2f 78 38 36  5f 36 34 2d 6c 69 6e 75  |/lib/x86_64-linu|
00000050  78 2d 67 6e 75 2f 00 2f  75 73 72 2f 6c 69 62 2f  |x-gnu/./usr/lib/|
00000060  78 38 36 5f 36 34 2d 6c  69 6e 75 78 2d 67 6e 75  |x86_64-linux-gnu|
00000070  2f 00 2f 6c 69 62 2f 00  2f 75 73 72 2f 6c 69 62  |/./lib/./usr/lib|

Thus

Thus, the 7f6a4b600000-7f6a4b60a000 vma is Bad ELF, we should skip it.

Rtoax added a commit that referenced this issue May 7, 2024
Just as link [0] says, this commit fix it.

[0] #15

Signed-off-by: Rong Tao <rongtao@cestc.cn>
@Rtoax
Copy link
Owner Author

Rtoax commented May 7, 2024

Fixed in fc6b00f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant