[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging
Greg Clayton via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 30 13:05:46 PST 2020
clayborg added a comment.
In D72751#1848880 <https://reviews.llvm.org/D72751#1848880>, @labath wrote:
> In D72751#1847617 <https://reviews.llvm.org/D72751#1847617>, @clayborg wrote:
>
> > Yes the current approach allows anyone to load any section at any address. On Darwin systems, the DYLD shared cache will move __TEXT, __DATA, and other sections around such that all __TEXT sections from all shared libraries in the shared cache are all in the one contiguous range. The slide is different for each section, so we have some nice flexibility with being able to set the section load address individually. They will even invert the memory order sometimes where in the file we have __TEXT followed by __DATA, but in the shared cache __DATA appears at a lower address than __TEXT.
>
>
> Sorry about the off-topic, but I found this bit very interesting. Greg, how does this work with code referencing the variables in the data section (e.g. `static int x; int *f() { return &x; }`). This code on elf, even when linked in fully position-independent mode will not contain any relocations because it is assumed that the dynamic loader will not change the relative layout of code and data (and so the code can use pc-relative addressing). This obviously does not work if data can be moved around independently. Does that mean that darwin will include some additional relocations which need to be resolved at load time?
No, the relocations are performed when the shared cache is made and they are removed! This also works for PLT calls from one shared library to another. If two shared libraries have PLT entries to each other's functions, those are resolved and don't require a call to the dynamic loader! There are two shared caches: one for running only and one for development. The development shared caches leave PLT entries alone so that interposing can happen.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72751/new/
https://reviews.llvm.org/D72751
More information about the lldb-commits
mailing list