Skip to content

Commit

Permalink
backend: remove OMFOBJ macro
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jun 23, 2015
1 parent 4ec581f commit 4fdf6d9
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 115 deletions.
2 changes: 1 addition & 1 deletion src/backend/cgobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct Loc
void error(Loc loc, const char *format, ...);
#endif

#if OMFOBJ
#if TARGET_WINDOS

static char __file__[] = __FILE__; // for tassert.h
#include "tassert.h"
Expand Down
43 changes: 21 additions & 22 deletions src/backend/cod3.c
Original file line number Diff line number Diff line change
Expand Up @@ -4530,41 +4530,40 @@ void assignaddrc(code *c)
s = c->IEVsym1;
switch (c->IFL1)
{
#if OMFOBJ
case FLdata:
if (config.objfmt == OBJ_MSCOFF || s->Sclass == SCcomdat)
{ c->IFL1 = FLextern;
goto do2;
}
if (config.objfmt == OBJ_OMF && s->Sclass != SCcomdat)
{
#if MARS
c->IEVseg1 = s->Sseg;
c->IEVseg1 = s->Sseg;
#else
c->IEVseg1 = DATA;
c->IEVseg1 = DATA;
#endif
c->IEVpointer1 += s->Soffset;
c->IFL1 = FLdatseg;
c->IEVpointer1 += s->Soffset;
c->IFL1 = FLdatseg;
}
else
c->IFL1 = FLextern;
goto do2;

case FLudata:
if (config.objfmt == OBJ_MSCOFF)
{ c->IFL1 = FLextern;
goto do2;
}
if (config.objfmt == OBJ_OMF)
{
#if MARS
c->IEVseg1 = s->Sseg;
c->IEVseg1 = s->Sseg;
#else
c->IEVseg1 = UDATA;
c->IEVseg1 = UDATA;
#endif
c->IEVpointer1 += s->Soffset;
c->IFL1 = FLdatseg;
c->IEVpointer1 += s->Soffset;
c->IFL1 = FLdatseg;
}
else
c->IFL1 = FLextern;
goto do2;
#else // don't loose symbol information
case FLdata:
case FLudata:

case FLtlsdata:
c->IFL1 = FLextern;
if (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH)
c->IFL1 = FLextern;
goto do2;
#endif
case FLdatseg:
c->IEVseg1 = DATA;
goto do2;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/el.c
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ elem *el_convstring(elem *e)
if (tybasic(e->Ety) == TYcptr ||
(tyfv(e->Ety) && config.flags3 & CFG3strcod))
{
assert(OMFOBJ); // option not done yet for others
assert(config.objfmt == OBJ_OMF); // option not done yet for others
s = symbol_generate(SCstatic, type_fake(mTYcs | e->Ety));
s->Sfl = FLcsdata;
s->Soffset = Coffset;
Expand Down
9 changes: 9 additions & 0 deletions src/backend/elfobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,15 @@ int ElfObj::getsegment(const char *name, const char *suffix, int type, int flags
return seg;
}

/**********************************
* Reset code seg to existing seg.
* Used after a COMDAT for a function is done.
*/

void Obj::setcodeseg(int seg)
{
}

/********************************
* Define a new code segment.
* Input:
Expand Down
9 changes: 9 additions & 0 deletions src/backend/machobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,15 @@ int MachObj::getsegment(const char *sectname, const char *segname,
return seg;
}

/**********************************
* Reset code seg to existing seg.
* Used after a COMDAT for a function is done.
*/

void Obj::setcodeseg(int seg)
{
}

/********************************
* Define a new code segment.
* Input:
Expand Down
6 changes: 3 additions & 3 deletions src/backend/mscoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct filehdr
unsigned long f_nscns; // number of sections
unsigned long f_symptr; // file offset of symbol table
unsigned long f_nsyms; // number of entries in the symbol table


#define IMAGE_FILE_MACHINE_UNKNOWN 0 // applies to any machine type
#define IMAGE_FILE_MACHINE_I386 0x14C // x86
#define IMAGE_FILE_MACHINE_AMD64 0x8664 // x86_64
Expand Down Expand Up @@ -267,7 +267,7 @@ union auxent

// Section definitions
struct
{
{
unsigned length;
unsigned short NumberOfRelocations;
unsigned short NumberOfLinenumbers;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/mscoffobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "aa.h"
#include "tinfo.h"

#if OMFOBJ
#if TARGET_WINDOS

#if MARS
#include "mars.h"
Expand Down
156 changes: 69 additions & 87 deletions src/backend/out.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,10 @@ void outdata(symbol *s)
{ seg_data *pseg = objmod->tlsseg_bss();
s->Sseg = pseg->SDseg;
objmod->data_start(s, datasize, pseg->SDseg);
#if ELFOBJ || MACHOBJ
objmod->lidata(pseg->SDseg, pseg->SDoffset, datasize);
#endif
#if OMFOBJ
if (config.objfmt == OBJ_MSCOFF)
objmod->lidata(pseg->SDseg, pseg->SDoffset, datasize);
else
if (config.objfmt == OBJ_OMF)
pseg->SDoffset += datasize;
#endif
else
objmod->lidata(pseg->SDseg, pseg->SDoffset, datasize);
s->Sfl = FLtlsdata;
break;
}
Expand All @@ -208,12 +203,7 @@ void outdata(symbol *s)
break;
}
assert(s->Sseg && s->Sseg != UNKNOWN);
#if ELFOBJ || MACHOBJ
if (s->Sclass == SCglobal || s->Sclass == SCstatic) // if a pubdef to be done
#endif
#if OMFOBJ
if (s->Sclass == SCglobal || (s->Sclass == SCstatic && config.objfmt == OBJ_MSCOFF)) // if a pubdef to be done
#endif
if (s->Sclass == SCglobal || (s->Sclass == SCstatic && config.objfmt != OBJ_OMF)) // if a pubdef to be done
objmod->pubdefsize(s->Sseg,s,s->Soffset,datasize); // do the definition
searchfixlist(s);
if (config.fulltypes &&
Expand Down Expand Up @@ -320,26 +310,16 @@ void outdata(symbol *s)
assert(0);
}
}
#if ELFOBJ || MACHOBJ
if (s->Sseg == UNKNOWN)
if (s->Sseg == UNKNOWN && (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH))
s->Sseg = seg;
else if (config.objfmt == OBJ_OMF)
s->Sseg = seg;
else
seg = s->Sseg;
#endif
#if OMFOBJ
s->Sseg = seg;
#endif
if (s->Sclass == SCglobal
#if ELFOBJ || MACHOBJ
|| s->Sclass == SCstatic
#endif
#if OMFOBJ
|| (s->Sclass == SCstatic && config.objfmt == OBJ_MSCOFF)
#endif
)
{

if (s->Sclass == SCglobal || (s->Sclass == SCstatic && config.objfmt != OBJ_OMF))
objmod->pubdefsize(seg,s,s->Soffset,datasize); /* do the definition */
}

assert(s->Sseg != UNKNOWN);
if (config.fulltypes &&
!(s->Sclass == SCstatic && funcsym_p)) // not local static
Expand Down Expand Up @@ -462,31 +442,29 @@ void outcommon(symbol *s,targ_size_t n)
#endif
if (s->ty() & mTYthread) // if store in thread local segment
{
#if ELFOBJ
s->Sclass = SCcomdef;
objmod->common_block(s, 0, n, 1);
#else
/* COMDEFs not supported in tls segment
* so put them out as COMDATs with initialized 0s
*/
s->Sclass = SCcomdat;
dtnzeros(&s->Sdt,n);
outdata(s);
#if SCPP && OMFOBJ
out_extdef(s);
#endif
if (config.objfmt == OBJ_ELF)
{
s->Sclass = SCcomdef;
objmod->common_block(s, 0, n, 1);
}
else
{
/* COMDEFs not supported in tls segment
* so put them out as COMDATs with initialized 0s
*/
s->Sclass = SCcomdat;
dtnzeros(&s->Sdt,n);
outdata(s);
#if SCPP
if (config.objfmt == OBJ_OMF)
out_extdef(s);
#endif
}
}
else
{
s->Sclass = SCcomdef;
#if ELFOBJ || MACHOBJ
objmod->common_block(s, 0, n, 1);
#endif
#if OMFOBJ
if (config.objfmt == OBJ_MSCOFF)
objmod->common_block(s, 0, n, 1);
else
if (config.objfmt == OBJ_OMF)
{
#if TARGET_SEGMENTED
s->Sxtrnnum = objmod->common_block(s,(s->ty() & mTYfar) == 0,n,1);
Expand All @@ -504,7 +482,8 @@ void outcommon(symbol *s,targ_size_t n)
ph_comdef(s); // notify PH that a COMDEF went out
#endif
}
#endif
else
objmod->common_block(s, 0, n, 1);
}
if (config.fulltypes)
cv_outsym(s);
Expand All @@ -518,19 +497,21 @@ void outcommon(symbol *s,targ_size_t n)
void out_readonly(symbol *s)
{
// The default is DATA
#if ELFOBJ || MACHOBJ
/* Cannot have pointers in CDATA when compiling PIC code, because
* they require dynamic relocations of the read-only segment.
* Instead use the .data.rel.ro section. See Bugzilla 11171.
*/
if (config.flags3 & CFG3pic && dtpointers(s->Sdt))
s->Sseg = CDATAREL;
if (config.objfmt == OBJ_ELF || config.objfmt == OBJ_MACH)
{
/* Cannot have pointers in CDATA when compiling PIC code, because
* they require dynamic relocations of the read-only segment.
* Instead use the .data.rel.ro section. See Bugzilla 11171.
*/
if (config.flags3 & CFG3pic && dtpointers(s->Sdt))
s->Sseg = CDATAREL;
else
s->Sseg = CDATA;
}
else
s->Sseg = CDATA;
#endif
#if OMFOBJ
// Haven't really worked out where immutable read-only data can go.
#endif
{
// Haven't really worked out where immutable read-only data can go.
}
}

/******************************
Expand Down Expand Up @@ -910,9 +891,7 @@ STATIC void writefunc2(symbol *sfunc)
unsigned nsymbols;
SYMIDX si;
int anyasm;
#if OMFOBJ
int csegsave;
#endif
int csegsave; // for OMF
func_t *f = sfunc->Sfunc;
tym_t tyf;

Expand Down Expand Up @@ -1202,9 +1181,7 @@ STATIC void writefunc2(symbol *sfunc)
{
if (symbol_iscomdat(sfunc))
{
#if OMFOBJ
csegsave = cseg;
#endif
objmod->comdat(sfunc);
}
else
Expand Down Expand Up @@ -1237,13 +1214,11 @@ STATIC void writefunc2(symbol *sfunc)
goto Ldone;
if (sfunc->Sclass == SCglobal)
{
#if OMFOBJ
if (!(config.flags4 & CFG4allcomdat))
if ((config.objfmt == OBJ_OMF || config.objfmt == OBJ_MSCOFF) && !(config.flags4 & CFG4allcomdat))
{
assert(sfunc->Sseg == cseg);
objmod->pubdef(sfunc->Sseg,sfunc,sfunc->Soffset); // make a public definition
}
#endif

#if SCPP && _WIN32
char *id;
Expand Down Expand Up @@ -1345,10 +1320,9 @@ STATIC void writefunc2(symbol *sfunc)
cod3_adjSymOffsets();
#endif

#if OMFOBJ
if (symbol_iscomdat(sfunc)) // if generated a COMDAT
if ((config.objfmt == OBJ_OMF || config.objfmt == OBJ_MSCOFF) &&
symbol_iscomdat(sfunc)) // if generated a COMDAT
objmod->setcodeseg(csegsave); // reset to real code seg
#endif

/* Check if function is a constructor or destructor, by */
/* seeing if the function name starts with _STI or _STD */
Expand Down Expand Up @@ -1423,6 +1397,9 @@ void out_reset()

symbol *out_readonly_sym(tym_t ty, void *p, int len)
{
#if HTOD
return;
#endif
#if 0
printf("out_readonly_sym(ty = x%x)\n", ty);
for (int i = 0; i < len; i++)
Expand All @@ -1438,20 +1415,25 @@ symbol *out_readonly_sym(tym_t ty, void *p, int len)

symbol *s;

#if ELFOBJ || (OMFOBJ && MARS) /* includes COFF */
/* MACHOBJ can't go here, because the const data segment goes into
* the _TEXT segment, and one cannot have a fixup from _TEXT to _TEXT.
*/
s = objmod->sym_cdata(ty, (char *)p, len);
#else
unsigned sz = tysize(ty);
if (config.objfmt == OBJ_ELF ||
(MARS && (config.objfmt == OBJ_OMF || config.objfmt == OBJ_MSCOFF)))
{
/* MACHOBJ can't go here, because the const data segment goes into
* the _TEXT segment, and one cannot have a fixup from _TEXT to _TEXT.
*/
s = objmod->sym_cdata(ty, (char *)p, len);
}
else
{
unsigned sz = tysize(ty);

alignOffset(DATA, sz);
s = symboldata(Doffset,ty | mTYconst);
s->Sseg = DATA;
objmod->write_bytes(SegData[DATA], len, p);
//printf("s->Sseg = %d:x%x\n", s->Sseg, s->Soffset);
}

alignOffset(DATA, sz);
s = symboldata(Doffset,ty | mTYconst);
s->Sseg = DATA;
objmod->write_bytes(SegData[DATA], len, p);
//printf("s->Sseg = %d:x%x\n", s->Sseg, s->Soffset);
#endif
if (len <= ROMAX)
{ Readonly *r;

Expand Down

0 comments on commit 4fdf6d9

Please sign in to comment.