I was able to reproduce it. clang and lldb are 17.0.5 versions installed via apk
.
/ # lldb
(lldb) target create --arch arm-*-*-eabihf --platform host /tmp/test.o
Current executable set to '/tmp/test.o' (arm).
(lldb) image list
[ 0] 372B6387-C6B8-B573-74C5-0D50E8A04AEC-596D3178 0x00000000 /tmp/test.o
So far so good. At least, probably, because ldd
shows:
/ # ldd /tmp/test.o
/lib/ld-musl-armhf.so.1 (0xf7f27000)
libc.musl-armv7.so.1 => /lib/ld-musl-armhf.so.1 (0xf7f27000)
But some of that is expected I think, as lldb hasn’t seen the dynamic loader run yet.
Side note: lldb /tmp/test.o
fails at run
. I couldn’t figure out why, but target create
seems to avoid whatever issue is causing that.
(lldb) b main
Breakpoint 1: where = test.o`main + 12 at test.c:1:14, address = 0x0000053c
(lldb) run
Process 412 launched: '/tmp/test.o' (arm)
<ctrl-c>
Process 412 stopped
* thread #1, name = 'test.o', stop reason = signal SIGSTOP
frame #0: 0x0040053c
-> 0x40053c: b 0x40053c
0x400540: .long 0xe8bdb501 ; unknown opcode
0x400544: ldrbmi r4, [r0, -r1]!
0x400548: andeq r0, r0, lr, lsr r0
(lldb) image list
error: the target has no associated executable images
Somehow process status
knows the name of the file, maybe that’s just the process’ name. But no images as you saw.
What’s odd is that memory region
is showing some image names.
(lldb) memory region --all
[0x0000000000000000-0x0000000000400000) ---
[0x0000000000400000-0x0000000000401000) r-x /tmp/test.o
[0x0000000000401000-0x0000000000402000) r-- /tmp/test.o
[0x0000000000402000-0x0000000000403000) rw- /tmp/test.o
[0x0000000000403000-0x0000000000404000) --- [heap]
[0x0000000000404000-0x0000000000405000) rw- [heap]
[0x0000000000405000-0x00000000f7f6b000) ---
[0x00000000f7f6b000-0x00000000f7f6c000) r-x [sigpage]
[0x00000000f7f6c000-0x00000000f7fed000) r-x /lib/ld-musl-armhf.so.1
[0x00000000f7fed000-0x00000000f7fef000) rw- /lib/ld-musl-armhf.so.1
[0x00000000f7fef000-0x00000000f7ff0000) rw-
[0x00000000f7ff0000-0x00000000fffcf000) ---
[0x00000000fffcf000-0x00000000ffff0000) rw- [stack]
[0x00000000ffff0000-0x00000000ffff1000) r-x [vectors]
[0x00000000ffff1000-0xffffffffffffffff) ---
I wonder if our hook into the dynamic loader is not working as expected. Looks like it could be.
(lldb) log enable lldb dyld
(lldb) target create --arch arm-*-*-eabihf --platform host /tmp/test.o
Current executable set to '/tmp/test.o' (arm).
(lldb) b main
Breakpoint 1: where = test.o`main + 12 at test.c:1:14, address = 0x0000053c
(lldb) run
DynamicLoaderDarwin::UseDYLDSPI: Use old DynamicLoader plugin
DynamicLoaderDarwin::UseDYLDSPI: Use old DynamicLoader plugin
DYLDRendezvous::UpdateExecutablePath cannot cache exe module path: null executable module pointer
DynamicLoaderPOSIXDYLD::DidLaunch()
This hook is what would tell us what the dynamic loader (ld-musl-armhf
) decided to load when the program is run. Though I am surprised that a problem there would make us discard the main program image as well.
I did fix an issue with the dynamic loader on 32 bit Arm recently, where lldb would discard symbol data for the dynamic loader itself. However that didn’t cause it to throw all the other images away.
I will try building the latest lldb and confirm whether this still happens.