[llvm] r206146 - tools: simplify symbol handling in objdump
Saleem Abdulrasool
compnerd at compnerd.org
Mon Apr 14 09:29:05 PDT 2014
On Mon, Apr 14, 2014 at 4:28 AM, Evgeniy Stepanov <eugeni.stepanov at gmail.com
> wrote:
> Hi,
>
> something in this change caused a heap buffer overflow:
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3022/steps/check-llvm%20asan/logs/stdio
Somehow I managed to miss two lines in my commit :-(. Thanks for the heads
up about this failure! Ill fix this shortly (after I re-run tests).
>
> On Mon, Apr 14, 2014 at 6:37 AM, Saleem Abdulrasool
> <compnerd at compnerd.org> wrote:
> > Author: compnerd
> > Date: Sun Apr 13 21:37:28 2014
> > New Revision: 206146
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=206146&view=rev
> > Log:
> > tools: simplify symbol handling in objdump
> >
> > Rather than switching behaviour on whether a previous symbol has an
> auxiliary
> > symbol record for the next count of elements, simply iterate over the
> auxiliary
> > symbols right after processing the current symbol entry. This makes the
> > behaviour much simpler to follow and similar to llvm-readobj and
> yaml2obj.
> >
> > Modified:
> > llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
> >
> > Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=206146&r1=206145&r2=206146&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
> > +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Sun Apr 13 21:37:28
> 2014
> > @@ -664,14 +664,31 @@ static void PrintSectionContents(const O
> >
> > static void PrintCOFFSymbolTable(const COFFObjectFile *coff) {
> > const coff_file_header *header;
> > - if (error(coff->getHeader(header))) return;
> > - int aux_count = 0;
> > - const coff_symbol *symbol = 0;
> > - for (int i = 0, e = header->NumberOfSymbols; i != e; ++i) {
> > - if (aux_count--) {
> > - if (symbol->isSectionDefinition()) {
> > + if (error(coff->getHeader(header)))
> > + return;
> > +
> > + for (unsigned SI = 0, SE = header->NumberOfSymbols; SI != SE; ++SI) {
> > + const coff_symbol *Symbol;
> > + StringRef Name;
> > + if (error(coff->getSymbol(SI, Symbol)))
> > + return;
> > +
> > + if (error(coff->getSymbolName(Symbol, Name)))
> > + return;
> > +
> > + outs() << "[" << format("%2d", SI) << "]"
> > + << "(sec " << format("%2d", int(Symbol->SectionNumber)) <<
> ")"
> > + << "(fl 0x00)" // Flag bits, which COFF doesn't have.
> > + << "(ty " << format("%3x", unsigned(Symbol->Type)) << ")"
> > + << "(scl " << format("%3x", unsigned(Symbol->StorageClass))
> << ") "
> > + << "(nx " << unsigned(Symbol->NumberOfAuxSymbols) << ") "
> > + << "0x" << format("%08x", unsigned(Symbol->Value)) << " "
> > + << Name << "\n";
> > +
> > + for (unsigned AI = 0, AE = Symbol->NumberOfAuxSymbols; AI < AE;
> ++AI, ++SI) {
> > + if (Symbol->isSectionDefinition()) {
> > const coff_aux_section_definition *asd;
> > - if (error(coff->getAuxSymbol<coff_aux_section_definition>(i,
> asd)))
> > + if (error(coff->getAuxSymbol<coff_aux_section_definition>(SI +
> 1, asd)))
> > return;
> >
> > outs() << "AUX "
> > @@ -683,31 +700,17 @@ static void PrintCOFFSymbolTable(const C
> > << format("assoc %d comdat %d\n"
> > , unsigned(asd->Number)
> > , unsigned(asd->Selection));
> > - } else if (symbol->isFileRecord()) {
> > + } else if (Symbol->isFileRecord()) {
> > const coff_aux_file *AF;
> > - if (error(coff->getAuxSymbol<coff_aux_file>(i, AF)))
> > + if (error(coff->getAuxSymbol<coff_aux_file>(SI + 1, AF)))
> > return;
> >
> > - StringRef Name(AF->FileName, (aux_count + 1) *
> COFF::SymbolSize);
> > + StringRef Name(AF->FileName,
> > + Symbol->NumberOfAuxSymbols * COFF::SymbolSize);
> > outs() << "AUX " << Name.rtrim(StringRef("\0", 1)) << '\n';
> > - i = i + aux_count;
> > - aux_count = 0;
> > } else {
> > outs() << "AUX Unknown\n";
> > }
> > - } else {
> > - StringRef name;
> > - if (error(coff->getSymbol(i, symbol))) return;
> > - if (error(coff->getSymbolName(symbol, name))) return;
> > - outs() << "[" << format("%2d", i) << "]"
> > - << "(sec " << format("%2d", int(symbol->SectionNumber)) <<
> ")"
> > - << "(fl 0x00)" // Flag bits, which COFF doesn't have.
> > - << "(ty " << format("%3x", unsigned(symbol->Type)) << ")"
> > - << "(scl " << format("%3x",
> unsigned(symbol->StorageClass)) << ") "
> > - << "(nx " << unsigned(symbol->NumberOfAuxSymbols) << ") "
> > - << "0x" << format("%08x", unsigned(symbol->Value)) << " "
> > - << name << "\n";
> > - aux_count = symbol->NumberOfAuxSymbols;
> > }
> > }
> > }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140414/712ae8b3/attachment.html>
More information about the llvm-commits
mailing list