On 10/23/24 07:46, Ilya Leoshkevich wrote:
When debugging qemu-user processes using gdbstub, the following warning
appears every time:
warning: BFD: warning: system-supplied DSO at 0x7f8253cc3000 has a corrupt
string table index
The reason is that QEMU does not map the VDSO's section headers. The
VDSO's ELF header's e_shoff points to zeros, which GDB fails to parse.
Interesting. I had wondered where this came from, but never looked.
- Fix up VDSO's PHDR size in gen-vdso. This is the simplest solution,
so do it. The only tricky part is byte-swaps: they need to be either
done on local copies or in-place, and then reverted in the end. To
preserve the existing code structure, do the former for Sym and Dyn,
and the latter for Ehdr, Phdr, and Shdr.
Or adjust the linker script, to mark those sections loaded.
This may or may not be easier, considering the rest of the changes.
@@ -154,6 +161,16 @@ static void elfN(process)(FILE *outf, void *buf, bool
need_bswap)
fprintf(stderr, "LOAD segment not loaded at address 0\n");
errors++;
}
+ /*
+ * Extend the program header to cover the entire VDSO, so that
+ * load_elf_vdso() loads everything, including section headers.
+ */
+ if (len > phdr[i].p_filesz) {
+ phdr[i].p_filesz = len;
+ }
+ if (len > phdr[i].p_memsz) {
+ phdr[i].p_memsz = len;
+ }
There should be no .bss, so these two numbers had better be identical. Certainly this
adjustment *requires* that there be no .bss. I think we should error out if the two
numbers differ.
r~