[llvm] r255350 - [dsymutil] Ignore absolute symbols in the debug map

Frederic Riss via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 11 09:50:38 PST 2015


Author: friss
Date: Fri Dec 11 11:50:37 2015
New Revision: 255350

URL: http://llvm.org/viewvc/llvm-project?rev=255350&view=rev
Log:
[dsymutil] Ignore absolute symbols in the debug map

Quoting from the comment added to the code:

    // Objective-C on i386 uses artificial absolute symbols to
    // perform some link time checks. Those symbols have a fixed 0
    // address that might conflict with real symbols in the object
    // file. As I cannot see a way for absolute symbols to find
    // their way into the debug information, let's just ignore those.

Added:
    llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386   (with props)
    llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o
    llvm/trunk/test/tools/dsymutil/absolute_symbol.test
Modified:
    llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp

Added: llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386?rev=255350&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386 (added) and llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386 Fri Dec 11 11:50:37 2015 differ

Propchange: llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386
------------------------------------------------------------------------------
    svn:executable = *

Added: llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o?rev=255350&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o (added) and llvm/trunk/test/tools/dsymutil/Inputs/absolute_sym.macho.i386.o Fri Dec 11 11:50:37 2015 differ

Added: llvm/trunk/test/tools/dsymutil/absolute_symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/absolute_symbol.test?rev=255350&view=auto
==============================================================================
--- llvm/trunk/test/tools/dsymutil/absolute_symbol.test (added)
+++ llvm/trunk/test/tools/dsymutil/absolute_symbol.test Fri Dec 11 11:50:37 2015
@@ -0,0 +1,16 @@
+RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path %p %p/Inputs/absolute_sym.macho.i386 | FileCheck %s
+
+The tested object file has been created by the dummy Objective-C code:
+ at interface Foo
+ at end
+
+ at implementation Foo
+ at end
+
+int main() { return 0; }
+
+compiled for i386. This create an absolute symbol .objc_class_name_Foo
+We must not consider this symbol for debug info linking as its address
+might conflict with other real symbols in the same file.
+
+CHECK-NOT: objc_class_name_Foo

Modified: llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp?rev=255350&r1=255349&r2=255350&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp (original)
+++ llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp Fri Dec 11 11:50:37 2015
@@ -10,6 +10,7 @@
 #include "BinaryHolder.h"
 #include "DebugMap.h"
 #include "dsymutil.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Object/MachO.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
@@ -53,7 +54,7 @@ private:
   /// Owns the MemoryBuffer for the currently handled object file.
   BinaryHolder CurrentObjectHolder;
   /// Map of the currently processed object file symbol addresses.
-  StringMap<uint64_t> CurrentObjectAddresses;
+  StringMap<Optional<uint64_t>> CurrentObjectAddresses;
   /// Element of the debug map corresponfing to the current object file.
   DebugMapObject *CurrentDebugMapObject;
 
@@ -388,7 +389,9 @@ void MachODebugMapParser::handleStabSymb
   if (ObjectSymIt == CurrentObjectAddresses.end())
     return Warning("could not find object file symbol for symbol " +
                    Twine(Name));
-  if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value,
+  if (!ObjectSymIt->getValue())
+    return;
+  if (!CurrentDebugMapObject->addSymbol(Name, *ObjectSymIt->getValue(), Value,
                                         Size))
     return Warning(Twine("failed to insert symbol '") + Name +
                    "' in the debug map.");
@@ -404,7 +407,15 @@ void MachODebugMapParser::loadCurrentObj
     ErrorOr<StringRef> Name = Sym.getName();
     if (!Name)
       continue;
-    CurrentObjectAddresses[*Name] = Addr;
+    // Objective-C on i386 uses artificial absolute symbols to
+    // perform some link time checks. Those symbols have a fixed 0
+    // address that might conflict with real symbols in the object
+    // file. As I cannot see a way for absolute symbols to find
+    // their way into the debug information, let's just ignore those.
+    if (Sym.getFlags() & SymbolRef::SF_Absolute)
+      CurrentObjectAddresses[*Name] = None;
+    else
+      CurrentObjectAddresses[*Name] = Addr;
   }
 }
 




More information about the llvm-commits mailing list