[PATCH] D44357: COFF: Adjust how we detect weak externals

Martell Malone via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 10 16:26:56 PST 2018


martell created this revision.
Herald added a subscriber: llvm-commits.

https://bugs.llvm.org/show_bug.cgi?id=36096

NOT READY.
Will verify later and add test cases
Please do not review yet :)


Repository:
  rL LLVM

https://reviews.llvm.org/D44357

Files:
  lib/Object/ArchiveWriter.cpp
  lib/Object/COFFImportFile.cpp
  lib/Object/COFFObjectFile.cpp


Index: lib/Object/COFFObjectFile.cpp
===================================================================
--- lib/Object/COFFObjectFile.cpp
+++ lib/Object/COFFObjectFile.cpp
@@ -217,11 +217,8 @@
   if (Symb.isExternal() || Symb.isWeakExternal())
     Result |= SymbolRef::SF_Global;
 
-  if (Symb.isWeakExternal()) {
+  if (Symb.isWeakExternal())
     Result |= SymbolRef::SF_Weak;
-    // We use indirect to allow the archiver to write weak externs
-    Result |= SymbolRef::SF_Indirect;
-  }
 
   if (Symb.getSectionNumber() == COFF::IMAGE_SYM_ABSOLUTE)
     Result |= SymbolRef::SF_Absolute;
@@ -235,7 +232,8 @@
   if (Symb.isCommon())
     Result |= SymbolRef::SF_Common;
 
-  if (Symb.isAnyUndefined())
+  if (Symb.isAnyUndefined() && !(this->getCharacteristics() &
+    COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS))
     Result |= SymbolRef::SF_Undefined;
 
   return Result;
Index: lib/Object/COFFImportFile.cpp
===================================================================
--- lib/Object/COFFImportFile.cpp
+++ lib/Object/COFFImportFile.cpp
@@ -546,7 +546,12 @@
        u16(0),
        IMAGE_SYM_CLASS_WEAK_EXTERNAL,
        1},
-      {{{2, 0, 0, 0, 3, 0, 0, 0}}, u32(0), u16(0), u16(0), uint8_t(0), 0},
+      {{{2, 0, 0, 0, IMAGE_WEAK_EXTERN_SEARCH_ALIAS, 0, 0, 0}},
+       u32(0),
+       u16(0),
+       u16(0),
+       IMAGE_SYM_CLASS_NULL,
+       0},
   };
   SymbolTable[2].Name.Offset.Offset = sizeof(uint32_t);
 
Index: lib/Object/ArchiveWriter.cpp
===================================================================
--- lib/Object/ArchiveWriter.cpp
+++ lib/Object/ArchiveWriter.cpp
@@ -305,8 +305,7 @@
     return false;
   if (!(Symflags & object::SymbolRef::SF_Global))
     return false;
-  if (Symflags & object::SymbolRef::SF_Undefined &&
-      !(Symflags & object::SymbolRef::SF_Indirect))
+  if (Symflags & object::SymbolRef::SF_Undefined)
     return false;
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44357.137931.patch
Type: text/x-patch
Size: 1905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180311/493f093b/attachment.bin>


More information about the llvm-commits mailing list