diff --git a/src/backend/elfobj.c b/src/backend/elfobj.c index ec6f63cfce02..6e558203b4c0 100644 --- a/src/backend/elfobj.c +++ b/src/backend/elfobj.c @@ -94,14 +94,13 @@ void elfobj_refGOTsym() if (!GOTsym) { symbol *s = elfobj_getGOTsym(); - objextern(s); + Obj::external(s); } } static void objfile_write(FILE *fd, void *buffer, unsigned len); STATIC char * objmodtoseg (const char *modname); -STATIC void obj_browse_flush(); STATIC void objfixupp (struct FIXUP *); STATIC void ledata_new (int seg,targ_size_t offset); void obj_tlssections(); @@ -582,7 +581,7 @@ symbol *elf_sym_cdata(tym_t ty,char *p,int len) //printf("elf_sym_cdata(ty = %x, p = %x, len = %d, CDoffset = %x)\n", ty, p, len, CDoffset); alignOffset(CDATA, tysize(ty)); s = symboldata(CDoffset, ty); - obj_bytes(CDATA, CDoffset, len, p); + Obj::bytes(CDATA, CDoffset, len, p); s->Sseg = CDATA; } @@ -598,7 +597,7 @@ symbol *elf_sym_cdata(tym_t ty,char *p,int len) * offset of that data */ -int elf_data_cdata(char *p, int len, int *pseg) +int Obj::data_readonly(char *p, int len, int *pseg) { int oldoff; /*if (OPT_IS_SET(OPTfwritable_strings)) @@ -620,11 +619,11 @@ int elf_data_cdata(char *p, int len, int *pseg) return oldoff; } -int elf_data_cdata(char *p, int len) +int Obj::data_readonly(char *p, int len) { int pseg; - return elf_data_cdata(p, len, &pseg); + return Obj::data_readonly(p, len, &pseg); } /****************************** @@ -632,9 +631,9 @@ int elf_data_cdata(char *p, int len) * Called before any other obj_xxx routines */ -void obj_init(Outbuffer *objbuf, const char *filename, const char *csegname) +void Obj::init(Outbuffer *objbuf, const char *filename, const char *csegname) { - //printf("obj_init()\n"); + //printf("Obj::init()\n"); cseg = CODE; fobjbuf = objbuf; @@ -815,9 +814,9 @@ void obj_init(Outbuffer *objbuf, const char *filename, const char *csegname) * csegname: User specified default code segment name */ -void obj_initfile(const char *filename, const char *csegname, const char *modname) +void Obj::initfile(const char *filename, const char *csegname, const char *modname) { - //dbg_printf("obj_initfile(filename = %s, modname = %s)\n",filename,modname); + //dbg_printf("Obj::initfile(filename = %s, modname = %s)\n",filename,modname); IDXSTR name = elf_addstr(symtab_strings, filename); if (I64) @@ -962,9 +961,9 @@ void *elf_renumbersyms() * Fixup and terminate object file. */ -void obj_termfile() +void Obj::termfile() { - //dbg_printf("obj_termfile\n"); + //dbg_printf("Obj::termfile\n"); if (configv.addlinenumbers) { dwarf_termmodule(); @@ -975,9 +974,9 @@ void obj_termfile() * Terminate package. */ -void obj_term() +void Obj::term() { - //printf("obj_term()\n"); + //printf("Obj::term()\n"); #if SCPP if (!errcnt) #endif @@ -1272,14 +1271,14 @@ void obj_term() * cseg current code segment */ -void objlinnum(Srcpos srcpos, targ_size_t offset) +void Obj::linnum(Srcpos srcpos, targ_size_t offset) { if (srcpos.Slinnum == 0) return; #if 0 #if MARS || SCPP - printf("objlinnum(cseg=%d, offset=0x%lx) ", cseg, offset); + printf("Obj::linnum(cseg=%d, offset=0x%lx) ", cseg, offset); #endif srcpos.print(""); #endif @@ -1350,9 +1349,9 @@ void objlinnum(Srcpos srcpos, targ_size_t offset) * Set start address */ -void obj_startaddress(Symbol *s) +void Obj::startaddress(Symbol *s) { - //dbg_printf("obj_startaddress(Symbol *%s)\n",s->Sident); + //dbg_printf("Obj::startaddress(Symbol *%s)\n",s->Sident); //obj.startaddress = s; } @@ -1360,9 +1359,9 @@ void obj_startaddress(Symbol *s) * Output library name. */ -bool obj_includelib(const char *name) +bool Obj::includelib(const char *name) { - //dbg_printf("obj_includelib(name *%s)\n",name); + //dbg_printf("Obj::includelib(name *%s)\n",name); return false; } @@ -1370,7 +1369,7 @@ bool obj_includelib(const char *name) * Do we allow zero sized objects? */ -bool obj_allowZeroSize() +bool Obj::allowZeroSize() { return true; } @@ -1379,27 +1378,27 @@ bool obj_allowZeroSize() * Embed string in executable. */ -void obj_exestr(const char *p) +void Obj::exestr(const char *p) { - //dbg_printf("obj_exestr(char *%s)\n",p); + //dbg_printf("Obj::exestr(char *%s)\n",p); } /************************** * Embed string in obj. */ -void obj_user(const char *p) +void Obj::user(const char *p) { - //dbg_printf("obj_user(char *%s)\n",p); + //dbg_printf("Obj::user(char *%s)\n",p); } /******************************* * Output a weak extern record. */ -void obj_wkext(Symbol *s1,Symbol *s2) +void Obj::wkext(Symbol *s1,Symbol *s2) { - //dbg_printf("obj_wkext(Symbol *%s,Symbol *s2)\n",s1->Sident,s2->Sident); + //dbg_printf("Obj::wkext(Symbol *%s,Symbol *s2)\n",s1->Sident,s2->Sident); } /******************************* @@ -1420,11 +1419,11 @@ void obj_filename(const char *modname) * Embed compiler version in .obj file. */ -void obj_compiler() +void Obj::compiler() { - //dbg_printf("obj_compiler\n"); + //dbg_printf("Obj::compiler\n"); comment_data = new Outbuffer(); - comment_data->write(compiler,sizeof(compiler)); + comment_data->write(::compiler,sizeof(::compiler)); //dbg_printf("Comment data size %d\n",comment_data->size()); } @@ -1443,13 +1442,13 @@ void obj_compiler() * 3: compiler */ -void obj_staticctor(Symbol *s,int dtor,int none) +void Obj::staticctor(Symbol *s,int dtor,int none) { // Static constructors and destructors IDXSEC seg; Outbuffer *buf; - //dbg_printf("obj_staticctor(%s) offset %x\n",s->Sident,s->Soffset); + //dbg_printf("Obj::staticctor(%s) offset %x\n",s->Sident,s->Soffset); //symbol_print(s); s->Sseg = seg = elf_getsegment(".ctors", NULL, SHT_PROGDEF, SHF_ALLOC|SHF_WRITE, 4); @@ -1470,12 +1469,12 @@ void obj_staticctor(Symbol *s,int dtor,int none) * s static destructor function */ -void obj_staticdtor(Symbol *s) +void Obj::staticdtor(Symbol *s) { IDXSEC seg; Outbuffer *buf; - //dbg_printf("obj_staticdtor(%s) offset %x\n",s->Sident,s->Soffset); + //dbg_printf("Obj::staticdtor(%s) offset %x\n",s->Sident,s->Soffset); //symbol_print(s); seg = elf_getsegment(".dtors", NULL, SHT_PROGDEF, SHF_ALLOC|SHF_WRITE, 4); buf = SegData[seg]->SDbuf; @@ -1494,9 +1493,9 @@ void obj_staticdtor(Symbol *s) * Used for static ctor and dtor lists. */ -void obj_funcptr(Symbol *s) +void Obj::funcptr(Symbol *s) { - //dbg_printf("obj_funcptr(%s) \n",s->Sident); + //dbg_printf("Obj::funcptr(%s) \n",s->Sident); } //#endif @@ -1508,9 +1507,9 @@ void obj_funcptr(Symbol *s) * length of function */ -void obj_ehtables(Symbol *sfunc,targ_size_t size,Symbol *ehsym) +void Obj::ehtables(Symbol *sfunc,targ_size_t size,Symbol *ehsym) { - //dbg_printf("obj_ehtables(%s) \n",sfunc->Sident); + //dbg_printf("Obj::ehtables(%s) \n",sfunc->Sident); symbol *ehtab_entry = symbol_generate(SCstatic,type_alloc(TYint)); symbol_keep(ehtab_entry); @@ -1550,10 +1549,10 @@ void obj_ehtables(Symbol *sfunc,targ_size_t size,Symbol *ehsym) * Put out symbols that define the beginning/end of the .deh_eh section. */ -void obj_ehsections() +void Obj::ehsections() { int sec = elf_getsegment(".deh_beg", NULL, SHT_PROGDEF, SHF_ALLOC, NPTRSIZE); - //obj_bytes(sec, 0, 4, NULL); + //Obj::bytes(sec, 0, 4, NULL); IDXSTR namidx = elf_addstr(symtab_strings,"_deh_beg"); elf_addsym(namidx, 0, 4, STT_OBJECT, STB_GLOBAL, MAP_SEG2SECIDX(sec)); @@ -1578,7 +1577,7 @@ void obj_tlssections() int align = I64 ? 16 : 4; int sec = elf_getsegment(".tdata", NULL, SHT_PROGDEF, SHF_ALLOC|SHF_WRITE|SHF_TLS, align); - obj_bytes(sec, 0, align, NULL); + Obj::bytes(sec, 0, align, NULL); namidx = elf_addstr(symtab_strings,"_tlsstart"); elf_addsym(namidx, 0, align, STT_TLS, STB_GLOBAL, MAP_SEG2SECIDX(sec)); @@ -1606,7 +1605,7 @@ STATIC void setup_comdat(Symbol *s) int flags; int align = 4; - //printf("obj_comdat(Symbol *%s\n",s->Sident); + //printf("Obj::comdat(Symbol *%s\n",s->Sident); //symbol_print(s); symbol_debug(s); if (tyfunc(s->ty())) @@ -1649,23 +1648,23 @@ STATIC void setup_comdat(Symbol *s) SegData[s->Sseg]->SDsym = s; } -int obj_comdat(Symbol *s) +int Obj::comdat(Symbol *s) { setup_comdat(s); if (s->Sfl == FLdata || s->Sfl == FLtlsdata) { - objpubdef(s->Sseg,s,0); + Obj::pubdef(s->Sseg,s,0); searchfixlist(s); // backpatch any refs to this symbol } return s->Sseg; } -int obj_comdatsize(Symbol *s, targ_size_t symsize) +int Obj::comdatsize(Symbol *s, targ_size_t symsize) { setup_comdat(s); if (s->Sfl == FLdata || s->Sfl == FLtlsdata) { - objpubdefsize(s->Sseg,s,0,symsize); + Obj::pubdefsize(s->Sseg,s,0,symsize); searchfixlist(s); // backpatch any refs to this symbol } s->Soffset = 0; @@ -1776,12 +1775,12 @@ int elf_getsegment(const char *name, const char *suffix, int type, int flags, * segment index of newly created code segment */ -int obj_codeseg(char *name,int suffix) +int Obj::codeseg(char *name,int suffix) { int seg; const char *sfx; - //dbg_printf("obj_codeseg(%s,%x)\n",name,suffix); + //dbg_printf("Obj::codeseg(%s,%x)\n",name,suffix); sfx = (suffix) ? "_TEXT" : NULL; @@ -1838,7 +1837,7 @@ int obj_codeseg(char *name,int suffix) * segment for TLS segment */ -seg_data *obj_tlsseg() +seg_data *Obj::tlsseg() { /* Ensure that ".tdata" precedes any other .tdata. section, as the ld * linker script fails to work right. @@ -1846,7 +1845,7 @@ seg_data *obj_tlsseg() elf_getsegment(".tdata", NULL, SHT_PROGDEF, SHF_ALLOC|SHF_WRITE|SHF_TLS, 4); static const char tlssegname[] = ".tdata."; - //dbg_printf("obj_tlsseg(\n"); + //dbg_printf("Obj::tlsseg(\n"); if (seg_tlsseg == UNKNOWN) { @@ -1865,10 +1864,10 @@ seg_data *obj_tlsseg() * segment for TLS segment */ -seg_data *obj_tlsseg_bss() +seg_data *Obj::tlsseg_bss() { static const char tlssegname[] = ".tbss"; - //dbg_printf("obj_tlsseg_bss(\n"); + //dbg_printf("Obj::tlsseg_bss(\n"); if (seg_tlsseg_bss == UNKNOWN) { @@ -1883,9 +1882,9 @@ seg_data *obj_tlsseg_bss() * Output an alias definition record. */ -void obj_alias(const char *n1,const char *n2) +void Obj::alias(const char *n1,const char *n2) { - dbg_printf("obj_alias(%s,%s)\n",n1,n2); + dbg_printf("Obj::alias(%s,%s)\n",n1,n2); assert(0); #if NOT_DONE char *buffer = (char *) alloca(strlen(n1) + strlen(n2) + 2 * ONS_OHD); @@ -1913,7 +1912,7 @@ char *obj_mangle2(Symbol *s,char *dest) { char *name; - //dbg_printf("obj_mangle('%s'), mangle = x%x\n",s->Sident,type_mangle(s->Stype)); + //dbg_printf("Obj::mangle('%s'), mangle = x%x\n",s->Sident,type_mangle(s->Stype)); symbol_debug(s); assert(dest); #if SCPP @@ -1986,9 +1985,9 @@ char *obj_mangle2(Symbol *s,char *dest) * Export a function name. */ -void obj_export(Symbol *s,unsigned argsize) +void Obj::export_symbol(Symbol *s,unsigned argsize) { - //dbg_printf("obj_export(%s,%d)\n",s->Sident,argsize); + //dbg_printf("Obj::export_symbol(%s,%d)\n",s->Sident,argsize); } /******************************* @@ -2004,10 +2003,10 @@ void obj_export(Symbol *s,unsigned argsize) * actual seg */ -int elf_data_start(Symbol *sdata, targ_size_t datasize, int seg) +int Obj::data_start(Symbol *sdata, targ_size_t datasize, int seg) { targ_size_t alignbytes; - //printf("elf_data_start(%s,size %llx,seg %d)\n",sdata->Sident,datasize,seg); + //printf("Obj::data_start(%s,size %llx,seg %d)\n",sdata->Sident,datasize,seg); //symbol_print(sdata); if (sdata->Sseg == UNKNOWN) // if we don't know then there @@ -2023,7 +2022,7 @@ int elf_data_start(Symbol *sdata, targ_size_t datasize, int seg) else alignbytes = align(datasize, offset) - offset; if (alignbytes) - obj_lidata(seg, offset, alignbytes); + Obj::lidata(seg, offset, alignbytes); sdata->Soffset = offset + alignbytes; return seg; } @@ -2051,7 +2050,7 @@ void elf_func_start(Symbol *sfunc) //dbg_printf("sfunc->Sseg %d CODE %d cseg %d Coffset %d\n",sfunc->Sseg,CODE,cseg,Coffset); cseg = sfunc->Sseg; assert(cseg == CODE || cseg > COMD); - objpubdef(cseg, sfunc, Coffset); + Obj::pubdef(cseg, sfunc, Coffset); sfunc->Soffset = Coffset; if (config.fulltypes) @@ -2084,11 +2083,11 @@ void elf_func_term(Symbol *sfunc) * offset = offset of name within segment */ -void objpubdef(int seg, Symbol *s, targ_size_t offset) +void Obj::pubdef(int seg, Symbol *s, targ_size_t offset) { const targ_size_t symsize= tyfunc(s->ty()) ? Offset(s->Sseg) - offset : type_size(s->Stype); - objpubdefsize(seg, s, offset, symsize); + Obj::pubdefsize(seg, s, offset, symsize); } /******************************** @@ -2100,7 +2099,7 @@ void objpubdef(int seg, Symbol *s, targ_size_t offset) * symsize size of symbol */ -void objpubdefsize(int seg, Symbol *s, targ_size_t offset, targ_size_t symsize) +void Obj::pubdefsize(int seg, Symbol *s, targ_size_t offset, targ_size_t symsize) { int bind; switch (s->Sclass) @@ -2119,7 +2118,7 @@ void objpubdefsize(int seg, Symbol *s, targ_size_t offset, targ_size_t symsize) } #if 0 - //printf("\nobjpubdef(%d,%s,%d)\n",seg,s->Sident,offset); + //printf("\nObj::pubdef(%d,%s,%d)\n",seg,s->Sident,offset); //symbol_print(s); #endif @@ -2150,18 +2149,18 @@ void objpubdefsize(int seg, Symbol *s, targ_size_t offset, targ_size_t symsize) * NOTE: Numbers will not be linear. */ -int objextern(const char *name) +int Obj::external(const char *name) { - //dbg_printf("objextdef('%s')\n",name); + //dbg_printf("Obj::external_def('%s')\n",name); assert(name); IDXSTR namidx = elf_addstr(symtab_strings,name); IDXSYM symidx = elf_addsym(namidx, 0, 0, STT_NOTYPE, STB_GLOBAL, SHT_UNDEF); return symidx; } -int objextdef(const char *name) +int Obj::external_def(const char *name) { - return objextern(name); + return Obj::external(name); } /******************************* @@ -2174,12 +2173,12 @@ int objextdef(const char *name) * NOTE: Numbers will not be linear. */ -int objextern(Symbol *s) +int Obj::external(Symbol *s) { int symtype,sectype; unsigned size; - //dbg_printf("objextern('%s') %x\n",s->Sident,s->Svalue); + //dbg_printf("Obj::external('%s') %x\n",s->Sident,s->Svalue); symbol_debug(s); IDXSTR namidx = elf_addmangled(s); @@ -2199,7 +2198,7 @@ int objextern(Symbol *s) } if (s->ty() & mTYthread) { - //printf("objextern('%s') %x TLS\n",s->Sident,s->Svalue); + //printf("Obj::external('%s') %x TLS\n",s->Sident,s->Svalue); symtype = STT_TLS; } @@ -2219,9 +2218,9 @@ int objextern(Symbol *s) * Symbol table index for symbol */ -int obj_comdef(Symbol *s,targ_size_t size,targ_size_t count) +int Obj::common_block(Symbol *s,targ_size_t size,targ_size_t count) { - //printf("obj_comdef('%s',%d,%d)\n",s->Sident,size,count); + //printf("Obj::common_block('%s',%d,%d)\n",s->Sident,size,count); symbol_debug(s); int align = I64 ? 16 : 4; @@ -2232,7 +2231,7 @@ int obj_comdef(Symbol *s,targ_size_t size,targ_size_t count) s->Sfl = FLtlsdata; SegData[s->Sseg]->SDsym = s; SegData[s->Sseg]->SDoffset += size * count; - objpubdef(s->Sseg, s, 0); + Obj::pubdef(s->Sseg, s, 0); searchfixlist(s); return s->Sseg; } @@ -2243,7 +2242,7 @@ int obj_comdef(Symbol *s,targ_size_t size,targ_size_t count) s->Sfl = FLudata; SegData[s->Sseg]->SDsym = s; SegData[s->Sseg]->SDoffset += size * count; - objpubdef(s->Sseg, s, 0); + Obj::pubdef(s->Sseg, s, 0); searchfixlist(s); return s->Sseg; } @@ -2253,7 +2252,7 @@ int obj_comdef(Symbol *s,targ_size_t size,targ_size_t count) IDXSYM symidx = elf_addsym(namidx, SegData[UDATA]->SDoffset, size*count, (s->ty() & mTYthread) ? STT_TLS : STT_OBJECT, STB_WEAK, SHI_BSS); - //dbg_printf("\tobj_comdef returning symidx %d\n",symidx); + //dbg_printf("\tObj::common_block returning symidx %d\n",symidx); s->Sseg = UDATA; s->Sfl = FLudata; SegData[UDATA]->SDoffset += size * count; @@ -2261,9 +2260,9 @@ int obj_comdef(Symbol *s,targ_size_t size,targ_size_t count) #endif } -int obj_comdef(Symbol *s, int flag, targ_size_t size, targ_size_t count) +int Obj::common_block(Symbol *s, int flag, targ_size_t size, targ_size_t count) { - return obj_comdef(s, size, count); + return Obj::common_block(s, size, count); } /*************************************** @@ -2271,9 +2270,9 @@ int obj_comdef(Symbol *s, int flag, targ_size_t size, targ_size_t count) * (uninitialized data only) */ -void obj_write_zeros(seg_data *pseg, targ_size_t count) +void Obj::write_zeros(seg_data *pseg, targ_size_t count) { - obj_lidata(pseg->SDseg, pseg->SDoffset, count); + Obj::lidata(pseg->SDseg, pseg->SDoffset, count); } /*************************************** @@ -2282,9 +2281,9 @@ void obj_write_zeros(seg_data *pseg, targ_size_t count) * For boundary alignment and initialization */ -void obj_lidata(int seg,targ_size_t offset,targ_size_t count) +void Obj::lidata(int seg,targ_size_t offset,targ_size_t count) { - //printf("obj_lidata(%d,%x,%d)\n",seg,offset,count); + //printf("Obj::lidata(%d,%x,%d)\n",seg,offset,count); if (seg == UDATA || seg == UNKNOWN) { // Use SDoffset to record size of .BSS section SegData[UDATA]->SDoffset += count; @@ -2295,7 +2294,7 @@ void obj_lidata(int seg,targ_size_t offset,targ_size_t count) } else { - obj_bytes(seg, offset, count, NULL); + Obj::bytes(seg, offset, count, NULL); } } @@ -2303,20 +2302,20 @@ void obj_lidata(int seg,targ_size_t offset,targ_size_t count) * Append byte to segment. */ -void obj_write_byte(seg_data *pseg, unsigned byte) +void Obj::write_byte(seg_data *pseg, unsigned byte) { - obj_byte(pseg->SDseg, pseg->SDoffset, byte); + Obj::byte(pseg->SDseg, pseg->SDoffset, byte); } /************************************ * Output byte to object file. */ -void obj_byte(int seg,targ_size_t offset,unsigned byte) +void Obj::byte(int seg,targ_size_t offset,unsigned byte) { Outbuffer *buf = SegData[seg]->SDbuf; int save = buf->size(); - //dbg_printf("obj_byte(seg=%d, offset=x%lx, byte=x%x)\n",seg,offset,byte); + //dbg_printf("Obj::byte(seg=%d, offset=x%lx, byte=x%x)\n",seg,offset,byte); buf->setsize(offset); buf->writeByte(byte); if (save > offset+1) @@ -2330,9 +2329,9 @@ void obj_byte(int seg,targ_size_t offset,unsigned byte) * Append bytes to segment. */ -void obj_write_bytes(seg_data *pseg, unsigned nbytes, void *p) +void Obj::write_bytes(seg_data *pseg, unsigned nbytes, void *p) { - obj_bytes(pseg->SDseg, pseg->SDoffset, nbytes, p); + Obj::bytes(pseg->SDseg, pseg->SDoffset, nbytes, p); } /************************************ @@ -2341,11 +2340,11 @@ void obj_write_bytes(seg_data *pseg, unsigned nbytes, void *p) * nbytes */ -unsigned obj_bytes(int seg, targ_size_t offset, unsigned nbytes, void *p) +unsigned Obj::bytes(int seg, targ_size_t offset, unsigned nbytes, void *p) { #if 0 if (!(seg >= 0 && seg <= seg_count)) - { printf("obj_bytes: seg = %d, seg_count = %d\n", seg, seg_count); + { printf("Obj::bytes: seg = %d, seg_count = %d\n", seg, seg_count); *(char*)0=0; } #endif @@ -2353,12 +2352,12 @@ unsigned obj_bytes(int seg, targ_size_t offset, unsigned nbytes, void *p) Outbuffer *buf = SegData[seg]->SDbuf; if (buf == NULL) { - //dbg_printf("obj_bytes(seg=%d, offset=x%lx, nbytes=%d, p=x%x)\n", seg, offset, nbytes, p); + //dbg_printf("Obj::bytes(seg=%d, offset=x%lx, nbytes=%d, p=x%x)\n", seg, offset, nbytes, p); //raise(SIGSEGV); assert(buf != NULL); } int save = buf->size(); - //dbg_printf("obj_bytes(seg=%d, offset=x%lx, nbytes=%d, p=x%x)\n", + //dbg_printf("Obj::bytes(seg=%d, offset=x%lx, nbytes=%d, p=x%x)\n", //seg,offset,nbytes,p); buf->setsize(offset); buf->reserve(nbytes); @@ -2431,7 +2430,7 @@ void elf_addrel(int seg, targ_size_t offset, unsigned type, if (I64) { /* Note that we're using Elf32_Shdr here instead of Elf64_Shdr. This is to make - * the code a bit simpler. In obj_term(), we translate the Elf32_Shdr into the proper + * the code a bit simpler. In Obj::term(), we translate the Elf32_Shdr into the proper * Elf64_Shdr. */ Elf32_Shdr *relsec = &SecHdrTab[relidx]; @@ -2518,10 +2517,10 @@ void elf_addrel(int seg, targ_size_t offset, unsigned type, * Example: * int *abc = &def[3]; * to allocate storage: - * reftodatseg(DATA,offset,3 * sizeof(int *),UDATA); + * Obj::reftodatseg(DATA,offset,3 * sizeof(int *),UDATA); */ -void reftodatseg(int seg,targ_size_t offset,targ_size_t val, +void Obj::reftodatseg(int seg,targ_size_t offset,targ_size_t val, unsigned targetdatum,int flags) { Outbuffer *buf; @@ -2531,7 +2530,7 @@ void reftodatseg(int seg,targ_size_t offset,targ_size_t val, save = buf->size(); buf->setsize(offset); #if 0 - printf("reftodatseg(seg=%d, offset=x%llx, val=x%llx,data %x, flags %x)\n", + printf("Obj::reftodatseg(seg=%d, offset=x%llx, val=x%llx,data %x, flags %x)\n", seg,(unsigned long long)offset,(unsigned long long)val,targetdatum,flags); #endif /*if (OPT_IS_SET(OPTfwritable_strings)) @@ -2590,13 +2589,13 @@ void reftodatseg(int seg,targ_size_t offset,targ_size_t val, * val = displacement from start of this module */ -void reftocodseg(int seg,targ_size_t offset,targ_size_t val) +void Obj::reftocodeseg(int seg,targ_size_t offset,targ_size_t val) { Outbuffer *buf; int save; int segtyp = MAP_SEG2TYP(seg); - //dbg_printf("reftocodseg(seg=%d, offset=x%lx, val=x%lx )\n",seg,offset,val); + //dbg_printf("Obj::reftocodeseg(seg=%d, offset=x%lx, val=x%lx )\n",seg,offset,val); assert(seg > 0); // COMDATs not done yet buf = SegData[seg]->SDbuf; save = buf->size(); @@ -2640,7 +2639,7 @@ void reftocodseg(int seg,targ_size_t offset,targ_size_t val) * number of bytes in reference (4 or 8) */ -int reftoident(int seg, targ_size_t offset, Symbol *s, targ_size_t val, +int Obj::reftoident(int seg, targ_size_t offset, Symbol *s, targ_size_t val, int flags) { bool external = TRUE; @@ -2652,7 +2651,7 @@ int reftoident(int seg, targ_size_t offset, Symbol *s, targ_size_t val, targ_size_t v = 0; #if 0 - printf("\nreftoident('%s' seg %d, offset x%llx, val x%llx, flags x%x)\n", + printf("\nObj::reftoident('%s' seg %d, offset x%llx, val x%llx, flags x%x)\n", s->Sident,seg,offset,val,flags); dbg_printf("Sseg = %d, Sxtrnnum = %d, retsize = %d\n",s->Sseg,s->Sxtrnnum,retsize); symbol_print(s); @@ -2918,9 +2917,9 @@ int reftoident(int seg, targ_size_t offset, Symbol *s, targ_size_t val, * s Symbol to generate a thunk for */ -void obj_far16thunk(Symbol *s) +void Obj::far16thunk(Symbol *s) { - //dbg_printf("obj_far16thunk('%s')\n", s->Sident); + //dbg_printf("Obj::far16thunk('%s')\n", s->Sident); assert(0); } @@ -2928,9 +2927,9 @@ void obj_far16thunk(Symbol *s) * Mark object file as using floating point. */ -void obj_fltused() +void Obj::fltused() { - //dbg_printf("obj_fltused()\n"); + //dbg_printf("Obj::fltused()\n"); } /************************************ @@ -2978,7 +2977,7 @@ long elf_align(targ_size_t size,long foffset) #if MARS -void obj_moduleinfo(Symbol *scc) +void Obj::moduleinfo(Symbol *scc) { // if (I64) return; // for now, until Phobos64 works @@ -2998,7 +2997,7 @@ void obj_moduleinfo(Symbol *scc) refOffset = SegData[seg]->SDoffset; SegData[seg]->SDbuf->writezeros(NPTRSIZE); SegData[seg]->SDoffset += NPTRSIZE; - SegData[seg]->SDoffset += reftoident(seg, SegData[seg]->SDoffset, scc, 0, CFoffset64 | CFoff); + SegData[seg]->SDoffset += Obj::reftoident(seg, SegData[seg]->SDoffset, scc, 0, CFoffset64 | CFoff); } /* Constructor that links the ModuleReference to the head of @@ -3035,7 +3034,7 @@ void obj_moduleinfo(Symbol *scc) buf->writeByte(0x8B); buf->writeByte(modregrm(0,CX,5)); buf->write32(0); - elf_addrel(seg, codeOffset + 10, R_X86_64_GOTPCREL, objextern("_Dmodule_ref"), -4); + elf_addrel(seg, codeOffset + 10, R_X86_64_GOTPCREL, Obj::external("_Dmodule_ref"), -4); } else { @@ -3049,7 +3048,7 @@ void obj_moduleinfo(Symbol *scc) /* movl _Dmodule_ref, %ecx */ buf->writeByte(0xB9); buf->write32(0); - elf_addrel(seg, codeOffset + 6, reltype, objextern("_Dmodule_ref"), 0); + elf_addrel(seg, codeOffset + 6, reltype, Obj::external("_Dmodule_ref"), 0); } if (I64)