syscall: implement sys_mmap/sys_munmap/sys_mprotect for dlopen support#48
Open
eplondke wants to merge 3 commits into
Open
syscall: implement sys_mmap/sys_munmap/sys_mprotect for dlopen support#48eplondke wants to merge 3 commits into
eplondke wants to merge 3 commits into
Conversation
Add a malloc+read based mmap implementation in libs/syscall/angel/src/sys_mmap.c to support BSD libdl's dlopen loading position-independent shared objects under hexagon-sim. MAP_ANON non-fixed allocations use memalign(4096) to reserve a contiguous aligned block that serves as the rtld base address. MAP_FIXED calls write directly into the already-allocated block via sys_seek+sys_read (file-backed) or memset (anonymous/BSS), placing each PT_LOAD segment at the correct relative offset. munmap is a no-op since dlclose is not yet supported. mprotect is a no-op since the simulator does not enforce page permissions. The previous UNSUPPORTED stubs in libs/qurt/src/qurt_mmap.c are removed. The new file is auto-included by the angel Makefile's $(wildcard src/*.c) rule. Signed-off-by: Erich Plondke <erich.plondke@oss.qualcomm.com> Signed-off-by: Erich Plondke <erich@qti.qualcomm.com>
Author
|
Make sure if you're trying this out you don't have the old qurt file .o in your artifacts directory! |
Dynamic ELF binaries have two string tables: .dynstr (for .dynsym) and .strtab (for .symtab). The old section scan picked the first SHT_STRTAB it found by type, which is .dynstr in dynamic binaries since it precedes .strtab in section order. Using .dynstr to decode .symtab symbol names causes all strcmp lookups to fail, so no special symbols (end, __boot_*, etc.) are found when loading a --force-dynamic binary. Fix: after locating SHT_SYMTAB, use pSymhdr->sh_line (h2_elf.h's name for the standard ELF sh_link field) as the index of the associated string table rather than scanning for the first SHT_STRTAB by type. Signed-off-by: Erich Plondke <erich.plondke@oss.qualcomm.com> Signed-off-by: Erich Plondke <erich@qti.qualcomm.com>
Signed-off-by: Erich Plondke <erich@qti.qualcomm.com>
Author
|
Yay, all checks passed! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a malloc+read based mmap implementation in libs/syscall/angel/src/sys_mmap.c to support BSD libdl's dlopen loading position-independent shared objects under hexagon-sim.
MAP_ANON non-fixed allocations use memalign(4096) to reserve a contiguous aligned block that serves as the rtld base address. MAP_FIXED calls write directly into the already-allocated block via sys_seek+sys_read (file-backed) or memset (anonymous/BSS), placing each PT_LOAD segment at the correct relative offset. munmap is a no-op since dlclose is not yet supported. mprotect is a no-op since the simulator does not enforce page permissions.
The previous UNSUPPORTED stubs in libs/qurt/src/qurt_mmap.c are removed. The new file is auto-included by the angel Makefile's $(wildcard src/*.c) rule.