Skip to content

Commit

Permalink
can now do hello world on OSX 64
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Nov 7, 2011
1 parent 475bd32 commit 0b82e50
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 95 deletions.
7 changes: 7 additions & 0 deletions src/backend/cod1.c
Expand Up @@ -2623,6 +2623,13 @@ code *cdfunc(elem *e,regm_t *pretregs)
stackpushsave += numalign;
}

// Variadic functions store the number of XMM registers used in AL
if (I64 && e->Eflags & EFLAGS_variadic)
{ code *c1 = getregs(mAX);
c1 = movregconst(c1,AX,0,1);
c = cat(c, c1);
keepmsk |= mAX;
}
}
Lret:
cgstate.stackclean--;
Expand Down
5 changes: 5 additions & 0 deletions src/backend/cod2.c
Expand Up @@ -4008,6 +4008,11 @@ code *getoffset(elem *e,unsigned reg)
if (config.flags3 & CFG3pic)
{ // LEA reg,immed32[RIP]
cs.Iop = 0x8D;
#if TARGET_OSX
symbol *s = e->EV.sp.Vsym;
if (fl == FLextern)
cs.Iop = 0x8B; // MOV reg,[00][RIP]
#endif
cs.Irm = modregrm(0,reg & 7,5);
if (reg & 8)
cs.Irex = (cs.Irex & ~REX_B) | REX_R;
Expand Down
3 changes: 3 additions & 0 deletions src/backend/cod3.c
Expand Up @@ -5308,6 +5308,9 @@ unsigned codout(code *c)
val = -8;
}
}
#if TARGET_OSX
val = 0;
#endif
}
do32bit((enum FL)c->IFL1,&c->IEV1,flags,val);
break;
Expand Down
11 changes: 9 additions & 2 deletions src/backend/el.c
Expand Up @@ -1408,6 +1408,9 @@ elem * el_var(symbol *s)
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
// OSX is currently always pic
if (config.flags3 & CFG3pic &&
#if TARGET_OSX
I32 &&
#endif
#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
(!(s->Stype->Tty & mTYthread) || I64) &&
#endif
Expand Down Expand Up @@ -1616,7 +1619,7 @@ elem * el_ptr(symbol *s)
symbol_debug(s);
type_debug(s->Stype);
#if TARGET_OSX
if (config.flags3 & CFG3pic && tyfunc(s->ty()))
if (config.flags3 & CFG3pic && tyfunc(s->ty()) && I32)
{
/* Cannot access address of code from code.
* Instead, create a data variable, put the address of the
Expand All @@ -1630,7 +1633,11 @@ elem * el_ptr(symbol *s)
}
#endif
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
if (config.flags3 & CFG3pic && tyfunc(s->ty()))
if (config.flags3 & CFG3pic &&
#if TARGET_OSX
I32 &&
#endif
tyfunc(s->ty()))
e = el_picvar(s);
else
#endif
Expand Down

0 comments on commit 0b82e50

Please sign in to comment.