Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 19551 - corrupt ELF library when using pragma(crt_constructor) #9204

Merged
merged 1 commit into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/dmd/backend/elfobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -1959,9 +1959,12 @@ private int elf_addsegment2(IDXSEC shtidx, IDXSYM symidx, IDXSEC relidx)
}
assert(seg_count < seg_max);
if (!SegData[seg])
{ SegData[seg] = cast(seg_data *)mem_calloc((seg_data).sizeof);
{
SegData[seg] = cast(seg_data *)mem_calloc(seg_data.sizeof);
//printf("test2: SegData[%d] = %p\n", seg, SegData[seg]);
}
else
memset(SegData[seg], 0, seg_data.sizeof);

seg_data *pseg = SegData[seg];
pseg.SDseg = seg;
Expand Down
12 changes: 12 additions & 0 deletions test/runnable/extra-files/lib18456b.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module manual;

class ManualGC {
void enable()
{
}

void disable()
{
}

}
3 changes: 2 additions & 1 deletion test/runnable/test18456.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

$DMD -m${MODEL} -I${EXTRA_FILES} -of${OUTPUT_BASE}${LIBEXT} -lib ${EXTRA_FILES}/lib18456.d
# source file order is important
$DMD -m${MODEL} -I${EXTRA_FILES} -of${OUTPUT_BASE}${LIBEXT} -lib ${EXTRA_FILES}/lib18456b.d ${EXTRA_FILES}/lib18456.d
$DMD -m${MODEL} -I${EXTRA_FILES} -of${OUTPUT_BASE}${EXE} ${EXTRA_FILES}/test18456.d ${OUTPUT_BASE}${LIBEXT}
${OUTPUT_BASE}${EXE}

Expand Down