[lld] r206931 - [PECOFF] Skip IMAGE_SYM_DEBUG sections correctly.

Rui Ueyama ruiu at google.com
Tue Apr 22 16:48:43 PDT 2014


Author: ruiu
Date: Tue Apr 22 18:48:42 2014
New Revision: 206931

URL: http://llvm.org/viewvc/llvm-project?rev=206931&view=rev
Log:
[PECOFF] Skip IMAGE_SYM_DEBUG sections correctly.

We don't use sections with IMAGE_SYM_DEBUG attribute so we basically
want to the symbols for them when reading symbol table. When we skip
them, we need to skip auxiliary symbols too. Otherwise weird error
would happen because aux symbols would be interpreted as regular ones.

Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
    lld/trunk/test/pecoff/Inputs/hello.obj.yaml

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=206931&r1=206930&r2=206931&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Tue Apr 22 18:48:42 2014
@@ -324,13 +324,13 @@ error_code FileCOFF::readSymbolTable(vec
   for (uint32_t i = 0, e = header->NumberOfSymbols; i != e; ++i) {
     // Retrieve the symbol.
     const coff_symbol *sym;
+    StringRef name;
     if (error_code ec = _obj->getSymbol(i, sym))
       return ec;
-    assert(sym->SectionNumber != llvm::COFF::IMAGE_SYM_DEBUG &&
-           "Cannot atomize IMAGE_SYM_DEBUG!");
+    if (sym->SectionNumber == llvm::COFF::IMAGE_SYM_DEBUG)
+      goto next;
     result.push_back(sym);
 
-    StringRef name;
     if (error_code ec = _obj->getSymbolName(sym, name))
       return ec;
 
@@ -338,7 +338,7 @@ error_code FileCOFF::readSymbolTable(vec
     // with Safe Exception Handling.
     if (name == "@feat.00") {
       _compatibleWithSEH = true;
-      continue;
+      goto next;
     }
 
     // Cache the name.
@@ -354,8 +354,9 @@ error_code FileCOFF::readSymbolTable(vec
       if (error_code ec = _obj->getAuxSymbol(i + 1, aux))
         return ec;
       _auxSymbol[sym] = aux;
-      i += sym->NumberOfAuxSymbols;
     }
+ next:
+      i += sym->NumberOfAuxSymbols;
   }
   return error_code::success();
 }
@@ -482,7 +483,8 @@ error_code FileCOFF::createDefinedSymbol
     }
 
     // Skip if it's not for defined atom.
-    if (sym->SectionNumber == llvm::COFF::IMAGE_SYM_ABSOLUTE ||
+    if (sym->SectionNumber == llvm::COFF::IMAGE_SYM_DEBUG ||
+        sym->SectionNumber == llvm::COFF::IMAGE_SYM_ABSOLUTE ||
         sym->SectionNumber == llvm::COFF::IMAGE_SYM_UNDEFINED)
       continue;
 

Modified: lld/trunk/test/pecoff/Inputs/hello.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/hello.obj.yaml?rev=206931&r1=206930&r2=206931&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/hello.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/hello.obj.yaml Tue Apr 22 18:48:42 2014
@@ -101,4 +101,11 @@ symbols:
       NumberOfLinenumbers: 0
       CheckSum:        0
       Number:          0
+  - Name:            .file
+    Value:           0
+    SectionNumber:   65534
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_STATIC
+    File: 	     "hello.c"
 ...





More information about the llvm-commits mailing list