mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 03:50:17 +08:00
[lld-macho] Generate ObjC symbols from .tbd files
I followed similar logic in TapiFile.cpp. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D85255
This commit is contained in:
@@ -403,13 +403,35 @@ DylibFile::DylibFile(std::shared_ptr<llvm::MachO::InterfaceFile> interface,
|
||||
umbrella = this;
|
||||
|
||||
dylibName = saver.save(interface->getInstallName());
|
||||
auto addSymbol = [&](const Twine &name) -> void {
|
||||
symbols.push_back(symtab->addDylib(saver.save(name), umbrella,
|
||||
/*isWeakDef=*/false,
|
||||
/*isTlv=*/false));
|
||||
};
|
||||
// TODO(compnerd) filter out symbols based on the target platform
|
||||
// TODO: handle weak defs, thread locals
|
||||
for (const auto symbol : interface->symbols())
|
||||
if (symbol->getArchitectures().has(config->arch))
|
||||
symbols.push_back(symtab->addDylib(saver.save(symbol->getName()),
|
||||
umbrella, /*isWeakDef=*/false,
|
||||
/*isTlv=*/false));
|
||||
for (const auto symbol : interface->symbols()) {
|
||||
if (!symbol->getArchitectures().has(config->arch))
|
||||
continue;
|
||||
|
||||
switch (symbol->getKind()) {
|
||||
case SymbolKind::GlobalSymbol:
|
||||
addSymbol(symbol->getName());
|
||||
break;
|
||||
case SymbolKind::ObjectiveCClass:
|
||||
// XXX ld64 only creates these symbols when -ObjC is passed in. We may
|
||||
// want to emulate that.
|
||||
addSymbol("_OBJC_CLASS_$_" + symbol->getName());
|
||||
addSymbol("_OBJC_METACLASS_$_" + symbol->getName());
|
||||
break;
|
||||
case SymbolKind::ObjectiveCClassEHType:
|
||||
addSymbol("_OBJC_EHTYPE_$_" + symbol->getName());
|
||||
break;
|
||||
case SymbolKind::ObjectiveCInstanceVariable:
|
||||
addSymbol("_OBJC_IVAR_$_" + symbol->getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO(compnerd) properly represent the hierarchy of the documents as it is
|
||||
// in theory possible to have re-exported dylibs from re-exported dylibs which
|
||||
// should be parent'ed to the child.
|
||||
|
||||
@@ -6,5 +6,8 @@ install-name: '/System/Library/Frameworks/CoreFoundation.framework/CoreFound
|
||||
current-version: 0001.001.1
|
||||
compatibility-version: 150
|
||||
exports:
|
||||
- archs: [ 'x86_64' ]
|
||||
symbols: [ '__CFBigNumGetInt128' ]
|
||||
- archs: [ 'x86_64' ]
|
||||
symbols: [ '__CFBigNumGetInt128' ]
|
||||
objc-classes: [ NSObject ]
|
||||
objc-ivars: [ NSConstantArray._count ]
|
||||
objc-eh-types: [ NSException ]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# RUN: mkdir -p %t
|
||||
#
|
||||
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
|
||||
# RUN: lld -flavor darwinnew -o %t/test -Z -L%S/Inputs/MacOSX.sdk/usr/lib -lSystem %t/test.o
|
||||
# RUN: lld -flavor darwinnew -o %t/test -syslibroot %S/Inputs/MacOSX.sdk -lSystem -framework CoreFoundation %t/test.o
|
||||
#
|
||||
# RUN: llvm-objdump --bind --no-show-raw-insn -d -r %t/test | FileCheck %s
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
# CHECK: movq {{.*}} # [[ADDR:[0-9a-f]+]]
|
||||
|
||||
# CHECK: Bind table:
|
||||
# CHECK: __DATA_CONST __got 0x[[ADDR]] pointer 0 libSystem ___nan
|
||||
# CHECK-DAG: __DATA_CONST __got 0x[[ADDR]] pointer 0 libSystem ___nan
|
||||
# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_CLASS_$_NSObject
|
||||
# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_METACLASS_$_NSObject
|
||||
# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_IVAR_$_NSConstantArray._count
|
||||
# CHECK-DAG: __DATA __data {{.*}} pointer 0 CoreFoundation _OBJC_EHTYPE_$_NSException
|
||||
|
||||
.section __TEXT,__text
|
||||
.global _main
|
||||
@@ -19,3 +23,9 @@
|
||||
_main:
|
||||
movq ___nan@GOTPCREL(%rip), %rax
|
||||
ret
|
||||
|
||||
.data
|
||||
.quad _OBJC_CLASS_$_NSObject
|
||||
.quad _OBJC_METACLASS_$_NSObject
|
||||
.quad _OBJC_IVAR_$_NSConstantArray._count
|
||||
.quad _OBJC_EHTYPE_$_NSException
|
||||
|
||||
Reference in New Issue
Block a user