[PATCH] D86908: [lld-macho] Mark weak symbols in symbol table

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 16:25:48 PDT 2020


int3 updated this revision to Diff 290604.
int3 marked an inline comment as done.
int3 added a comment.

adjust comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86908/new/

https://reviews.llvm.org/D86908

Files:
  lld/MachO/SyntheticSections.cpp
  lld/test/MachO/symtab.s


Index: lld/test/MachO/symtab.s
===================================================================
--- lld/test/MachO/symtab.s
+++ lld/test/MachO/symtab.s
@@ -20,7 +20,8 @@
 # CHECK-NEXT:     Type: Section (0xE)
 # CHECK-NEXT:     Section: __text (0x1)
 # CHECK-NEXT:     RefType:
-# CHECK-NEXT:     Flags [ (0x0)
+# CHECK-NEXT:     Flags [ (0x80)
+# CHECK-NEXT:       WeakDef (0x80)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Value:
 # CHECK-NEXT:   }
@@ -42,6 +43,7 @@
   .asciz "Hello world!\n"
 
 .text
+.weak_definition bar
 .global bar
 .global _main
 
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -473,10 +473,11 @@
   for (const SymtabEntry &entry : symbols) {
     nList->n_strx = entry.strx;
     // TODO support other symbol types
-    // TODO populate n_desc
+    // TODO populate n_desc with more flags
     if (auto *defined = dyn_cast<Defined>(entry.sym)) {
       nList->n_type = MachO::N_EXT | MachO::N_SECT;
       nList->n_sect = defined->isec->parent->index;
+      nList->n_desc |= defined->isWeakDef() ? MachO::N_WEAK_DEF : 0;
       // For the N_SECT symbol type, n_value is the address of the symbol
       nList->n_value = defined->value + defined->isec->getVA();
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86908.290604.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200908/d1a98313/attachment.bin>


More information about the llvm-commits mailing list