diff options
author | Jez Ng <jezng@fb.com> | 2020-08-31 20:32:39 -0700 |
---|---|---|
committer | Jez Ng <jezng@fb.com> | 2020-09-20 20:43:14 -0700 |
commit | 0a7e56f74c2adde9a4bc2c1163e7ed3aff984584 (patch) | |
tree | f646f53a3cb7bb051373c73663b8cbce01f9abc3 /lld | |
parent | 0cd73dbe2c0d169ec2cdd9a8264f4ee1695b53b7 (diff) | |
download | llvm-0a7e56f74c2adde9a4bc2c1163e7ed3aff984584.zip llvm-0a7e56f74c2adde9a4bc2c1163e7ed3aff984584.tar.gz llvm-0a7e56f74c2adde9a4bc2c1163e7ed3aff984584.tar.bz2 |
[lld-macho] Mark weak symbols in symbol table
Reviewed By: #lld-macho, smeenai
Differential Revision: https://reviews.llvm.org/D86908
Diffstat (limited to 'lld')
-rw-r--r-- | lld/MachO/SyntheticSections.cpp | 3 | ||||
-rw-r--r-- | lld/test/MachO/symtab.s | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp index 66dcbde..0106426 100644 --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -473,10 +473,11 @@ void SymtabSection::writeTo(uint8_t *buf) const { 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(); } diff --git a/lld/test/MachO/symtab.s b/lld/test/MachO/symtab.s index 44a0169..1efa7a2 100644 --- a/lld/test/MachO/symtab.s +++ b/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 @@ foo: .asciz "Hello world!\n" .text +.weak_definition bar .global bar .global _main |