DynamoRIO / DynamoRIO/dynamorio
ELF loader ignores segment alignment
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 30
Description
The ELF loader in drlibc ignores the ElfNN_Phdr.p_align flag entirely: instead it uses the page size only for alignment of the start and end of each segment. This doesn't matter for most ELF files, since they align their p_vaddr fields. But it does appear when loading AArch64 ELF files on x86 where the ELF expects 64K pages and aligns its segments to 64K. (This also raises the problem of how to handle cross-arch page sizes like that when we load cross-arch ELF files for drcachesim trace analysis and other purposes: right now using the host page size is working b/c we only run AArch64 on x86 where x86's page size is *smaller*.)
Getting into the details: it is a little murky as to which loaders honor p_align, and what p_align really means. I found a case where an ELF file's segments had 2MB p_align, but the kernel there completely ignored the p_align (slightly custom Linux kernel). DR not matching the kernel in this respect causes major problems when our early injection parses the libdynamorio.so headers for relocation.
Contributor guide
Research direction
Start at the ELF loader's segment start/end alignment logic and trace how early injection parses libdynamorio.so headers. Compare handling of ElfNN_Phdr.p_align with the existing host-page-size behavior, including AArch64 ELF on x86; done when relocation parsing no longer breaks for the described alignment case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems, reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100