00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __SYMTAB_H__
00032 #define __SYMTAB_H__
00033
00034 #include <set>
00035
00036 #include "Symbol.h"
00037 #include "Module.h"
00038 #include "Region.h"
00039
00040 #include "Annotatable.h"
00041 #include "Serialization.h"
00042
00043 #include "ProcReader.h"
00044
00045 #include "boost/shared_ptr.hpp"
00046
00047 class MappedFile;
00048
00049 #define SYM_MAJOR 8
00050 #define SYM_MINOR 1
00051 #define SYM_BETA 2
00052
00053 namespace Dyninst {
00054
00055 struct SymSegment;
00056
00057 namespace SymtabAPI {
00058
00059 class Archive;
00060 class builtInTypeCollection;
00061
00062 class ExceptionBlock;
00063 class Object;
00064 class localVar;
00065 class relocationEntry;
00066 class Type;
00067
00068 typedef Dyninst::ProcessReader MemRegReader;
00069
00070 class Symtab : public LookupInterface,
00071 public Serializable,
00072 public AnnotatableSparse
00073 {
00074
00075 friend class Archive;
00076 friend class Symbol;
00077 friend class Function;
00078 friend class Variable;
00079 friend class Module;
00080 friend class Region;
00081 friend class emitElf;
00082 friend class emitElf64;
00083 friend class emitElfStatic;
00084 friend class emitWin;
00085 friend class Aggregate;
00086 friend class relocationEntry;
00087
00088 public:
00089
00090
00091
00092 public:
00093 SYMTAB_EXPORT static void version(int& major, int& minor, int& maintenance);
00094 SYMTAB_EXPORT Symtab(MappedFile *);
00095
00096 SYMTAB_EXPORT Symtab();
00097
00098 SYMTAB_EXPORT Symtab(const Symtab& obj);
00099 SYMTAB_EXPORT Symtab(unsigned char *mem_image, size_t image_size,
00100 const std::string &name, bool defensive_binary, bool &err);
00101
00102 typedef enum {
00103 NotDefensive,
00104 Defensive} def_t;
00105
00106 SYMTAB_EXPORT static bool openFile(Symtab *&obj, std::string filename,
00107 def_t defensive_binary = NotDefensive);
00108 SYMTAB_EXPORT static bool openFile(Symtab *&obj, void *mem_image, size_t size,
00109 std::string name, def_t defensive_binary = NotDefensive);
00110 SYMTAB_EXPORT static Symtab *findOpenSymtab(std::string filename);
00111 SYMTAB_EXPORT static bool closeSymtab(Symtab *);
00112
00113 SYMTAB_EXPORT Serializable * serialize_impl(SerializerBase *sb,
00114 const char *tag = "Symtab") THROW_SPEC (SerializerError);
00115 void rebuild_symbol_hashes(SerializerBase *);
00116 void rebuild_funcvar_hashes(SerializerBase *);
00117 void rebuild_module_hashes(SerializerBase *);
00118 void rebuild_region_indexes(SerializerBase *) THROW_SPEC(SerializerError);
00119 static bool setup_module_up_ptrs(SerializerBase *,Symtab *st);
00120 static bool fixup_relocation_symbols(SerializerBase *,Symtab *st);
00121
00122 SYMTAB_EXPORT bool exportXML(std::string filename);
00123 SYMTAB_EXPORT bool exportBin(std::string filename);
00124 static Symtab *importBin(std::string filename);
00125 SYMTAB_EXPORT bool getRegValueAtFrame(Address pc,
00126 Dyninst::MachRegister reg,
00127 Dyninst::MachRegisterVal ®_result,
00128 MemRegReader *reader);
00129 SYMTAB_EXPORT bool hasStackwalkDebugInfo();
00130
00131
00132
00133
00134
00135
00136
00137 SYMTAB_EXPORT virtual bool findSymbol(std::vector<Symbol *> &ret,
00138 const std::string& name,
00139 Symbol::SymbolType sType = Symbol::ST_UNKNOWN,
00140 NameType nameType = anyName,
00141 bool isRegex = false,
00142 bool checkCase = false,
00143 bool includeUndefined = false);
00144
00145 SYMTAB_EXPORT virtual bool getAllSymbols(std::vector<Symbol *> &ret);
00146 SYMTAB_EXPORT virtual bool getAllSymbolsByType(std::vector<Symbol *> &ret,
00147 Symbol::SymbolType sType);
00148
00149 std::vector<Symbol *> *findSymbolByOffset(Offset);
00150
00151
00152
00153 SYMTAB_EXPORT bool getAllUndefinedSymbols(std::vector<Symbol *> &ret);
00154
00155
00156 SYMTAB_EXPORT bool getAllDefinedSymbols(std::vector<Symbol *> &ret);
00157
00158
00159
00160 SYMTAB_EXPORT bool findFuncByEntryOffset(Function *&ret, const Offset offset);
00161 SYMTAB_EXPORT bool findFunctionsByName(std::vector<Function *> &ret, const std::string name,
00162 NameType nameType = anyName,
00163 bool isRegex = false,
00164 bool checkCase = true);
00165 SYMTAB_EXPORT bool getAllFunctions(std::vector<Function *>&ret);
00166 SYMTAB_EXPORT bool getContainingFunction(Offset offset, Function* &func);
00167
00168
00169 SYMTAB_EXPORT bool findVariableByOffset(Variable *&ret, const Offset offset);
00170 SYMTAB_EXPORT bool findVariablesByName(std::vector<Variable *> &ret, const std::string name,
00171 NameType nameType = anyName,
00172 bool isRegex = false,
00173 bool checkCase = true);
00174 SYMTAB_EXPORT bool getAllVariables(std::vector<Variable *> &ret);
00175
00176
00177
00178 SYMTAB_EXPORT bool getAllModules(std::vector<Module *>&ret);
00179 SYMTAB_EXPORT bool findModuleByOffset(Module *&ret, Offset off);
00180 SYMTAB_EXPORT bool findModuleByName(Module *&ret, const std::string name);
00181 SYMTAB_EXPORT Module *getDefaultModule();
00182
00183
00184
00185 SYMTAB_EXPORT bool getCodeRegions(std::vector<Region *>&ret);
00186 SYMTAB_EXPORT bool getDataRegions(std::vector<Region *>&ret);
00187 SYMTAB_EXPORT bool getAllRegions(std::vector<Region *>&ret);
00188 SYMTAB_EXPORT bool getAllNewRegions(std::vector<Region *>&ret);
00189
00190 SYMTAB_EXPORT bool findRegion(Region *&ret, std::string regname);
00191 SYMTAB_EXPORT bool findRegion(Region *&ret, const Offset addr, const unsigned long size);
00192 SYMTAB_EXPORT bool findRegionByEntry(Region *&ret, const Offset offset);
00193 SYMTAB_EXPORT Region *findEnclosingRegion(const Offset offset);
00194
00195
00196 SYMTAB_EXPORT bool findException(ExceptionBlock &excp,Offset addr);
00197 SYMTAB_EXPORT bool getAllExceptions(std::vector<ExceptionBlock *> &exceptions);
00198 SYMTAB_EXPORT bool findCatchBlock(ExceptionBlock &excp, Offset addr,
00199 unsigned size = 0);
00200
00201
00202 SYMTAB_EXPORT bool getFuncBindingTable(std::vector<relocationEntry> &fbt) const;
00203 SYMTAB_EXPORT bool updateFuncBindingTable(Offset stub_addr, Offset plt_addr);
00204
00205
00206
00207
00208
00209 SYMTAB_EXPORT bool addSymbol(Symbol *newsym);
00210 SYMTAB_EXPORT bool addSymbol(Symbol *newSym, Symbol *referringSymbol);
00211 SYMTAB_EXPORT Function *createFunction(std::string name, Offset offset, size_t size, Module *mod = NULL);
00212 SYMTAB_EXPORT Variable *createVariable(std::string name, Offset offset, size_t size, Module *mod = NULL);
00213
00214 SYMTAB_EXPORT bool deleteFunction(Function *func);
00215 SYMTAB_EXPORT bool deleteVariable(Variable *var);
00216
00217
00218
00219 SYMTAB_EXPORT bool isExec() const;
00220 SYMTAB_EXPORT bool isStripped();
00221 SYMTAB_EXPORT ObjectType getObjectType() const;
00222 SYMTAB_EXPORT Dyninst::Architecture getArchitecture();
00223 SYMTAB_EXPORT bool isCode(const Offset where) const;
00224 SYMTAB_EXPORT bool isData(const Offset where) const;
00225 SYMTAB_EXPORT bool isValidOffset(const Offset where) const;
00226
00227 SYMTAB_EXPORT bool isNativeCompiler() const;
00228 SYMTAB_EXPORT bool getMappedRegions(std::vector<Region *> &mappedRegs) const;
00229
00230
00231 SYMTAB_EXPORT bool getAddressRanges(std::vector<std::pair<Offset, Offset> >&ranges,
00232 std::string lineSource, unsigned int LineNo);
00233 SYMTAB_EXPORT bool getSourceLines(std::vector<Statement *> &lines,
00234 Offset addressInRange);
00235 SYMTAB_EXPORT bool getSourceLines(std::vector<LineNoTuple> &lines,
00236 Offset addressInRange);
00237 SYMTAB_EXPORT bool addLine(std::string lineSource, unsigned int lineNo,
00238 unsigned int lineOffset, Offset lowInclAddr,
00239 Offset highExclAddr);
00240 SYMTAB_EXPORT bool addAddressRange(Offset lowInclAddr, Offset highExclAddr, std::string lineSource,
00241 unsigned int lineNo, unsigned int lineOffset = 0);
00242 SYMTAB_EXPORT void setTruncateLinePaths(bool value);
00243 SYMTAB_EXPORT bool getTruncateLinePaths();
00244
00245
00246 SYMTAB_EXPORT virtual bool findType(Type *&type, std::string name);
00247 SYMTAB_EXPORT virtual Type *findType(unsigned type_id);
00248 SYMTAB_EXPORT virtual bool findVariableType(Type *&type, std::string name);
00249
00250 SYMTAB_EXPORT bool addType(Type *typ);
00251
00252 static boost::shared_ptr<builtInTypeCollection> builtInTypes();
00253 static boost::shared_ptr<typeCollection> stdTypes();
00254
00255 SYMTAB_EXPORT static std::vector<Type *> *getAllstdTypes();
00256 SYMTAB_EXPORT static std::vector<Type *> *getAllbuiltInTypes();
00257
00258 SYMTAB_EXPORT void parseTypesNow();
00259
00260
00261 SYMTAB_EXPORT bool findLocalVariable(std::vector<localVar *>&vars, std::string name);
00262
00263
00264 SYMTAB_EXPORT bool hasRel() const;
00265 SYMTAB_EXPORT bool hasRela() const;
00266 SYMTAB_EXPORT bool hasReldyn() const;
00267 SYMTAB_EXPORT bool hasReladyn() const;
00268 SYMTAB_EXPORT bool hasRelplt() const;
00269 SYMTAB_EXPORT bool hasRelaplt() const;
00270
00271 SYMTAB_EXPORT bool isStaticBinary() const;
00272
00273
00274 SYMTAB_EXPORT bool emitSymbols(Object *linkedFile, std::string filename, unsigned flag = 0);
00275 SYMTAB_EXPORT bool addRegion(Offset vaddr, void *data, unsigned int dataSize,
00276 std::string name, Region::RegionType rType_, bool loadable = false,
00277 unsigned long memAlign = sizeof(unsigned), bool tls = false);
00278 SYMTAB_EXPORT bool addRegion(Region *newreg);
00279 SYMTAB_EXPORT bool emit(std::string filename, unsigned flag = 0);
00280
00281 SYMTAB_EXPORT void addDynLibSubstitution(std::string oldName, std::string newName);
00282 SYMTAB_EXPORT std::string getDynLibSubstitution(std::string name);
00283
00284 SYMTAB_EXPORT bool getSegments(std::vector<Segment> &segs) const;
00285
00286 SYMTAB_EXPORT void fixup_code_and_data(Offset newImageOffset,
00287 Offset newImageLength,
00288 Offset newDataOffset,
00289 Offset newDataLength);
00290 SYMTAB_EXPORT bool fixup_RegionAddr(const char* name, Offset memOffset, long memSize);
00291 SYMTAB_EXPORT bool fixup_SymbolAddr(const char* name, Offset newOffset);
00292 SYMTAB_EXPORT bool updateRegion(const char* name, void *buffer, unsigned size);
00293 SYMTAB_EXPORT bool updateCode(void *buffer, unsigned size);
00294 SYMTAB_EXPORT bool updateData(void *buffer, unsigned size);
00295 SYMTAB_EXPORT Offset getFreeOffset(unsigned size);
00296
00297 SYMTAB_EXPORT bool addLibraryPrereq(std::string libname);
00298 SYMTAB_EXPORT bool addSysVDynamic(long name, long value);
00299
00300 SYMTAB_EXPORT bool addLinkingResource(Archive *library);
00301 SYMTAB_EXPORT bool getLinkingResources(std::vector<Archive *> &libs);
00302
00303 SYMTAB_EXPORT bool addExternalSymbolReference(Symbol *externalSym, Region *localRegion, relocationEntry localRel);
00304 SYMTAB_EXPORT bool addTrapHeader_win(Address ptr);
00305
00306 SYMTAB_EXPORT bool updateRelocations(Address start, Address end, Symbol *oldsym, Symbol *newsym);
00307
00308
00309 SYMTAB_EXPORT std::string file() const;
00310 SYMTAB_EXPORT std::string name() const;
00311 SYMTAB_EXPORT std::string memberName() const;
00312
00313 SYMTAB_EXPORT char *mem_image() const;
00314
00315 SYMTAB_EXPORT Offset imageOffset() const;
00316 SYMTAB_EXPORT Offset dataOffset() const;
00317 SYMTAB_EXPORT Offset dataLength() const;
00318 SYMTAB_EXPORT Offset imageLength() const;
00319
00320
00321 SYMTAB_EXPORT Offset getInitOffset();
00322 SYMTAB_EXPORT Offset getFiniOffset();
00323
00324 SYMTAB_EXPORT const char* getInterpreterName() const;
00325
00326 SYMTAB_EXPORT unsigned getAddressWidth() const;
00327 SYMTAB_EXPORT Offset getLoadOffset() const;
00328 SYMTAB_EXPORT Offset getEntryOffset() const;
00329 SYMTAB_EXPORT Offset getBaseOffset() const;
00330 SYMTAB_EXPORT Offset getTOCoffset(Function *func = NULL) const;
00331 SYMTAB_EXPORT Offset getTOCoffset(Offset off) const;
00332 SYMTAB_EXPORT Address getLoadAddress();
00333 SYMTAB_EXPORT bool isDefensiveBinary() const;
00334 SYMTAB_EXPORT Offset fileToDiskOffset(Dyninst::Offset) const;
00335 SYMTAB_EXPORT Offset fileToMemOffset(Dyninst::Offset) const;
00336
00337
00338 SYMTAB_EXPORT std::string getDefaultNamespacePrefix() const;
00339
00340 SYMTAB_EXPORT unsigned getNumberofRegions() const;
00341 SYMTAB_EXPORT unsigned getNumberofSymbols() const;
00342
00343 SYMTAB_EXPORT std::vector<std::string> &getDependencies();
00344 SYMTAB_EXPORT bool removeLibraryDependency(std::string lib);
00345
00346 SYMTAB_EXPORT Archive *getParentArchive() const;
00347
00348
00349 SYMTAB_EXPORT static SymtabError getLastSymtabError();
00350 SYMTAB_EXPORT static std::string printError(SymtabError serr);
00351
00352 SYMTAB_EXPORT ~Symtab();
00353
00354 bool delSymbol(Symbol *sym) { return deleteSymbol(sym); }
00355 bool deleteSymbol(Symbol *sym);
00356
00357 Symbol *getSymbolByIndex(unsigned);
00358 protected:
00359 Symtab(std::string filename, std::string member_name, Offset offset, bool &err, void *base = NULL);
00360 Symtab(char *img, size_t size, std::string member_name, Offset offset, bool &err, void *base = NULL);
00361
00362
00363 private:
00364
00365 SYMTAB_EXPORT Symtab(std::string filename, bool defensive_bin, bool &err);
00366
00367 SYMTAB_EXPORT bool extractInfo(Object *linkedFile);
00368
00369
00370
00371 bool extractSymbolsFromFile(Object *linkedFile, std::vector<Symbol *> &raw_syms);
00372
00373 bool fixSymRegion(Symbol *sym);
00374
00375 bool fixSymModules(std::vector<Symbol *> &raw_syms);
00376 bool demangleSymbols(std::vector<Symbol *> &rawsyms);
00377 bool createIndices(std::vector<Symbol *> &raw_syms, bool undefined);
00378 bool createAggregates();
00379
00380 bool fixSymModule(Symbol *&sym);
00381 bool demangleSymbol(Symbol *&sym);
00382 bool addSymbolToIndices(Symbol *&sym, bool undefined);
00383 bool addSymbolToAggregates(Symbol *&sym);
00384 bool doNotAggregate(Symbol *&sym);
00385 bool updateIndices(Symbol *sym, std::string newName, NameType nameType);
00386
00387
00388 void setModuleLanguages(dyn_hash_map<std::string, supportedLanguages> *mod_langs);
00389
00390 bool buildDemangledName( const std::string &mangled,
00391 std::string &pretty,
00392 std::string &typed,
00393 bool nativeCompiler,
00394 supportedLanguages lang );
00395
00396
00397 bool changeType(Symbol *sym, Symbol::SymbolType oldType);
00398
00399 bool changeSymbolOffset(Symbol *sym, Offset newOffset);
00400 bool deleteSymbolFromIndices(Symbol *sym);
00401
00402 bool changeAggregateOffset(Aggregate *agg, Offset oldOffset, Offset newOffset);
00403 bool deleteAggregate(Aggregate *agg);
00404
00405
00406 public:
00407 SYMTAB_EXPORT bool canBeShared();
00408 SYMTAB_EXPORT Module *getOrCreateModule(const std::string &modName,
00409 const Offset modAddr);
00410
00411 public:
00412
00413 SYMTAB_EXPORT Offset getElfDynamicOffset();
00414
00415 SYMTAB_EXPORT void getSegmentsSymReader(std::vector<SymSegment> &segs);
00416
00417 private:
00418 void createDefaultModule();
00419
00420 Module *newModule(const std::string &name, const Offset addr, supportedLanguages lang);
00421
00422
00423
00424
00425
00426 bool addSymtabVariables();
00427
00428 void checkPPC64DescriptorSymbols(Object *linkedFile);
00429
00430
00431 void parseLineInformation();
00432 void parseTypes();
00433 bool setDefaultNamespacePrefix(std::string &str);
00434
00435 bool addUserRegion(Region *newreg);
00436 bool addUserType(Type *newtypeg);
00437
00438 void setTOCOffset(Offset offset);
00439
00440
00441 private:
00442
00443 static boost::shared_ptr<typeCollection> setupStdTypes();
00444 static boost::shared_ptr<builtInTypeCollection> setupBuiltinTypes();
00445
00446
00447 std::string member_name_;
00448 Offset member_offset_;
00449 Archive * parentArchive_;
00450 MappedFile *mf;
00451 MappedFile *mfForDebugInfo;
00452
00453 Offset imageOffset_;
00454 unsigned imageLen_;
00455 Offset dataOffset_;
00456 unsigned dataLen_;
00457
00458 bool is_a_out;
00459 Offset main_call_addr_;
00460
00461 bool nativeCompiler;
00462
00463 unsigned address_width_;
00464 char *code_ptr_;
00465 char *data_ptr_;
00466 std::string interpreter_name_;
00467 Offset entry_address_;
00468 Offset base_address_;
00469 Offset load_address_;
00470 ObjectType object_type_;
00471 bool is_eel_;
00472 std::vector<Segment> segments_;
00473
00474
00475
00476
00477 static std::vector<Symtab *> allSymtabs;
00478 std::string defaultNamespacePrefix;
00479
00480
00481 unsigned no_of_sections;
00482 std::vector<Region *> regions_;
00483 std::vector<Region *> codeRegions_;
00484 std::vector<Region *> dataRegions_;
00485 dyn_hash_map <Offset, Region *> regionsByEntryAddr;
00486
00487
00488 unsigned newSectionInsertPoint;
00489
00490
00491 unsigned no_of_symbols;
00492
00493
00494
00495 std::vector<Symbol *> everyDefinedSymbol;
00496
00497
00498
00499 std::vector<Symbol *> undefDynSyms;
00500 std::map <std::string, std::vector<Symbol *> > undefDynSymsByMangledName;
00501 std::map <std::string, std::vector<Symbol *> > undefDynSymsByPrettyName;
00502 std::map <std::string, std::vector<Symbol *> > undefDynSymsByTypedName;
00503
00504
00505
00506 dyn_hash_map <Offset, std::vector<Symbol *> > symsByOffset;
00507
00508
00509 dyn_hash_map <std::string, std::vector<Symbol *> > symsByMangledName;
00510
00511
00512 dyn_hash_map <std::string, std::vector<Symbol *> > symsByPrettyName;
00513
00514
00515 dyn_hash_map <std::string, std::vector<Symbol *> > symsByTypedName;
00516
00517
00518 bool sorted_everyFunction;
00519 std::vector<Function *> everyFunction;
00520
00521
00522 dyn_hash_map <Offset, Function *> funcsByOffset;
00523
00524
00525 std::vector<Variable *> everyVariable;
00526 dyn_hash_map <Offset, Variable *> varsByOffset;
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550 dyn_hash_map <std::string, Module *> modsByFileName;
00551 dyn_hash_map <std::string, Module *> modsByFullName;
00552 std::vector<Module *> _mods;
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566 std::vector<relocationEntry > relocation_table_;
00567 std::vector<ExceptionBlock *> excpBlocks;
00568
00569 std::vector<std::string> deps_;
00570
00571
00572 std::vector<Archive *> linkingResources_;
00573
00574
00575 bool getExplicitSymtabRefs(std::set<Symtab *> &refs);
00576 std::set<Symtab *> explicitSymtabRefs_;
00577
00578
00579 bool isLineInfoValid_;
00580
00581 bool isTypeInfoValid_;
00582
00583 int nlines_;
00584 unsigned long fdptr_;
00585 char *lines_;
00586 char *stabstr_;
00587 int nstabs_;
00588 void *stabs_;
00589 char *stringpool_;
00590
00591
00592 bool hasRel_;
00593 bool hasRela_;
00594 bool hasReldyn_;
00595 bool hasReladyn_;
00596 bool hasRelplt_;
00597 bool hasRelaplt_;
00598
00599 bool isStaticBinary_;
00600 bool isDefensiveBinary_;
00601
00602
00603 public:
00604 Object *getObject();
00605 private:
00606 Object *obj_private;
00607
00608
00609 std::map <std::string, std::string> dynLibSubs;
00610
00611 public:
00612 static boost::shared_ptr<Type> type_Error();
00613 static boost::shared_ptr<Type> type_Untyped();
00614
00615 private:
00616 unsigned _ref_cnt;
00617 };
00618
00619
00620
00621
00622
00623 SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const ExceptionBlock &q);
00624
00625 class ExceptionBlock : public Serializable, public AnnotatableSparse {
00626
00627 public:
00628 SYMTAB_EXPORT Serializable * serialize_impl(SerializerBase *sb,
00629 const char *tag = "exceptionBlock") THROW_SPEC (SerializerError);
00630 SYMTAB_EXPORT ExceptionBlock(Offset tStart, unsigned tSize, Offset cStart);
00631 SYMTAB_EXPORT ExceptionBlock(Offset cStart);
00632 SYMTAB_EXPORT ExceptionBlock(const ExceptionBlock &eb);
00633 SYMTAB_EXPORT ~ExceptionBlock();
00634 SYMTAB_EXPORT ExceptionBlock();
00635
00636 SYMTAB_EXPORT bool hasTry() const;
00637 SYMTAB_EXPORT Offset tryStart() const;
00638 SYMTAB_EXPORT Offset tryEnd() const;
00639 SYMTAB_EXPORT Offset trySize() const;
00640 SYMTAB_EXPORT Offset catchStart() const;
00641 SYMTAB_EXPORT bool contains(Offset a) const;
00642
00643 friend SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const ExceptionBlock &q);
00644 private:
00645 Offset tryStart_;
00646 unsigned trySize_;
00647 Offset catchStart_;
00648 bool hasTry_;
00649 };
00650
00651
00652
00653
00654
00655 SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const relocationEntry &q);
00656
00657 class relocationEntry : public Serializable, public AnnotatableSparse {
00658 public:
00659
00660 SYMTAB_EXPORT relocationEntry();
00661 SYMTAB_EXPORT relocationEntry(Offset ta, Offset ra, Offset add,
00662 std::string n, Symbol *dynref = NULL, unsigned long relType = 0);
00663 SYMTAB_EXPORT relocationEntry(Offset ta, Offset ra, std::string n,
00664 Symbol *dynref = NULL, unsigned long relType = 0);
00665 SYMTAB_EXPORT relocationEntry(Offset ra, std::string n, Symbol *dynref = NULL,
00666 unsigned long relType = 0, Region::RegionType rtype = Region::RT_REL);
00667 SYMTAB_EXPORT relocationEntry(Offset ta, Offset ra, Offset add,
00668 std::string n, Symbol *dynref = NULL, unsigned long relType = 0,
00669 Region::RegionType rtype = Region::RT_REL);
00670
00671 SYMTAB_EXPORT Serializable * serialize_impl(SerializerBase *sb,
00672 const char *tag = "relocationEntry") THROW_SPEC (SerializerError);
00673
00674 SYMTAB_EXPORT Offset target_addr() const;
00675 SYMTAB_EXPORT Offset rel_addr() const;
00676 SYMTAB_EXPORT Offset addend() const;
00677 SYMTAB_EXPORT Region::RegionType regionType() const;
00678 SYMTAB_EXPORT const std::string &name() const;
00679 SYMTAB_EXPORT Symbol *getDynSym() const;
00680 SYMTAB_EXPORT bool addDynSym(Symbol *dynref);
00681 SYMTAB_EXPORT unsigned long getRelType() const;
00682
00683 SYMTAB_EXPORT void setTargetAddr(const Offset);
00684 SYMTAB_EXPORT void setRelAddr(const Offset);
00685 SYMTAB_EXPORT void setAddend(const Offset);
00686 SYMTAB_EXPORT void setRegionType(const Region::RegionType);
00687 SYMTAB_EXPORT void setName(const std::string &newName);
00688 SYMTAB_EXPORT void setRelType(unsigned long relType) { relType_ = relType; }
00689
00690
00691
00692
00693 friend SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const relocationEntry &q);
00694
00695 enum {pltrel = 1, dynrel = 2} relocationType;
00696 SYMTAB_EXPORT bool operator==(const relocationEntry &) const;
00697
00698
00699 SYMTAB_EXPORT static unsigned long getGlobalRelType(unsigned addressWidth, Symbol *sym = NULL);
00700 static const char *relType2Str(unsigned long r, unsigned addressWidth = sizeof(Address));
00701
00702 private:
00703 Offset target_addr_;
00704 Offset rel_addr_;
00705 Offset addend_;
00706 Region::RegionType rtype_;
00707 std::string name_;
00708 Symbol *dynref_;
00709 unsigned long relType_;
00710 Offset rel_struct_addr_;
00711 };
00712
00713 #if 1
00714 #if 1
00715 SYMTAB_EXPORT SerializerBase *nonpublic_make_bin_symtab_serializer(Symtab *t, std::string file);
00716 SYMTAB_EXPORT SerializerBase *nonpublic_make_bin_symtab_deserializer(Symtab *t, std::string file);
00717 SYMTAB_EXPORT void nonpublic_free_bin_symtab_serializer(SerializerBase *sb);
00718 #else
00719
00720 template <class T>
00721 SerializerBase *nonpublic_make_bin_serializer(T *t, std::string file)
00722 {
00723 SerializerBin<T> *ser;
00724 ser = new SerializerBin<T>(t, "SerializerBin", file, sd_serialize, true);
00725 T *test_st = ser->getScope();
00726 assert(test_st == t);
00727 return ser;
00728 }
00729
00730 template <class T>
00731 SerializerBase *nonpublic_make_bin_deserializer(T *t, std::string file)
00732 {
00733 SerializerBin<T> *ser;
00734 ser = new SerializerBin<T>(t, "DeserializerBin", file, sd_deserialize, true);
00735 T *test_st = ser->getScope();
00736 assert(test_st == t);
00737 return ser;
00738 }
00739
00740 template <class T>
00741 void nonpublic_free_bin_serializer(SerializerBase *sb)
00742 {
00743 SerializerBin<T> *sbin = dynamic_cast<SerializerBin<T> *>(sb);
00744 if (sbin)
00745 {
00746 delete(sbin);
00747 }
00748 else
00749 fprintf(stderr, "%s[%d]: FIXME\n", FILE__, __LINE__);
00750
00751 }
00752 #endif
00753 #endif
00754
00755 }
00756
00757 }
00758 #endif