You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After this you will be left with only the following sections: `NULL`, `.text`, `.symtab`, `.strtab`, `.shstrtab`, which you can verify with `readelf -S thing.syms`.
30
+
You can test that this does in fact work with LLDB:
31
+
```bash
32
+
~❯ lldb thing.nosyms
33
+
(lldb) target create "thing.nosyms"
34
+
Current executable set to '/thing.nosyms' (x86_64).
35
+
(lldb) b main
36
+
Breakpoint 1: no locations (pending).
37
+
WARNING: Unable to resolve breakpoint to any actual locations.
Clearly the breakpoint was set at the wrong place, and it doesn't stop when it should.
68
+
69
+
## The program header table
70
+
By playing around and comparing the ELF that niche-elf generates versus the one generated like above, I figured out that the problem for LLDB is the lack of a program header table. I added this table and have a working LLDB setup which you can look at on the `lldb-support` branch.
71
+
72
+
There are lots of hardcoded values on that branch so it won't work in general but if you set the proper values (same as in the reference binary, `thing.syms`) it does work.
73
+
74
+
There are two huge problems though:
75
+
1. It doesn't work with GDB for some reason
76
+
2. The text segment program header requires a precise `p_memsz` value.
77
+
78
+
Regarding the second point: I took this value from `thing.syms`, and using any other value than exactly that one, makes LLDB not work (breakpoints don't work). The problem is that, that value is not even the same one as in`thing` nor `thing.syms` (0x521 in my case). Somehow, `objcopy` sets it (to 0x4a2 in my case), and I don't know based on what. As such, I literarly cannot produce a binary that works for LLDB given an original ELF without invoking `objcopy` (and not invoking `objcopy` is kinda the point of niche-elf).
79
+
80
+
I am tired of essentially black-box fuzzing GDB's and LLDB's ELF parsers, so I think the only feasible solution at this point is using the JSON solution if we want to support LLDB.
0 commit comments