Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libsel4utils: Fix TLS page fault if PT_PHDR exists
PT_PHDR is emitted by ld.lld but not ld.bfd. This segment should only exist if the program header *is* part of the program memory image itself (which is not the case in seL4, as it copies the program header in the stack). This is important as muslc’s TLS init is relying on the existence of PT_PHDR to get the base address of the image in memory and from that, it calculates the TLS base for the source ELF. The calculation will be wrong in seL4 as the program header is copied in the stack; thus it may trigger a page fault if the new TLS base is not mapped, or affects the integrity of programs relying on TLS variables (e.g., those with __thread). By setting PT_PHDR's segment to PT_NULL, muslc will skip this search and won't do any relocations for the TLS segment which is part of the loaded ELF image itself, thus getting the correct mapped address. Sponsored by: DARPA. Signed-off-by: Hesham Almatary <[email protected]>
- Loading branch information