summaryrefslogtreecommitdiff
path: root/linker/linker_wrapper.cpp
AgeCommit message (Collapse)Author
2018-10-22Rework the linker_wrapper to work with lldDan Willemsen
This is use by Host Bionic to bootstrap into an embedded copy of the linker by tweaking the AT_* values before calling in to the linker entry. Similarly to 9729f35922aee4d1662b97d62d82385f6b8124ef, get the base address from AT_PHDR, so that we're not relying on the relative offset before relocation, which doesn't work with lld (at least with the standard flags). To find the offset to the linker code, we can still use an absolute symbol created by extract_linker (which is currently hardcoded to 0x1000). Instead of relying on something similar for the linker entry point, we're now just reading the entry point from the linker's ELF header. Then we get the address to the real _start function using host_bionic_inject, which injects the value into a global variable after the link step is finished. It also uses that opportunity to verify that the linker is embedded as we expect it to be. Bug: 31559095 Test: build with host bionic Change-Id: I9d81ea77c51c079de06905da1ebe421fead1dc3b
2017-09-20Use an embedded linker for host bionicDan Willemsen
The linux kernel requires that the ELF interpreter (runtime linker) that's referenced by PT_INTERP be either an absolute path, or a relative path from the current working directory. We'd prefer a relative path from the binary, similarly to how we handle looking up shared libraries, but that's not supported. Instead, extract the LOAD segments from the runtime linker ELF binary and embed them into each host bionic binary, omitting the PT_INTERP declaration. The kernel will treat it as a static binary, and we'll use a special entry point (linker_wrapper) to fix up the arguments passed by the kernel before jumping to the embedded linker. From the linker's point of view, it looks like the kernel loaded the linker like normal. Bug: 31559095 Test: Enable host bionic, build and run libdemangle_test Change-Id: I1753401ef91eecbf0ae3376faca31eec1c53842b