COFF: Assign the correct symbol type to internal functions.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 6 Aug 2015 05:26:35 +0000 (05:26 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 6 Aug 2015 05:26:35 +0000 (05:26 +0000)
The COFFSymbolRef::isFunctionDefinition() function tests for several conditions
that are not related to whether a symbol is a function, but rather whether
the symbol meets the requirements for a function definition auxiliary record,
which excludes certain symbols such as internal functions and undefined
references. The test we need to determine the symbol type is much simpler:
we only need to compare the complex type against IMAGE_SYM_DTYPE_FUNCTION.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244195 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/COFFObjectFile.cpp
test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64 [new file with mode: 0755]
test/tools/llvm-objdump/X86/coff-dis-internal.test [new file with mode: 0644]

index d110b9293ba2fc5fe5c96c0a1b470a1e580a9bd9..fa6aa4ced392572ae740cf4cfe18b22f3c195798 100644 (file)
@@ -186,10 +186,10 @@ SymbolRef::Type COFFObjectFile::getSymbolType(DataRefImpl Ref) const {
   COFFSymbolRef Symb = getCOFFSymbol(Ref);
   int32_t SectionNumber = Symb.getSectionNumber();
 
+  if (Symb.getComplexType() == COFF::IMAGE_SYM_DTYPE_FUNCTION)
+    return SymbolRef::ST_Function;
   if (Symb.isAnyUndefined())
     return SymbolRef::ST_Unknown;
-  if (Symb.isFunctionDefinition())
-    return SymbolRef::ST_Function;
   if (Symb.isCommon())
     return SymbolRef::ST_Data;
   if (Symb.isFileRecord())
diff --git a/test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64 b/test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64
new file mode 100755 (executable)
index 0000000..0c38deb
Binary files /dev/null and b/test/tools/llvm-objdump/X86/Inputs/internal.exe.coff-x86_64 differ
diff --git a/test/tools/llvm-objdump/X86/coff-dis-internal.test b/test/tools/llvm-objdump/X86/coff-dis-internal.test
new file mode 100644 (file)
index 0000000..530dadc
--- /dev/null
@@ -0,0 +1,3 @@
+RUN: llvm-objdump -d %p/Inputs/internal.exe.coff-x86_64 | FileCheck %s
+
+CHECK: callq {{.*}} <foo>