Issue |
153772
|
Summary |
[lldb] Duplicate module listing when zero page is mapped
|
Labels |
new issue
|
Assignees |
|
Reporter |
nevesnunes
|
# Description
When debugging a target with a memory mapping loaded in the zero page, the module has a duplicated listing at the start of the zero page.
Some actions, such as loading symbols, will throw errors due to matching multiple (duplicated) modules.
# Steps to reproduce
Source file `a.c`:
```c
int main() {
return 0;
}
```
Linker script `a.ld`:
```ld
OUTPUT_FORMAT(elf64-x86-64)
MEMORY
{
ram (rw) : ORIGIN = 0x100, LENGTH = 0x40000
rom (rx) : ORIGIN = 0x400100, LENGTH = 0x40000
}
SECTIONS
{
.data : { FILL(0x00) . += 1K; } > ram
.text : { *(.text) } > rom
/DISCARD/ : { *(.comment) *(.eh_frame*) }
}
```
`Dockerfile`:
```Dockerfile
FROM debian:bookworm-20250811-slim
RUN apt-get -y update \
&& apt-get install -y gnupg lsb-release software-properties-common wget \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod +x /llvm.sh \
&& /llvm.sh 20
```
Set minimum virtual address to allow mapping zero page, compile, and debug:
```sh
echo 0 | sudo tee /proc/sys/vm/mmap_min_addr
clang-20 -O0 -static -nostdlib -c a.c
ld a.o -T a.ld --build-id
lldb-20 a.out --one-line 'process launch --stop-at-entry' --one-line 'image list' --one-line 'image dump sections a.out'
```
# Current behaviour
```
(lldb) target create "a.out"
Current executable set to '/share/a.out' (x86_64).
(lldb) process launch --stop-at-entry
Process 278 launched: '/share/a.out' (x86_64)
(lldb) image list
[ 0] CF0C15EC-96E1-0F70-F2D9-8F6BB9CC9491-4BA4B4D4 0x0000000000000000 /share/a.out
[ 1] CF0C15EC-96E1-0F70-F2D9-8F6BB9CC9491-4BA4B4D4 0x0000000000000000 /share/a.out
[ 2] 2B3312B1-A6A1-6808-B9C9-5675682C1430-19E065E3 0x00007ffff7ffd000 [vdso] (0x00007ffff7ffd000)
(lldb) image dump sections a.out
Sections for '/share/a.out' (x86_64):
SectID Type Load Address Perm File Off. File Size Flags Section Name
------------------ ---------------------- --------------------------------------- ---- ---------- ---------- ---------- ----------------------------
0xffffffffffffffff container [0x0000000000000000-0x0000000000000424) rw- 0x00001100 0x00000024 0x00000000 a.out.PT_LOAD[0]
0x0000000000000001 regular [0x0000000000000000-0x0000000000000024) r-- 0x00001100 0x00000024 0x00000002 a.out.PT_LOAD[0]..note.gnu.build-id
0x0000000000000002 zero-fill [0x0000000000000024-0x0000000000000424) rw- 0x00001124 0x00000000 0x00000003 a.out.PT_LOAD[0]..data
0xfffffffffffffffe container [0x0000000000400000-0x000000000040000f) r-x 0x00002100 0x0000000f 0x00000000 a.out.PT_LOAD[1]
0x0000000000000003 code [0x0000000000400000-0x000000000040000f) r-x 0x00002100 0x0000000f 0x00000006 a.out.PT_LOAD[1]..text
0x0000000000000004 elf-symbol-table --- 0x00002110 0x00000048 0x00000000 a.out..symtab
0x0000000000000005 regular --- 0x00002158 0x0000000a 0x00000000 a.out..strtab
0x0000000000000006 regular --- 0x00002162 0x0000003a 0x00000000 a.out..shstrtab
```
Attempting to load symbols and sections:
```
(lldb) target symbols add a.out
error: multiple modules match symbol file '/share/a.out', use the --uuid option to resolve the ambiguity.
(lldb) target modules load --uuid CF0C15EC-96E1-0F70-F2D9-8F6BB9CC9491-4BA4B4D4 .data 0x900000
/share/a.out
/share/a.out
error: multiple modules match uuid=CF0C15EC-96E1-0F70-F2D9-8F6BB9CC9491-4BA4B4D4:
```
If we update `a.ld` to set an origin after the zero page:
```diff
- ram (rw) : ORIGIN = 0x100, LENGTH = 0x40000
+ ram (rw) : ORIGIN = 0x1100, LENGTH = 0x40000
```
We only get a single listing for this module:
```
# lldb-20 a.0x001100.out --one-line 'process launch --stop-at-entry' --one-line 'image list' --one-line 'image dump sections a.0x001100.out'
(lldb) target create "a.0x001100.out"
Current executable set to '/share/a.0x001100.out' (x86_64).
(lldb) process launch --stop-at-entry
Process 301 launched: '/share/a.0x001100.out' (x86_64)
(lldb) image list
[ 0] 602155C1-95B3-20A7-A847-61D93C19D0D3-BD2685ED 0x0000000000001100 /share/a.0x001100.out
[ 1] 2B3312B1-A6A1-6808-B9C9-5675682C1430-19E065E3 0x00007ffff7ffd000 [vdso] (0x00007ffff7ffd000)
(lldb) image dump sections a.0x001100.out
Sections for '/share/a.0x001100.out' (x86_64):
SectID Type Load Address Perm File Off. File Size Flags Section Name
------------------ ---------------------- --------------------------------------- ---- ---------- ---------- ---------- ----------------------------
0xffffffffffffffff container [0x0000000000001100-0x0000000000001524) rw- 0x00001100 0x00000024 0x00000000 a.0x001100.out.PT_LOAD[0]
0x0000000000000001 regular [0x0000000000001100-0x0000000000001124) r-- 0x00001100 0x00000024 0x00000002 a.0x001100.out.PT_LOAD[0]..note.gnu.build-id
0x0000000000000002 zero-fill [0x0000000000001124-0x0000000000001524) rw- 0x00001124 0x00000000 0x00000003 a.0x001100.out.PT_LOAD[0]..data
0xfffffffffffffffe container [0x0000000000400100-0x000000000040010f) r-x 0x00002100 0x0000000f 0x00000000 a.0x001100.out.PT_LOAD[1]
0x0000000000000003 code [0x0000000000400100-0x000000000040010f) r-x 0x00002100 0x0000000f 0x00000006 a.0x001100.out.PT_LOAD[1]..text
0x0000000000000004 elf-symbol-table --- 0x00002110 0x00000048 0x00000000 a.0x001100.out..symtab
0x0000000000000005 regular --- 0x00002158 0x0000000a 0x00000000 a.0x001100.out..strtab
0x0000000000000006 regular --- 0x00002162 0x0000003a 0x00000000 a.0x001100.out..shstrtab
```
# Expected behaviour
In either case, we should have a single listing for the loaded module, or a workaround that allows us to desambiguate a module by index.
# Context
```
# uname -a
Linux 888ad4154b71 6.1.0-35-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.137-1 (2025-05-07) x86_64 GNU/Linux
# clang-20 --version
Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
# ld --version
GNU ld (GNU Binutils for Debian) 2.40
# lldb-20 --version
lldb version 20.1.8
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs