Skip to content

Commit

Permalink
Fixed bug where dynStr memsize was 0. Use filesize is that case. Undi…
Browse files Browse the repository at this point in the history
…d the check for 0 virtual address in symTab.
  • Loading branch information
jacob-baines committed Oct 10, 2015
1 parent 863a78d commit 8627fe0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
18 changes: 4 additions & 14 deletions src/abstract_segments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ AbstractSegments::AbstractSegments() :
m_is64(false),
m_isLE(false),
m_isDY(false),
m_fakeDynamicStringTable(false),
m_strTabMissingVirtAddress(false)
m_fakeDynamicStringTable(false)
{
}

Expand Down Expand Up @@ -85,8 +84,9 @@ void AbstractSegments::makeSegmentFromProgramHeader(const AbstractProgramHeader&
m_setBase = true;
}
m_programs.emplace_back(p_header.getName(), p_header.getName(), p_header.getOffset(),
p_header.getVirtualAddress(), p_header.getMemorySize(), 0,
p_header.isExecutable(), p_header.isWritable(),
p_header.getVirtualAddress(),
p_header.getMemorySize() ? p_header.getMemorySize() : p_header.getFileSize(),
0, p_header.isExecutable(), p_header.isWritable(),
p_header.getType() == elf::k_pdynamic);
}

Expand Down Expand Up @@ -233,12 +233,6 @@ void AbstractSegments::generateSegments()
}
else
{
// a missing virtual address is enough to confuse readelf.
if (m_sections[link].getPhysOffset() != 0 &&
m_sections[link].getVirtAddress() == 0)
{
m_strTabMissingVirtAddress = true;
}
m_types.push_back(new StringTableSegment(m_data,
m_sections[link].getPhysOffset(), m_sections[link].getSize(), elf::k_strtab));
m_offsets.insert(m_data + m_sections[link].getPhysOffset());
Expand Down Expand Up @@ -337,10 +331,6 @@ void AbstractSegments::evaluate(std::vector<std::pair<boost::int32_t, std::strin
{
p_capabilities[elf::k_antidebug].insert("Fake symbol table strings in sections");
}
if (m_strTabMissingVirtAddress)
{
p_capabilities[elf::k_antidebug].insert("Symbol table strings section had virtual address zeroed out");
}
}

std::vector<AbstractSymbol> AbstractSegments::getAllSymbols() const
Expand Down
3 changes: 0 additions & 3 deletions src/abstract_segments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ class AbstractSegments

//! indicates if we detected a fake dynamic string table
bool m_fakeDynamicStringTable;

//! indicates if we detected a valid string table section header with no virt addr
bool m_strTabMissingVirtAddress;
};

#endif
14 changes: 7 additions & 7 deletions src/programheaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ std::string ProgramHeaders::printToStdOut() const
BOOST_FOREACH(const AbstractProgramHeader& header, m_programHeaders)
{
returnValue << "\tEntry type=" << header.getName()
<< " flags=" << std::dec << header.getFlags()
<< " offset=0x" << std::hex << header.getOffset()
<< " vaddr=0x" << header.getVirtualAddress()
<< " paddr=0x" << header.getPhysicalAddress()
<< " filesz=0x" << header.getFileSize()
<< " memsz=0x" << header.getMemorySize()
<< std::dec << "\n";
<< " flags=" << std::dec << header.getFlags()
<< " offset=0x" << std::hex << header.getOffset()
<< " vaddr=0x" << header.getVirtualAddress()
<< " paddr=0x" << header.getPhysicalAddress()
<< " filesz=0x" << header.getFileSize()
<< " memsz=0x" << header.getMemorySize()
<< std::dec << "\n";
}
return returnValue.str();
}
Expand Down
3 changes: 1 addition & 2 deletions src/symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Symbols::createSymbols(const char* p_data,
bool p_is64, bool p_isLE, bool p_isDY)
{
m_isDY = p_isDY;
if (p_symTabOffset == 0 || p_strTabOffset == 0)
if (p_symTabOffset == 0 || p_strTabOffset == 0 || p_symTabSize == 0)
{
return;
}
Expand Down Expand Up @@ -187,7 +187,6 @@ void Symbols::createSymbols(const char* p_data,
m_files.insert(symbol.getName());
}
}

m_symbols.push_back(symbol);
}
}
Expand Down

0 comments on commit 8627fe0

Please sign in to comment.