feat: use PIC code model for shared libraries, fix shared library bugs

This commit is contained in:
2026-04-08 17:07:55 +02:00
parent d87c14da25
commit 28d0614511
10 changed files with 85 additions and 25 deletions
+4 -3
View File
@@ -268,10 +268,11 @@ namespace Sched {
uint64_t copyEnd = (pageEnd < targetSegFileEnd) ? pageEnd : targetSegFileEnd;
if (copyStart < copyEnd) {
// Source: file data at (copyStart - targetSegStart) offset from p_offset
// Source stays segment-relative, but the destination must be page-relative.
// Using a segment-relative destination offset leaves page 2+ zero-filled and
// writes past the newly allocated page in the kernel mapping.
uint64_t srcOffset = phdr->p_offset + (copyStart - targetSegStart);
// Dest: page at (copyStart - targetSegStart) offset, then adjusted for this page
uint64_t pageDataOffset = copyStart - targetSegStart;
uint64_t pageDataOffset = copyStart - pageStart;
uint64_t copySize = copyEnd - copyStart;
uint8_t* dst = (uint8_t*)Memory::HHDM(physAddr) + pageDataOffset;