Dyninst::SymtabAPI::emitElf64 Class Reference

#include <emitElf-64.h>

Public Member Functions

 emitElf64 (Elf_X *oldElfHandle_, bool isStripped_=false, Object *obj_=NULL, void(*)(const char *)=log_msg)
 ~emitElf64 ()
bool createSymbolTables (Symtab *obj, vector< Symbol * > &allSymbols)
bool driver (Symtab *obj, std::string fName)

Private Member Functions

bool createElfSymbol (Symbol *symbol, unsigned strIndex, vector< Elf64_Sym * > &symbols, bool dynSymFlag=false)
void findSegmentEnds ()
void renameSection (const std::string &oldStr, const std::string &newStr, bool renameAll=true)
void fixPhdrs (unsigned &)
void createNewPhdrRegion (dyn_hash_map< std::string, unsigned > &newNameIndexMapping)
bool addSectionHeaderTable (Elf64_Shdr *shdr)
bool createNonLoadableSections (Elf64_Shdr *&shdr)
bool createLoadableSections (Symtab *obj, Elf64_Shdr *&shdr, unsigned &extraAlignSize, dyn_hash_map< std::string, unsigned > &newIndexMapping, unsigned &sectionNumber)
void createRelocationSections (Symtab *obj, std::vector< relocationEntry > &relocation_table, bool isDynRelocs, dyn_hash_map< std::string, unsigned long > &dynSymNameMapping)
void updateSymbols (Elf_Data *symtabData, Elf_Data *strData, unsigned long loadSecsSize)
void updateDynamic (unsigned tag, Elf64_Addr val)
void createSymbolVersions (Symtab *obj, Elf64_Half *&symVers, char *&verneedSecData, unsigned &verneedSecSize, char *&verdefSecData, unsigned &verdefSecSize, unsigned &dynSymbolNamesLength, std::vector< std::string > &dynStrs)
void createHashSection (Symtab *obj, Elf64_Word *&hashsecData, unsigned &hashsecSize, std::vector< Symbol * > &dynSymbols)
void createDynamicSection (void *dynData, unsigned size, Elf64_Dyn *&dynsecData, unsigned &dynsecSize, unsigned &dynSymbolNamesLength, std::vector< std::string > &dynStrs)
void addDTNeeded (std::string s)
void log_elferror (void(*err_func)(const char *), const char *msg)
bool hasPHdrSectionBug ()
bool cannotRelocatePhdrs ()

Private Attributes

Elf_XoldElfHandle
Elf * newElf
Elf * oldElf
Elf64_Ehdr * newEhdr
Elf64_Ehdr * oldEhdr
Elf64_Phdr * newPhdr
Elf64_Phdr * oldPhdr
Offset phdr_offset
Elf_Data * textData
Elf_Data * symStrData
Elf_Data * dynStrData
char * olddynStrData
unsigned olddynStrSize
Elf_Data * symTabData
Elf_Data * hashData
Elf_Data * dynsymData
Elf_Data * dynData
Elf_Data * rodata
Elf_Data * dataData
Elf64_Shdr * textSh
Elf64_Shdr * rodataSh
Elf_Scn * phdrs_scn
std::vector< Region * > nonLoadableSecs
std::vector< Region * > newSecs
std::map< unsigned,
std::vector< Elf64_Dyn * > > 
dynamicSecData
std::vector< std::string > DT_NEEDEDEntries
std::vector< std::pair< long,
long > > 
new_dynamic_entries
std::vector< std::string > unversionedNeededEntries
std::map< std::string,
std::map< std::string,
unsigned > > 
verneedEntries
std::map< std::string, unsigned > verdefEntries
std::map< unsigned,
std::vector< std::string > > 
verdauxEntries
std::map< std::string, unsigned > versionNames
std::vector< Elf64_Half > versionSymTable
int curVersionNum
int verneednum
int verdefnum
Elf64_Off newSegmentStart
Elf64_Shdr * firstNewLoadSec
Elf64_Off dataSegEnd
Elf64_Off textSegEnd
Elf64_Off dynSegOff
Elf64_Off dynSegAddr
Elf64_Off phdrSegOff
Elf64_Off phdrSegAddr
unsigned dynSegSize
vector< std::string > secNames
unsigned secNameIndex
Offset currEndOffset
Address currEndAddress
char * linkedStaticData
bool BSSExpandFlag
bool movePHdrsFirst
bool createNewPhdr
bool replaceNOTE
unsigned loadSecTotalSize
bool isStripped
int library_adjust
Objectobject
void(* err_func_ )(const char *)
bool hasRewrittenTLS
bool TLSExists
Elf64_Shdr * newTLSData

Detailed Description

Definition at line 41 of file emitElf-64.h.


Constructor & Destructor Documentation

emitElf64::emitElf64 ( Elf_X oldElfHandle_,
bool  isStripped_ = false,
Object obj_ = NULL,
void(*)(const char *)  err_func = log_msg 
)
Dyninst::SymtabAPI::emitElf64::~emitElf64 (  )  [inline]

Definition at line 44 of file emitElf-64.h.

References linkedStaticData.


Member Function Documentation

void Dyninst::SymtabAPI::emitElf64::addDTNeeded ( std::string  s  )  [private]

Referenced by createSymbolTables().

bool emitElf64::addSectionHeaderTable ( Elf64_Shdr *  shdr  )  [private]

Definition at line 1511 of file emitElf-64.C.

References err_func_, FILE__, fprintf, log_elferror(), newElf, secNameIndex, and secNames.

bool emitElf64::cannotRelocatePhdrs (  )  [private]

Definition at line 131 of file emitElf-64.C.

Referenced by emitElf64().

void emitElf64::createDynamicSection ( void *  dynData,
unsigned  size,
Elf64_Dyn *&  dynsecData,
unsigned &  dynsecSize,
unsigned &  dynSymbolNamesLength,
std::vector< std::string > &  dynStrs 
) [private]

List every dynamic entry that references an address and isn't already updated here. library_adjust will be a page size if we're dealing with a library without a fixed load address. We'll be shifting the addresses of that library by a page.

Definition at line 2416 of file emitElf-64.C.

References DT_GNU_CONFLICT, DT_NEEDEDEntries, dynamicSecData, Dyninst::SymtabAPI::Object::getRelType(), Dyninst::SymtabAPI::Object::hasReldyn(), library_adjust, new_dynamic_entries, object, olddynStrData, Dyninst::SymtabAPI::Region::RT_REL, and Dyninst::SymtabAPI::Region::RT_RELA.

Referenced by createSymbolTables().

bool emitElf64::createElfSymbol ( Symbol symbol,
unsigned  strIndex,
vector< Elf64_Sym * > &  symbols,
bool  dynSymFlag = false 
) [private]
void Dyninst::SymtabAPI::emitElf64::createHashSection ( Symtab obj,
Elf64_Word *&  hashsecData,
unsigned &  hashsecSize,
std::vector< Symbol * > &  dynSymbols 
) [private]

Referenced by createSymbolTables().

bool emitElf64::createLoadableSections ( Symtab obj,
Elf64_Shdr *&  shdr,
unsigned &  extraAlignSize,
dyn_hash_map< std::string, unsigned > &  newIndexMapping,
unsigned &  sectionNumber 
) [private]
void emitElf64::createNewPhdrRegion ( dyn_hash_map< std::string, unsigned > &  newNameIndexMapping  )  [private]
bool emitElf64::createNonLoadableSections ( Elf64_Shdr *&  shdr  )  [private]
void emitElf64::createRelocationSections ( Symtab obj,
std::vector< relocationEntry > &  relocation_table,
bool  isDynRelocs,
dyn_hash_map< std::string, unsigned long > &  dynSymNameMapping 
) [private]
bool emitElf64::createSymbolTables ( Symtab obj,
vector< Symbol * > &  allSymbols 
)

Definition at line 1693 of file emitElf-64.C.

References addDTNeeded(), Dyninst::SymtabAPI::Symtab::addRegion(), createDynamicSection(), createElfSymbol(), createHashSection(), createRelocationSections(), createSymbolVersions(), Dyninst::SymtabAPI::Object::deps_, Dyninst::SymtabAPI::Emit_Error, err_func_, errMsg, Dyninst::SymtabAPI::Symtab::findRegion(), Dyninst::SymtabAPI::Symtab::getAddressWidth(), Dyninst::SymtabAPI::Symtab::getAllNewRegions(), Dyninst::SymtabAPI::Region::getDiskSize(), Dyninst::SymtabAPI::Object::getDynRelocs(), Dyninst::SymtabAPI::Region::getMemSize(), Dyninst::SymtabAPI::Symtab::getObject(), Dyninst::SymtabAPI::Object::getPLTRelocs(), Dyninst::SymtabAPI::Region::getPtrToRawData(), Dyninst::SymtabAPI::Object::getRelPLTAddr(), Dyninst::SymtabAPI::Object::getTagRegionMapping(), hasRewrittenTLS, Dyninst::SymtabAPI::Symtab::isStaticBinary(), isStripped, linkedStaticData, log_elferror(), Dyninst::SymtabAPI::Symbol::magicEmitElfSymbol(), Dyninst::SymtabAPI::Symtab::name(), Dyninst::SymtabAPI::Object::new_dynamic_entries, new_dynamic_entries, newSecs, olddynStrData, olddynStrSize, Dyninst::SymtabAPI::Object::prereq_libs, Dyninst::SymtabAPI::emitElfStatic::printStaticLinkError(), rewrite_printf(), Dyninst::SymtabAPI::Region::RT_DYNAMIC, Dyninst::SymtabAPI::Region::RT_HASH, Dyninst::SymtabAPI::Region::RT_STRTAB, Dyninst::SymtabAPI::Region::RT_SYMTAB, Dyninst::SymtabAPI::Region::RT_SYMVERDEF, Dyninst::SymtabAPI::Region::RT_SYMVERNEEDED, Dyninst::SymtabAPI::Region::RT_SYMVERSIONS, Dyninst::SymtabAPI::Region::setPtrToRawData(), setSymtabError(), symtab_log_perror(), Dyninst::SymtabAPI::emitElfUtils::updateHeapVariables(), and versionSymTable.

Referenced by Dyninst::SymtabAPI::Object::emitDriver().

void Dyninst::SymtabAPI::emitElf64::createSymbolVersions ( Symtab obj,
Elf64_Half *&  symVers,
char *&  verneedSecData,
unsigned &  verneedSecSize,
char *&  verdefSecData,
unsigned &  verdefSecSize,
unsigned &  dynSymbolNamesLength,
std::vector< std::string > &  dynStrs 
) [private]

Referenced by createSymbolTables().

bool Dyninst::SymtabAPI::emitElf64::driver ( Symtab obj,
std::string  fName 
)
void emitElf64::findSegmentEnds (  )  [private]

Definition at line 435 of file emitElf-64.C.

References dataSegEnd, oldEhdr, oldElf, and TLSExists.

void emitElf64::fixPhdrs ( unsigned &  extraAlignSize  )  [private]
bool emitElf64::hasPHdrSectionBug (  )  [private]

Definition at line 122 of file emitElf-64.C.

References libelfso1Flag, libelfso1version_major, libelfso1version_minor, and movePHdrsFirst.

Referenced by fixPhdrs().

void emitElf64::log_elferror ( void(*)(const char *)  err_func,
const char *  msg 
) [private]
void emitElf64::renameSection ( const std::string &  oldStr,
const std::string &  newStr,
bool  renameAll = true 
) [private]

Definition at line 457 of file emitElf-64.C.

References secNames.

void emitElf64::updateDynamic ( unsigned  tag,
Elf64_Addr  val 
) [private]

Definition at line 1163 of file emitElf-64.C.

References DT_GNU_HASH, dynamicSecData, isStaticBinary, verdefnum, and verneednum.

Referenced by createLoadableSections().

void emitElf64::updateSymbols ( Elf_Data *  symtabData,
Elf_Data *  strData,
unsigned long  loadSecsSize 
) [private]

Definition at line 1201 of file emitElf-64.C.

References newSegmentStart.


Field Documentation

Definition at line 118 of file emitElf-64.h.

Referenced by emitElf64(), and fixPhdrs().

Definition at line 120 of file emitElf-64.h.

Referenced by createLoadableSections(), createNewPhdrRegion(), emitElf64(), and fixPhdrs().

Definition at line 110 of file emitElf-64.h.

Referenced by createLoadableSections(), createNewPhdrRegion(), and fixPhdrs().

Definition at line 95 of file emitElf-64.h.

Referenced by createElfSymbol(), and emitElf64().

Definition at line 75 of file emitElf-64.h.

Definition at line 102 of file emitElf-64.h.

Referenced by findSegmentEnds().

std::vector<std::string> Dyninst::SymtabAPI::emitElf64::DT_NEEDEDEntries [private]

Definition at line 85 of file emitElf-64.h.

Referenced by createDynamicSection().

std::map<unsigned, std::vector<Elf64_Dyn *> > Dyninst::SymtabAPI::emitElf64::dynamicSecData [private]

Definition at line 84 of file emitElf-64.h.

Referenced by createDynamicSection(), and updateDynamic().

Definition at line 73 of file emitElf-64.h.

Definition at line 103 of file emitElf-64.h.

Referenced by createLoadableSections(), and fixPhdrs().

Definition at line 103 of file emitElf-64.h.

Referenced by createLoadableSections(), and fixPhdrs().

Definition at line 104 of file emitElf-64.h.

Referenced by createLoadableSections(), and fixPhdrs().

Definition at line 67 of file emitElf-64.h.

Referenced by createLoadableSections(), and emitElf64().

Definition at line 72 of file emitElf-64.h.

Referenced by createLoadableSections(), and emitElf64().

void(* Dyninst::SymtabAPI::emitElf64::err_func_)(const char *) [private]

Definition at line 99 of file emitElf-64.h.

Referenced by createLoadableSections(), emitElf64(), and fixPhdrs().

Definition at line 71 of file emitElf-64.h.

Referenced by emitElf64().

Definition at line 145 of file emitElf-64.h.

Referenced by createSymbolTables(), emitElf64(), and fixPhdrs().

Definition at line 124 of file emitElf-64.h.

Referenced by createSymbolTables().

Definition at line 114 of file emitElf-64.h.

Referenced by createSymbolTables(), emitElf64(), and ~emitElf64().

Definition at line 122 of file emitElf-64.h.

Referenced by createLoadableSections(), createNewPhdrRegion(), and fixPhdrs().

Definition at line 119 of file emitElf-64.h.

Referenced by createNewPhdrRegion(), emitElf64(), fixPhdrs(), and hasPHdrSectionBug().

std::vector<std::pair<long, long> > Dyninst::SymtabAPI::emitElf64::new_dynamic_entries [private]

Definition at line 86 of file emitElf-64.h.

Referenced by createDynamicSection(), and createSymbolTables().

Definition at line 56 of file emitElf-64.h.

Referenced by createNewPhdrRegion(), and fixPhdrs().

Definition at line 59 of file emitElf-64.h.

Referenced by fixPhdrs().

Definition at line 98 of file emitElf-64.h.

Referenced by createLoadableSections(), fixPhdrs(), and updateSymbols().

Definition at line 147 of file emitElf-64.h.

Referenced by createLoadableSections(), emitElf64(), and fixPhdrs().

Definition at line 82 of file emitElf-64.h.

Referenced by createLoadableSections(), and createNonLoadableSections().

Definition at line 126 of file emitElf-64.h.

Referenced by createDynamicSection(), and createRelocationSections().

Definition at line 68 of file emitElf-64.h.

Referenced by createDynamicSection(), and createSymbolTables().

Definition at line 69 of file emitElf-64.h.

Referenced by createSymbolTables().

Definition at line 57 of file emitElf-64.h.

Referenced by createNewPhdrRegion(), findSegmentEnds(), and fixPhdrs().

Definition at line 53 of file emitElf-64.h.

Referenced by emitElf64(), and findSegmentEnds().

Definition at line 51 of file emitElf-64.h.

Referenced by emitElf64().

Definition at line 60 of file emitElf-64.h.

Referenced by fixPhdrs().

Definition at line 61 of file emitElf-64.h.

Referenced by createNewPhdrRegion().

Definition at line 80 of file emitElf-64.h.

Referenced by createNewPhdrRegion(), and fixPhdrs().

Definition at line 103 of file emitElf-64.h.

Referenced by createNewPhdrRegion(), and fixPhdrs().

Definition at line 103 of file emitElf-64.h.

Referenced by createNewPhdrRegion().

Definition at line 121 of file emitElf-64.h.

Referenced by createLoadableSections(), emitElf64(), and fixPhdrs().

Definition at line 74 of file emitElf-64.h.

Referenced by emitElf64().

Definition at line 78 of file emitElf-64.h.

vector<std::string> Dyninst::SymtabAPI::emitElf64::secNames [private]

Definition at line 66 of file emitElf-64.h.

Referenced by emitElf64().

Definition at line 70 of file emitElf-64.h.

Referenced by emitElf64().

Definition at line 65 of file emitElf-64.h.

Referenced by emitElf64().

Definition at line 102 of file emitElf-64.h.

Definition at line 77 of file emitElf-64.h.

Definition at line 146 of file emitElf-64.h.

Referenced by emitElf64(), findSegmentEnds(), and fixPhdrs().

std::vector<std::string> Dyninst::SymtabAPI::emitElf64::unversionedNeededEntries [private]

Definition at line 87 of file emitElf-64.h.

Referenced by createElfSymbol().

std::map<unsigned, std::vector<std::string> > Dyninst::SymtabAPI::emitElf64::verdauxEntries [private]

Definition at line 92 of file emitElf-64.h.

Referenced by createElfSymbol().

std::map<std::string, unsigned> Dyninst::SymtabAPI::emitElf64::verdefEntries [private]

Definition at line 91 of file emitElf-64.h.

Referenced by createElfSymbol().

Definition at line 95 of file emitElf-64.h.

Referenced by updateDynamic().

std::map<std::string, std::map<std::string, unsigned> > Dyninst::SymtabAPI::emitElf64::verneedEntries [private]

Definition at line 90 of file emitElf-64.h.

Referenced by createElfSymbol().

Definition at line 95 of file emitElf-64.h.

Referenced by updateDynamic().

std::map<std::string, unsigned> Dyninst::SymtabAPI::emitElf64::versionNames [private]

Definition at line 93 of file emitElf-64.h.

Referenced by createElfSymbol().

std::vector<Elf64_Half> Dyninst::SymtabAPI::emitElf64::versionSymTable [private]

Definition at line 94 of file emitElf-64.h.

Referenced by createElfSymbol(), and createSymbolTables().


The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1