Showing with 58 additions and 62 deletions.
  1. +2 −2 src/backend/cdef.h
  2. +7 −5 src/backend/cgcod.c
  3. +38 −36 src/backend/cod3.c
  4. +0 −3 src/backend/code.h
  5. +4 −0 src/backend/dwarf.c
  6. +2 −2 src/backend/global.h
  7. +1 −0 src/backend/obj.h
  8. +0 −2 src/backend/out.c
  9. +0 −8 src/backend/rtlsym.c
  10. +0 −1 src/backend/rtlsym.h
  11. +0 −2 src/backend/symbol.c
  12. +4 −1 src/win32.mak
4 changes: 2 additions & 2 deletions src/backend/cdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ struct Config
unsigned objfmt; // target object format
#define OBJ_OMF 1
#define OBJ_MSCOFF 2
#define OBJ_ELF 3
#define OBJ_MACH 4
#define OBJ_ELF 4
#define OBJ_MACH 8
unsigned exe; // target operating system
#define EX_DOSX 1 // DOSX 386 program
#define EX_ZPM 2 // ZPM 286 program
Expand Down
12 changes: 7 additions & 5 deletions src/backend/cgcod.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,13 @@ void codgen()
#endif

// Compute starting offset for switch tables
#if ELFOBJ || MACHOBJ
targ_size_t swoffset = (config.flags & CFGromable) ? coffset : CDoffset;
#else
targ_size_t swoffset = (config.flags & CFGromable) ? coffset : Doffset;
#endif
targ_size_t swoffset;
if (config.flags & CFGromable)
swoffset = coffset;
else if (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH)
swoffset = CDoffset;
else
swoffset = Doffset;
swoffset = align(0,swoffset);

// Emit the generated code
Expand Down
74 changes: 38 additions & 36 deletions src/backend/cod3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2975,11 +2975,9 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
genregs(c,0x8B,BP,SP); // MOV BP,SP
if (I64)
code_orrex(c, REX_W); // MOV RBP,RSP
#if ELFOBJ || MACHOBJ
if (config.fulltypes)
if ((config.objfmt & (OBJ_ELF | OBJ_MACH)) && config.fulltypes)
// Don't reorder instructions, as dwarf CFA relies on it
code_orflag(c, CFvolatile);
#endif
#if NTEXCEPTIONS == 2
if (usednteh & ~NTEHjmonitor && (config.flags2 & CFG2seh))
{
Expand All @@ -2991,8 +2989,7 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
// by nteh_prolog()
}
#endif
#if ELFOBJ || MACHOBJ
if (config.fulltypes)
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D)
{ int off = 2 * REGSIZE;
dwarf_CFA_set_loc(1); // address after PUSH EBP
dwarf_CFA_set_reg_offset(SP, off); // CFA is now 8[ESP]
Expand All @@ -3002,7 +2999,6 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
// But this gets the cfa register set to EBP correctly
dwarf_CFA_set_reg_offset(BP, off); // CFA is now 0[EBP]
}
#endif
*enter = false; /* do not use ENTER instruction */
}
else
Expand Down Expand Up @@ -3068,9 +3064,7 @@ code* prolog_frameadj(tym_t tyf, unsigned xlocalsize, bool enter, bool* pushallo
if (enter)
{ // ENTER xlocalsize,0
c = genc(c,0xC8,0,FLconst,xlocalsize,FLconst,(targ_uns) 0);
#if ELFOBJ || MACHOBJ
assert(!config.fulltypes); // didn't emit Dwarf data
#endif
assert(!(config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D)); // didn't emit Dwarf data
}
else if (xlocalsize == REGSIZE && config.flags4 & CFG4optimized)
{ c = gen1(c,0x50 + pushallocreg); // PUSH AX
Expand Down Expand Up @@ -3137,15 +3131,13 @@ code* prolog_saveregs(code *c, regm_t topush)
c = genpush(c, reg);
EBPtoESP += REGSIZE;
spoff += REGSIZE;
#if ELFOBJ || MACHOBJ
if (config.fulltypes)
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D)
{ // Emit debug_frame data giving location of saved register
// relative to 0[EBP]
pinholeopt(c, NULL);
dwarf_CFA_set_loc(calcblksize(c)); // address after PUSH reg
dwarf_CFA_offset(reg, -EBPtoESP - REGSIZE);
}
#endif
}
}
return c;
Expand Down Expand Up @@ -4688,36 +4680,46 @@ void assignaddrc(code *c)
s = c->IEVsym2;
switch (c->IFL2)
{
#if ELFOBJ || MACHOBJ
case FLdata:
if (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH)
{
c->IFL2 = FLextern;
goto do2;
}
else
{
if (s->Sclass == SCcomdat)
{ c->IFL2 = FLextern;
goto do2;
}
c->IEVseg2 = MARS ? s->Sseg : DATA;
c->IEVpointer2 += s->Soffset;
c->IFL2 = FLdatseg;
goto done;
}

case FLudata:
if (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH)
{
c->IFL2 = FLextern;
goto do2;
}
else
{
c->IEVseg2 = MARS ? s->Sseg : UDATA;
c->IEVpointer2 += s->Soffset;
c->IFL2 = FLdatseg;
goto done;
}

case FLtlsdata:
c->IFL2 = FLextern;
goto do2;
#else
case FLdata:
if (s->Sclass == SCcomdat)
{ c->IFL2 = FLextern;
if (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH)
{
c->IFL2 = FLextern;
goto do2;
}
#if MARS
c->IEVseg2 = s->Sseg;
#else
c->IEVseg2 = DATA;
#endif
c->IEVpointer2 += s->Soffset;
c->IFL2 = FLdatseg;
goto done;
case FLudata:
#if MARS
c->IEVseg2 = s->Sseg;
#else
c->IEVseg2 = UDATA;
#endif
c->IEVpointer2 += s->Soffset;
c->IFL2 = FLdatseg;
goto done;
#endif

case FLdatseg:
c->IEVseg2 = DATA;
goto done;
Expand Down
3 changes: 0 additions & 3 deletions src/backend/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,6 @@ struct seg_data



#if 1 //ELFOBJ || MACHOBJ

struct linnum_data
{
const char *filename;
Expand All @@ -618,7 +616,6 @@ struct linnum_data
unsigned (*linoff)[2]; // [0] = line number, [1] = offset
};

#endif

extern seg_data **SegData;
#define Offset(seg) SegData[seg]->SDoffset
Expand Down
4 changes: 4 additions & 0 deletions src/backend/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2493,5 +2493,9 @@ unsigned dwarf_abbrev_code(unsigned char *data, size_t nbytes)
return *pcode;
}

#else
void dwarf_CFA_set_loc(size_t location) { }
void dwarf_CFA_set_reg_offset(int reg, int offset) { }
void dwarf_CFA_offset(int reg, int offset) { }
#endif
#endif
4 changes: 2 additions & 2 deletions src/backend/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,12 @@ void rtlsym_init();
void rtlsym_reset();
void rtlsym_term();

#if SYMDEB_DWARF
// Dwarf
void dwarf_CFA_set_loc(size_t location);
void dwarf_CFA_set_reg_offset(int reg, int offset);
void dwarf_CFA_offset(int reg, int offset);
void dwarf_CFA_args_size(size_t sz);
#endif


#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
elem * exp_isconst();
Expand Down
1 change: 1 addition & 0 deletions src/backend/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct Obj

#if TARGET_WINDOS
VIRTUAL int seg_debugT(); // where the symbolic debug type data goes
static void gotref(symbol *s) { }
#endif
};

Expand Down
2 changes: 0 additions & 2 deletions src/backend/out.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,10 @@ STATIC void outelem(elem *e)
}
else if (s->Sdt) /* if initializer for symbol */
outdata(s); // write out data for symbol
#if ELFOBJ || MACHOBJ
if (config.flags3 & CFG3pic)
{
objmod->gotref(s);
}
#endif
#endif
break;
case OPstring:
Expand Down
8 changes: 0 additions & 8 deletions src/backend/rtlsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ void rtlsym_init()
tv->Tcount++;
#endif

#if MACHOBJ
type *tw = type_fake(TYnpfunc);
tw->Tmangle = mTYman_sys;
tw->Tcount++;
#else
type *tw = NULL;
#endif

#undef SYMBOL_Z
#define SYMBOL_Z(e, fl, saved, n, flags, ty) \
if (ty) rtlsym[RTLSYM_##e]->Stype = (ty); \
Expand Down
1 change: 0 additions & 1 deletion src/backend/rtlsym.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#define RTLSYMS \
\
SYMBOL_MARS(THROW, FLfunc,(mES | mBP),"_d_throw@4", SFLexit, tw) \
SYMBOL_MARS(THROWC, FLfunc,(mES | mBP),"_d_throwc", SFLexit, t) \
SYMBOL_MARS(MONITOR_HANDLER, FLfunc,FREGSAVED,"_d_monitor_handler", 0, 0) \
SYMBOL_MARS(MONITOR_PROLOG, FLfunc,FREGSAVED,"_d_monitor_prolog",0,t) \
Expand Down
2 changes: 0 additions & 2 deletions src/backend/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2322,9 +2322,7 @@ void slist_reset()
{
Symbol *s = slist[i];

#if MACHOBJ
s->Soffset = 0;
#endif
s->Sxtrnnum = 0;
s->Stypidx = 0;
s->Sflags &= ~(STRoutdef | SFLweak);
Expand Down
5 changes: 4 additions & 1 deletion src/win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ BACKOBJ= go.obj gdag.obj gother.obj gflow.obj gloop.obj var.obj el.obj \
cgcod.obj cod1.obj cod2.obj cod3.obj cod4.obj cod5.obj outbuf.obj \
bcomplex.obj ptrntab.obj aa.obj ti_achar.obj md5.obj \
ti_pvoid.obj mscoffobj.obj pdata.obj cv8.obj backconfig.obj \
divcoeff.obj \
divcoeff.obj dwarf.obj \
ph2.obj util2.obj eh.obj tk.obj \


Expand Down Expand Up @@ -550,6 +550,9 @@ divcoeff.obj : $C\divcoeff.c
dt.obj : $C\dt.h $C\dt.c
$(CC) -c $(MFLAGS) $C\dt

dwarf.obj : $C\dwarf.h $C\dwarf.c
$(CC) -c $(MFLAGS) $C\dwarf

ee.obj : $C\ee.c
$(CC) -c $(MFLAGS) $C\ee

Expand Down