Skip to content

Commit

Permalink
Win64
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Sep 1, 2012
1 parent 31f858b commit ded2db7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/backend/cod3.c
Original file line number Diff line number Diff line change
Expand Up @@ -3715,6 +3715,10 @@ void cod3_thunk(symbol *sthunk,symbol *sfunc,unsigned p,tym_t thisty,
sthunk->Sseg = cseg;
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
objmod->pubdef(cseg,sthunk,sthunk->Soffset);
#endif
#if TARGET_WINDOS
if (config.exe == EX_WIN64)
objmod->pubdef(cseg,sthunk,sthunk->Soffset);
#endif
searchfixlist(sthunk); /* resolve forward refs */
}
Expand Down
1 change: 1 addition & 0 deletions src/backend/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ symbol * symbol_generate(int sclass,type *t)
{ char name[10];
static int tmpnum;

//printf("symbol_generate(_TMP%d)\n", tmpnum);
sprintf(name,"_TMP%d",tmpnum++);
#ifdef DEBUG
symbol *s = symbol_name(name,sclass,t);
Expand Down
12 changes: 7 additions & 5 deletions src/e2ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ elem *callfunc(Loc loc,
goto L1;
}
ea = arg->toElem(irs);
if (config.exe == EX_WIN64 && tybasic(ea->Ety) == TYcfloat)
{ /* Treat a cfloat like it was a struct { float re,im; }
*/
ea->Ety = TYllong;
}
L1:
if (tybasic(ea->Ety) == TYstruct || tybasic(ea->Ety) == TYarray)
{
Expand Down Expand Up @@ -213,10 +218,7 @@ elem *callfunc(Loc loc,

if (fd && fd->isMember2())
{
Symbol *sfunc;
AggregateDeclaration *ad;

ad = fd->isThis();
AggregateDeclaration *ad = fd->isThis();
if (ad)
{
ethis = ec;
Expand All @@ -230,7 +232,7 @@ elem *callfunc(Loc loc,
// Evaluate ec for side effects
eside = ec;
}
sfunc = fd->toSymbol();
Symbol *sfunc = fd->toSymbol();

if (!fd->isVirtual() ||
directcall || // BUG: fix
Expand Down
20 changes: 17 additions & 3 deletions src/libmscoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct ObjSymbol
*/
int ObjSymbol_cmp(const void *p, const void *q)
{
ObjSymbol *s1 = (ObjSymbol *)p;
ObjSymbol *s2 = (ObjSymbol *)q;
ObjSymbol *s1 = *(ObjSymbol **)p;
ObjSymbol *s2 = *(ObjSymbol **)q;
return strcmp(s1->name, s2->name);
}

Expand Down Expand Up @@ -199,6 +199,16 @@ struct ObjModule
int scan; // 1 means scan for symbols
};

/*********
* Do module offset comparison of ObjSymbol's for qsort()
*/
int ObjSymbol_offset_cmp(const void *p, const void *q)
{
ObjSymbol *s1 = *(ObjSymbol **)p;
ObjSymbol *s2 = *(ObjSymbol **)q;
return s1->om->offset - s2->om->offset;
}

struct Header
{
#define OBJECT_NAME_SIZE 16
Expand Down Expand Up @@ -709,10 +719,14 @@ void LibMSCoff::WriteLibToBuffer(OutBuffer *libbuf)
sputl(objsymbols.dim, buf);
libbuf->write(buf, 4);

// Sort objsymbols[] in module offset order
qsort(objsymbols.data, objsymbols.dim, sizeof(objsymbols.data[0]), &ObjSymbol_offset_cmp);

unsigned long lastoffset;
for (size_t i = 0; i < objsymbols.dim; i++)
{ ObjSymbol *os = objsymbols[i];

//printf("objsymbols[%d] = '%s', offset = %u\n", i, os->name, os->om->offset);
if (i)
// Should be sorted in module order
assert(lastoffset <= os->om->offset);
Expand Down Expand Up @@ -775,7 +789,7 @@ void LibMSCoff::WriteLibToBuffer(OutBuffer *libbuf)
if (libbuf->offset & 1)
libbuf->writeByte('\n');

printf("libbuf %x longnames %x\n", (int)libbuf->offset, (int)LongnamesMemberOffset);
//printf("libbuf %x longnames %x\n", (int)libbuf->offset, (int)LongnamesMemberOffset);
assert(libbuf->offset == LongnamesMemberOffset);

// header
Expand Down

0 comments on commit ded2db7

Please sign in to comment.