Skip to content

Commit

Permalink
Merge branch 'rdinfo' into visuald
Browse files Browse the repository at this point in the history
  • Loading branch information
rainers committed Feb 7, 2014
2 parents cfd606b + cd821ce commit e6a3d17
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
69 changes: 69 additions & 0 deletions src/backend/cgobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ struct Objstate
int fisegi; // SegData[] index of FI segment

#if MARS
int hpsegi; // SegData[] of "has pointer" segment
int tlshpsegi; // SegData[] of "TLS has pointer" segment
int fmsegi; // SegData[] of FM segment
#endif

Expand Down Expand Up @@ -521,6 +523,73 @@ seg_data *getsegment()
return pseg;
}

int Obj::hpseg(bool tls)
{
//return DATA;
#define DATACLASS 6 // data class lname index
int& segi = tls ? obj.tlshpsegi : obj.hpsegi;

if (segi == 0)
{
static char tls_lnames[] =
{ "\06HPTLSB\05HPTLS\06HPTLSE"
};
static char lnames[] =
{ "\03HPB\02HP\03HPE"
};

// Put out LNAMES record

if(tls)
objrecord(LNAMES,tls_lnames,sizeof(tls_lnames) - 1);
else
objrecord(LNAMES,lnames,sizeof(lnames) - 1);

int dsegattr = I32
? SEG_ATTR(SEG_ALIGN4,SEG_C_PUBLIC,0,USE32)
: SEG_ATTR(SEG_ALIGN2,SEG_C_PUBLIC,0,USE16);

// Put out beginning segment
objsegdef(dsegattr,0,obj.lnameidx,DATACLASS);
obj.lnameidx++;
obj.segidx++;

// Put out segment definition record
segi = obj_newfarseg(0,DATACLASS);
objsegdef(dsegattr,0,obj.lnameidx,DATACLASS);
SegData[segi]->attr = dsegattr;
assert(SegData[segi]->segidx == obj.segidx);

// Put out ending segment
objsegdef(dsegattr,0,obj.lnameidx + 1,DATACLASS);

obj.lnameidx += 2; // for next time
obj.segidx += 2;

// dbg_printf("NOSCAN seg is %d\n", obj.noscansegi);
}
return segi;

}



int Obj::write_pointerInfo(Symbol *s, Symbol *ti)
{
// output address,TypeInfo pair to new segment
int seg = hpseg(s->Sfl == FLtlsdata);
targ_size_t offset = Offset(seg);

int flags = CFoff;
if (I64)
flags |= CFoffset64;

offset += objmod->reftoident(seg, offset, s, 0, flags);
offset += objmod->reftoident(seg, offset, ti, 0, flags);
Offset(seg) = offset;
return 1;
}


/**************************
* Ouput read only data for data.
Expand Down
10 changes: 10 additions & 0 deletions src/backend/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ struct Obj
VIRTUAL void func_start(Symbol *sfunc);
VIRTUAL void func_term(Symbol *sfunc);

#if TARGET_WINDOS
VIRTUAL int write_pointerInfo(Symbol *s, Symbol *ti);
int hpseg(bool tls);
int tlshpseg();
#endif

#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
static unsigned addstr(Outbuffer *strtab, const char *);
static void gotref(symbol *s);
Expand Down Expand Up @@ -182,6 +188,10 @@ struct MsCoffObj : Obj
VIRTUAL void func_start(Symbol *sfunc);
VIRTUAL void func_term(Symbol *sfunc);

#if TARGET_WINDOS
VIRTUAL int write_pointerInfo(Symbol *s, Symbol *ti) { return 0; }
#endif

static int getsegment(const char *sectname, unsigned long flags);
static int getsegment2(unsigned shtidx);
static unsigned addScnhdr(const char *scnhdr_name, unsigned long flags);
Expand Down
11 changes: 10 additions & 1 deletion src/toobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,16 @@ void VarDeclaration::toObjFile(int multiobj)
{
outdata(s);
if (isExport())
objmod->export_symbol(s,0);
objmod->export_symbol(s,0);

#if TARGET_WINDOS
if (type->hasPointers())
{
if (!type->vtinfo)
type->getTypeInfo(NULL); // ensure typeinfo generated
objmod->write_pointerInfo(s, type->vtinfo->toSymbol());
}
#endif
}
}
}
Expand Down

0 comments on commit e6a3d17

Please sign in to comment.