Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 8074173

Browse files
authored
Merge pull request #1678 from ibuclaw/testdataalign
Ensure that the writable data segment is aligned. merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2 parents f60615f + 9f7ae4b commit 8074173

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/rt/sections_elf_shared.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ version (Shared)
676676
{
677677
if (phdr.p_type == PT_DYNAMIC)
678678
{
679-
auto p = cast(ElfW!"Dyn"*)(info.dlpi_addr + phdr.p_vaddr);
679+
auto p = cast(ElfW!"Dyn"*)(info.dlpi_addr + (phdr.p_vaddr & ~(size_t.sizeof - 1)));
680680
dyns = p[0 .. phdr.p_memsz / ElfW!"Dyn".sizeof];
681681
break;
682682
}
@@ -745,12 +745,12 @@ void scanSegments(in ref dl_phdr_info info, DSO* pdso) nothrow @nogc
745745
case PT_LOAD:
746746
if (phdr.p_flags & PF_W) // writeable data segment
747747
{
748-
auto beg = cast(void*)(info.dlpi_addr + phdr.p_vaddr);
748+
auto beg = cast(void*)(info.dlpi_addr + (phdr.p_vaddr & ~(size_t.sizeof - 1)));
749749
pdso._gcRanges.insertBack(beg[0 .. phdr.p_memsz]);
750750
}
751751
version (Shared) if (phdr.p_flags & PF_X) // code segment
752752
{
753-
auto beg = cast(void*)(info.dlpi_addr + phdr.p_vaddr);
753+
auto beg = cast(void*)(info.dlpi_addr + (phdr.p_vaddr & ~(size_t.sizeof - 1)));
754754
pdso._codeSegments.insertBack(beg[0 .. phdr.p_memsz]);
755755
}
756756
break;

0 commit comments

Comments
 (0)