Skip to content

Commit

Permalink
Merge pull request #6667 from rainers/issue17291
Browse files Browse the repository at this point in the history
fix issue 17291: bad relocations for pointer references
  • Loading branch information
WalterBright committed Apr 2, 2017
2 parents 9c17c57 + 4b45720 commit cd33499
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/ddmd/backend/cgobj.c
Expand Up @@ -756,10 +756,11 @@ void Obj::term(const char *objfilename)
#if SCPP
if (!errcnt)
#endif
{ obj_defaultlib();
{
obj_defaultlib();
objflush_pointerRefs();
outfixlist(); // backpatches
}
objflush_pointerRefs();

if (config.fulltypes)
cv_term(); // write out final debug info
Expand Down
2 changes: 1 addition & 1 deletion src/ddmd/backend/mscoffobj.c
Expand Up @@ -683,8 +683,8 @@ void MsCoffObj::term(const char *objfilename)
if (!errcnt)
#endif
{
outfixlist(); // backpatches
objflush_pointerRefs();
outfixlist(); // backpatches
}

if (configv.addlinenumbers)
Expand Down
13 changes: 12 additions & 1 deletion test/runnable/testptrref.d
Expand Up @@ -53,6 +53,12 @@ class Class
void* ptr;
}

struct Struc(T)
{
static T vtls;
static __gshared T vgshared;
}

__gshared Struct* gsharedStrctPtr2 = new Struct(7, new Struct(8, null));

int tlsInt;
Expand Down Expand Up @@ -128,7 +134,7 @@ void testRefPtr()
assert(findDataPtr(&gsharedStrct.next));
assert(findDataPtr(&(gsharedClss)));
assert(findDataPtr(&(gsharedClss.ptr)));


assert(findTlsPtr(&tlsVar));
assert(findTlsPtr(&tlsClss));
assert(findTlsPtr(&tlsStrcArr[0].next));
Expand All @@ -154,4 +160,9 @@ void testRefPtr()
assert(findDataPtr(&gsharedStrctPtr));
assert(findDataPtr(&gsharedStrctPtr.next));
assert(findDataPtr(&gsharedStrctPtr.next.next));

assert(findDataPtr(&(Struc!(int*).vgshared)));
assert(!findDataPtr(&(Struc!(int).vgshared)));
assert(findTlsPtr(&(Struc!(int*).vtls)));
assert(!findTlsPtr(&(Struc!(int).vtls)));
}

0 comments on commit cd33499

Please sign in to comment.