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

tests/hello: aarch64: segvfault when apply patch-add-vars.ulp #6

Open
Rtoax opened this issue Mar 2, 2024 · 1 comment
Open

tests/hello: aarch64: segvfault when apply patch-add-vars.ulp #6

Rtoax opened this issue Mar 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Rtoax
Copy link
Owner

Rtoax commented Mar 2, 2024

apply $ ./test.sh -u patch-add-vars.ulp segvfault

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

Rtoax commented Mar 2, 2024

The original disassmbler

(gdb) disassemble print_hello
Dump of assembler code for function print_hello:
   0x00000055709e098c <+0>:	stp	x29, x30, [sp, #-32]!
   0x00000055709e0990 <+4>:	mov	x29, sp
   0x00000055709e0994 <+8>:	str	x0, [sp, #24]
   0x00000055709e0998 <+12>:	ldr	x0, [sp, #24]
   0x00000055709e099c <+16>:	bl	0x55709e0954 <internal_print_hello>
   0x00000055709e09a0 <+20>:	nop
   0x00000055709e09a4 <+24>:	ldp	x29, x30, [sp], #32
   0x00000055709e09a8 <+28>:	ret
End of assembler dump.

Apply ulpatch

rongtao@rpi5:~/Git/ulpatch/tests/hello$ ./test.sh -u patch-pthread.ulp
Already install ulpatch
make: Nothing to be done for 'build'.
Wrong ELF magic
Out of rang.
Out of rang.
Out of rang.
Out of rang.
Out of rang.
55709e0000-55709e1000 r-xp 00000000 b3:02 1049687                        /home/rongtao/Git/ulpatch/tests/hello/hello
55709e1000-55709e3000 rwxs 00000000 b3:02 2586908                        /tmp/ulpatch/6528/map_files/patch-IvyobT
55709ff000-5570a00000 r--p 0000f000 b3:02 1049687                        /home/rongtao/Git/ulpatch/tests/hello/hello
5570a00000-5570a01000 rw-p 00010000 b3:02 1049687                        /home/rongtao/Git/ulpatch/tests/hello/hello
55a39f7000-55a3a18000 rw-p 00000000 00:00 0                              [heap]
7fa7dd0000-7fa7de0000 ---p 00000000 00:00 0 
7fa7de0000-7fa85e0000 rw-p 00000000 00:00 0 
7fa85e0000-7fa85f0000 ---p 00000000 00:00 0 
7fa85f0000-7fa8df0000 rw-p 00000000 00:00 0 
7fa8df0000-7fa8e00000 ---p 00000000 00:00 0 
7fa8e00000-7fa9600000 rw-p 00000000 00:00 0 
7fa9600000-7fa9787000 r-xp 00000000 b3:02 139433                         /usr/lib/aarch64-linux-gnu/libc.so.6
7fa9787000-7fa979c000 ---p 00187000 b3:02 139433                         /usr/lib/aarch64-linux-gnu/libc.so.6
7fa979c000-7fa97a0000 r--p 0018c000 b3:02 139433                         /usr/lib/aarch64-linux-gnu/libc.so.6
7fa97a0000-7fa97a2000 rw-p 00190000 b3:02 139433                         /usr/lib/aarch64-linux-gnu/libc.so.6
7fa97a2000-7fa97af000 rw-p 00000000 00:00 0 
7fa97c7000-7fa97ee000 r-xp 00000000 b3:02 139430                         /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
7fa9800000-7fa9802000 rw-p 00000000 00:00 0 
7fa9802000-7fa9804000 r--p 00000000 00:00 0                              [vvar]
7fa9804000-7fa9805000 r-xp 00000000 00:00 0                              [vdso]
7fa9805000-7fa9807000 r--p 0002e000 b3:02 139430                         /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
7fa9807000-7fa9809000 rw-p 00030000 b3:02 139430                         /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
7fc9944000-7fc9965000 rw-p 00000000 00:00 0                              [stack]
NUM      DATE                 VMA_ADDR         TARGET_FUNC     
1        2024/03/02 14:44:52  55709e1000       print_hello

Coredump

rongtao@rpi5:~/Git/ulpatch/tests/hello$ ./hello
print_hello                     : 0x000000709e098c
puts                            : 0x000000a966c7b0
Hello World. 0, 255
Hello World. 1, 255
Hello World. 2, 255
Hello World. 3, 255
Hello World. 4, 255
Hello World. 5, 255
Hello World. 6, 255
Hello World. 7, 255
Hello World. 8, 255
Hello World. 9, 255
Hello World. 10, 255
Hello World. 11, 255
Hello World. 12, 255
Hello World. 13, 255
Hello World. 14, 255
Hello World. 15, 255
Hello World. 16, 255
Hello World. 16, 255
Hello World. 18, 255
Hello World. 19, 255
Hello World. 20, 255
Hello World. 21, 255
Hello World. 21, 255
Hello World. 21, 255
Segmentation fault (core dumped)

Check coredump

rongtao@rpi5:~/Git/ulpatch/tests/hello$ gdb -q ./hello core.6528
Reading symbols from ./hello...
[New LWP 6531]
[New LWP 6529]
[New LWP 6528]
[New LWP 6530]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
Core was generated by `./hello'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000055709e109c in ?? ()
[Current thread is 1 (Thread 0x7fa85df180 (LWP 6531))]
(gdb) disassemble print_hello 
Dump of assembler code for function print_hello:
   0x00000055709e098c <+0>:	ldr	x17, 0x55709e0994 <print_hello+8>
   0x00000055709e0990 <+4>:	br	x17
   0x00000055709e0994 <+8>:	adr	x8, 0x557091cba7
   0x00000055709e0998 <+12>:	udf	#85
   0x00000055709e099c <+16>:	bl	0x55709e0954 <internal_print_hello>
   0x00000055709e09a0 <+20>:	nop
   0x00000055709e09a4 <+24>:	ldp	x29, x30, [sp], #32
   0x00000055709e09a8 <+28>:	ret
End of assembler dump.

image

@Rtoax Rtoax self-assigned this Apr 14, 2024
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