Skip to content

Commit

Permalink
Functions not filed into correct Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
wrwilliams committed May 27, 2016
2 parents 9de709e + 290c66a commit dcc529b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 28 deletions.
6 changes: 3 additions & 3 deletions symtabAPI/h/Aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ class SYMTAB_EXPORT Aggregate
name_iter typed_names_end() const;

/***** Aggregate updating *****/
virtual bool addMangledName(std::string name, bool isPrimary);
virtual bool addPrettyName(std::string name, bool isPrimary);
virtual bool addTypedName(std::string name, bool isPrimary);
virtual bool addMangledName(std::string name, bool isPrimary, bool isDebug=false);
virtual bool addPrettyName(std::string name, bool isPrimary, bool isDebug=false);
virtual bool addTypedName(std::string name, bool isPrimary, bool isDebug=false);

bool setModule(Module *mod);
bool setSize(unsigned size);
Expand Down
16 changes: 8 additions & 8 deletions symtabAPI/h/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class SYMTAB_EXPORT FunctionBase

/***** Primary name *****/
virtual std::string getName() const = 0;
virtual bool addMangledName(std::string name, bool isPrimary) = 0;
virtual bool addPrettyName(std::string name, bool isPrimary) = 0;
virtual bool addMangledName(std::string name, bool isPrimary, bool isDebug=false) = 0;
virtual bool addPrettyName(std::string name, bool isPrimary, bool isDebug=false) = 0;

/***** Opaque data object pointers, usable by user ****/
void *getData();
Expand Down Expand Up @@ -173,10 +173,10 @@ class SYMTAB_EXPORT FunctionBase
virtual unsigned getSize() const;
virtual std::string getName() const;
virtual Offset getOffset() const { return Aggregate::getOffset(); }
virtual bool addMangledName(std::string name, bool isPrimary)
{return Aggregate::addMangledName(name, isPrimary);}
virtual bool addPrettyName(std::string name, bool isPrimary)
{return Aggregate::addPrettyName(name, isPrimary);}
virtual bool addMangledName(std::string name, bool isPrimary, bool isDebug=false)
{return Aggregate::addMangledName(name, isPrimary, isDebug);}
virtual bool addPrettyName(std::string name, bool isPrimary, bool isDebug=false)
{return Aggregate::addPrettyName(name, isPrimary, isDebug);}
virtual Module* getModule() const { return module_; }
};

Expand All @@ -192,8 +192,8 @@ class SYMTAB_EXPORT InlinedFunction : public FunctionBase
typedef std::vector<std::string>::const_iterator name_iter;
std::pair<std::string, Dyninst::Offset> getCallsite();
virtual bool removeSymbol(Symbol *sym);
virtual bool addMangledName(std::string name, bool isPrimary);
virtual bool addPrettyName(std::string name, bool isPrimary);
virtual bool addMangledName(std::string name, bool isPrimary, bool isDebug=false);
virtual bool addPrettyName(std::string name, bool isPrimary, bool isDebug=false);
virtual std::string getName() const;
virtual Offset getOffset() const;
virtual unsigned getSize() const;
Expand Down
7 changes: 5 additions & 2 deletions symtabAPI/h/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ class SYMTAB_EXPORT Symbol : public Serializable,
unsigned getSize() const { return size_; }
Region *getRegion() const { return region_; }

bool isInDynSymtab() const { return (type_ != ST_DELETED) && isDynamic_; }
bool isInSymtab() const { return (type_ != ST_DELETED) && !isDynamic_; }
bool isInDynSymtab() const { return (type_ != ST_DELETED) && isDynamic_ && !isDebug_; }
bool isInSymtab() const { return (type_ != ST_DELETED) && !isDynamic_ && !isDebug_; }
bool isAbsolute() const { return isAbsolute_; }
bool isDebug() const { return isDebug_; }
bool isCommonStorage() const { return isCommonStorage_; }

bool isFunction() const;
Expand Down Expand Up @@ -228,6 +229,7 @@ class SYMTAB_EXPORT Symbol : public Serializable,
SymbolTag tag () const;
bool setDynamic(bool d) { isDynamic_ = d; return true;}
bool setAbsolute(bool a) { isAbsolute_ = a; return true; }
bool setDebug(bool dbg) { isDebug_ = dbg; return true; }
bool setCommonStorage(bool cs) { isCommonStorage_ = cs; return true; }

bool setVersionFileName(std::string &fileName);
Expand Down Expand Up @@ -264,6 +266,7 @@ class SYMTAB_EXPORT Symbol : public Serializable,

bool isDynamic_;
bool isAbsolute_;
bool isDebug_;

Aggregate * aggregate_; // Pointer to Function or Variable container, if appropriate.

Expand Down
12 changes: 7 additions & 5 deletions symtabAPI/src/Aggregate.C
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ bool Aggregate::addMangledNameInternal(std::string name, bool /*isPrimary*/, boo
return true;
}

SYMTAB_EXPORT bool Aggregate::addMangledName(string name, bool isPrimary)
SYMTAB_EXPORT bool Aggregate::addMangledName(string name, bool isPrimary, bool isDebug)
{
if (!addMangledNameInternal(name, isPrimary, false))
return false;
Expand All @@ -191,19 +191,21 @@ SYMTAB_EXPORT bool Aggregate::addMangledName(string name, bool isPrimary)
newSym->setMangledName(name);
module_->exec()->demangleSymbol(newSym);
newSym->isDynamic_ = false;
newSym->isDebug_ = isDebug;
module_->exec()->addSymbol(newSym);
}
if (dynamicSym) {
Symbol *newSym = new Symbol(*dynamicSym);
newSym->setMangledName(name);
module_->exec()->demangleSymbol(newSym);
newSym->isDynamic_ = true;
newSym->isDebug_ = isDebug;
module_->exec()->addSymbol(newSym);
}
return true;
}

SYMTAB_EXPORT bool Aggregate::addPrettyName(string name, bool isPrimary)
SYMTAB_EXPORT bool Aggregate::addPrettyName(string name, bool isPrimary, bool isDebug)
{
// Check to see if we're duplicating
for (auto i = pretty_names_begin();
Expand All @@ -212,10 +214,10 @@ SYMTAB_EXPORT bool Aggregate::addPrettyName(string name, bool isPrimary)
if (i->find(name) != string::npos)
return false;
}
return addMangledName(name, isPrimary);
return addMangledName(name, isPrimary, isDebug);
}

SYMTAB_EXPORT bool Aggregate::addTypedName(string name, bool isPrimary)
SYMTAB_EXPORT bool Aggregate::addTypedName(string name, bool isPrimary, bool isDebug)
{
// Check to see if we're duplicating
for (auto i = typed_names_begin();
Expand All @@ -224,7 +226,7 @@ SYMTAB_EXPORT bool Aggregate::addTypedName(string name, bool isPrimary)
if (i->find(name) != string::npos)
return false;
}
return addMangledName(name, isPrimary);
return addMangledName(name, isPrimary, isDebug);
}

bool Aggregate::changeSymbolOffset(Symbol *sym)
Expand Down
4 changes: 2 additions & 2 deletions symtabAPI/src/Function.C
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ bool InlinedFunction::removeSymbol(Symbol *)
return false;
}

bool InlinedFunction::addMangledName(std::string name, bool /*isPrimary*/)
bool InlinedFunction::addMangledName(std::string name, bool /*isPrimary*/, bool /*isDebug*/)
{
name_ = name;
return true;
}

bool InlinedFunction::addPrettyName(std::string name, bool /*isPrimary*/)
bool InlinedFunction::addPrettyName(std::string name, bool /*isPrimary*/, bool /*isDebug*/)
{
name_ = name;
return true;
Expand Down
3 changes: 3 additions & 0 deletions symtabAPI/src/Object-elf.C
Original file line number Diff line number Diff line change
Expand Up @@ -5115,6 +5115,9 @@ bool Object::parse_all_relocations(Elf_X &elf, Elf_X_Shdr *dynsym_scnp,
if( (*sym_it)->tag() == Symbol::TAG_INTERNAL ) {
continue;
}
if( (*sym_it)->isDebug() ) {
continue;
}

std::pair<dyn_hash_map<int, Symbol *>::iterator, bool> result;
if( (*sym_it)->isInDynSymtab() ) {
Expand Down
2 changes: 2 additions & 0 deletions symtabAPI/src/Object.C
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ void print_symbols( std::vector< Symbol *>& allsymbols ) {
fprintf(fd, " DYN");
if (sym->isAbsolute())
fprintf(fd, " ABS");
if (sym->isDebug())
fprintf(fd, " DBG");
std::string fileName;
std::vector<std::string> *vers;
if (sym->getVersionFileName(fileName))
Expand Down
7 changes: 6 additions & 1 deletion symtabAPI/src/Symbol.C
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,12 @@ std::ostream& Dyninst::SymtabAPI::operator<< (ostream &os, const Symbol &s)
//<< " tag=" << (unsigned) s.tag_
<< " tag=" << s.symbolTag2Str(s.tag_)
<< " isAbs=" << s.isAbsolute_
<< " isDbg=" << s.isDebug_
<< " isCommon=" << s.isCommonStorage_
<< (s.isFunction() ? " [FUNC]" : "")
<< (s.isVariable() ? " [VAR]" : "")
<< (s.isInSymtab() ? "[STA]" : "[DYN]")
<< (s.isInSymtab() ? "[STA]" : "")
<< (s.isInDynSymtab() ? "[DYN]" : "")
<< " }";
}

Expand Down Expand Up @@ -380,6 +382,7 @@ bool Symbol::operator==(const Symbol& s) const
&& (size_ == s.size_)
&& (isDynamic_ == s.isDynamic_)
&& (isAbsolute_ == s.isAbsolute_)
&& (isDebug_ == s.isDebug_)
&& (isCommonStorage_ == s.isCommonStorage_)
&& (versionHidden_ == s.versionHidden_)
&& (mangledName_ == s.mangledName_));
Expand All @@ -405,6 +408,7 @@ Symbol::Symbol () :
size_(0),
isDynamic_(false),
isAbsolute_(false),
isDebug_(false),
aggregate_(NULL),
mangledName_(Symbol::emptyString),
tag_(TAG_UNKNOWN) ,
Expand Down Expand Up @@ -441,6 +445,7 @@ Symbol::Symbol(const std::string& name,
size_(s),
isDynamic_(d),
isAbsolute_(a),
isDebug_(false),
aggregate_(NULL),
mangledName_(name),
tag_(TAG_UNKNOWN),
Expand Down
2 changes: 1 addition & 1 deletion symtabAPI/src/dwarfWalker.C
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool DwarfWalker::parseModule(Dwarf_Bool is_info, Module *&fixUnknownMod) {
fixUnknownMod = mod();

if (!buildSrcFiles(moduleDIE)) return false;


if (!parse_int(moduleDIE, true)) return false;

Expand Down
16 changes: 10 additions & 6 deletions symtabAPI/src/emitElf-64.C
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,10 @@ bool emitElf64<ElfTypes>::driver(std::string fName) {
if (startMovingSections || obj->isStaticBinary()
|| obj->getObjectType() == obj_SharedLib)
newshdr->sh_offset += pgSize;
//else if (createNewPhdr) newshdr->sh_offset += pgSize; //oldEhdr->e_phentsize;
else if (createNewPhdr) {
newshdr->sh_offset += oldEhdr->e_phentsize;
newshdr->sh_addr -= pgSize - oldEhdr->e_phentsize;
}
}
}

Expand Down Expand Up @@ -1090,12 +1093,13 @@ void emitElf64<ElfTypes>::fixPhdrs(unsigned &extraAlignSize) {
newPhdr->p_flags = PF_R + PF_W + PF_X;
newPhdr->p_align = pgSize;
}
else if (old->p_type == PT_INTERP && movePHdrsFirst
&& old->p_offset && newEhdr->e_phnum >= oldEhdr->e_phnum) {
Elf_Off interp_shift = library_adjust; //(Elf_Off) oldEhdr->e_phentsize * (Elf_Off)(newEhdr->e_phnum - oldEhdr->e_phnum);
else if (old->p_type == PT_INTERP && movePHdrsFirst && old->p_offset) {
Elf_Off interp_shift = library_adjust;
if (newEhdr->e_phnum >= oldEhdr->e_phnum)
interp_shift += (Elf_Off) oldEhdr->e_phentsize * (Elf_Off)(newEhdr->e_phnum - oldEhdr->e_phnum);
newPhdr->p_offset += interp_shift;
newPhdr->p_vaddr += interp_shift;
newPhdr->p_paddr += interp_shift;
newPhdr->p_vaddr += interp_shift - pgSize;
newPhdr->p_paddr += interp_shift - pgSize;
}
else if (movePHdrsFirst && old->p_offset) {
newPhdr->p_offset += pgSize;
Expand Down

0 comments on commit dcc529b

Please sign in to comment.