Skip to content

Commit

Permalink
Merge pull request #10680 from WalterBright/comdef
Browse files Browse the repository at this point in the history
send .init of all zeros to COMDEF sections
  • Loading branch information
atilaneves committed Dec 23, 2019
2 parents f8d88eb + 1331265 commit 78c6e62
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/dmd/toobj.d
Expand Up @@ -511,7 +511,20 @@ void toObjFile(Dsymbol ds, bool multiobj)
auto dtb = DtBuilder(0);
StructDeclaration_toDt(sd, dtb);
sd.sinit.Sdt = dtb.finish();
out_readonly(sd.sinit); // put in read-only segment

/* fails to link on OBJ_MACH 64 with:
* ld: in generated/osx/release/64/libphobos2.a(dwarfeh_8dc_56a.o),
* in section __TEXT,__textcoal_nt reloc 6:
* symbol index out of range for architecture x86_64
*/
if (config.objfmt != OBJ_MACH &&
dtallzeros(sd.sinit.Sdt))
{
sd.sinit.Sclass = SCglobal;
dt2common(&sd.sinit.Sdt);
}
else
out_readonly(sd.sinit); // put in read-only segment
outdata(sd.sinit);

// Put out the members
Expand Down
6 changes: 3 additions & 3 deletions test/compilable/extra-files/test11237.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

if [[ $OS == linux || $OS == freebsd ]]; then
nm -S ${OUTPUT_BASE}_0.o | grep "00010000 B _D9test112376Buffer6__initZ"
fi
#if [[ $OS == linux || $OS == freebsd ]]; then
# nm -S ${OUTPUT_BASE}_0.o | grep "00010000 B _D9test112376Buffer6__initZ"
#fi

0 comments on commit 78c6e62

Please sign in to comment.