[llvm] r371576 - [llvm-nm] Add tapi file support
Cyndy Ishida via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 17:00:53 PDT 2019
Author: cishida
Date: Tue Sep 10 17:00:53 2019
New Revision: 371576
URL: http://llvm.org/viewvc/llvm-project?rev=371576&view=rev
Log:
[llvm-nm] Add tapi file support
Summary:
This commit is the final one for adding tapi support to the llvm-nm implementation.
This commit also has accompanying tests the additions to lib/Object
Reviewers: ributzka, steven_wu
Reviewed By: ributzka
Subscribers: hiraditya, plotfi, dexonsmith, rupprecht, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66160
Added:
llvm/trunk/test/Object/Inputs/tapi-invalid-v1.tbd
llvm/trunk/test/Object/Inputs/tapi-invalid-v2.tbd
llvm/trunk/test/Object/Inputs/tapi-invalid-v3.tbd
llvm/trunk/test/Object/Inputs/tapi-v1.tbd
llvm/trunk/test/Object/Inputs/tapi-v2.tbd
llvm/trunk/test/Object/Inputs/tapi-v3.tbd
llvm/trunk/test/Object/nm-tapi-invalids.test
llvm/trunk/test/Object/nm-tapi.test
Modified:
llvm/trunk/include/llvm/Object/TapiFile.h
llvm/trunk/include/llvm/TextAPI/MachO/Architecture.def
llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h
llvm/trunk/lib/Object/TapiFile.cpp
llvm/trunk/lib/TextAPI/MachO/Architecture.cpp
llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/include/llvm/Object/TapiFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/TapiFile.h?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/TapiFile.h (original)
+++ llvm/trunk/include/llvm/Object/TapiFile.h Tue Sep 10 17:00:53 2019
@@ -41,6 +41,8 @@ public:
static bool classof(const Binary *v) { return v->isTapiFile(); }
+ bool is64Bit() { return MachO::is64Bit(Arch); }
+
private:
struct Symbol {
StringRef Prefix;
@@ -52,6 +54,7 @@ private:
};
std::vector<Symbol> Symbols;
+ MachO::Architecture Arch;
};
} // end namespace object.
Modified: llvm/trunk/include/llvm/TextAPI/MachO/Architecture.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TextAPI/MachO/Architecture.def?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TextAPI/MachO/Architecture.def (original)
+++ llvm/trunk/include/llvm/TextAPI/MachO/Architecture.def Tue Sep 10 17:00:53 2019
@@ -13,26 +13,26 @@
///
/// X86 architectures sorted by cpu type and sub type id.
///
-ARCHINFO(i386, MachO::CPU_TYPE_I386, MachO::CPU_SUBTYPE_I386_ALL)
-ARCHINFO(x86_64, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_ALL)
-ARCHINFO(x86_64h, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_H)
+ARCHINFO(i386, MachO::CPU_TYPE_I386, MachO::CPU_SUBTYPE_I386_ALL, 32)
+ARCHINFO(x86_64, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_ALL, 64)
+ARCHINFO(x86_64h, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_H, 64)
///
/// ARM architectures sorted by cpu sub type id.
///
-ARCHINFO(armv4t, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V4T)
-ARCHINFO(armv6, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6)
-ARCHINFO(armv5, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V5TEJ)
-ARCHINFO(armv7, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7)
-ARCHINFO(armv7s, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7S)
-ARCHINFO(armv7k, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7K)
-ARCHINFO(armv6m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6M)
-ARCHINFO(armv7m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7M)
-ARCHINFO(armv7em, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7EM)
+ARCHINFO(armv4t, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V4T, 32)
+ARCHINFO(armv6, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6, 32)
+ARCHINFO(armv5, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V5TEJ, 32)
+ARCHINFO(armv7, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7, 32)
+ARCHINFO(armv7s, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7S, 32)
+ARCHINFO(armv7k, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7K, 32)
+ARCHINFO(armv6m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6M, 32)
+ARCHINFO(armv7m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7M, 32)
+ARCHINFO(armv7em, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7EM, 32)
///
/// ARM64 architectures sorted by cpu sub type id.
///
-ARCHINFO(arm64, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64_ALL)
+ARCHINFO(arm64, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64_ALL, 64)
Modified: llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h (original)
+++ llvm/trunk/include/llvm/TextAPI/MachO/Architecture.h Tue Sep 10 17:00:53 2019
@@ -21,7 +21,7 @@ namespace MachO {
/// Defines the architecture slices that are supported by Text-based Stub files.
enum Architecture : uint8_t {
-#define ARCHINFO(Arch, Type, SubType) AK_##Arch,
+#define ARCHINFO(Arch, Type, SubType, NumBits) AK_##Arch,
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
AK_unknown, // this has to go last.
@@ -39,6 +39,9 @@ StringRef getArchitectureName(Architectu
/// Convert an architecture slice to a CPU Type and Subtype pair.
std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch);
+/// Check if architecture is 64 bit
+bool is64Bit(Architecture);
+
raw_ostream &operator<<(raw_ostream &OS, Architecture Arch);
} // end namespace MachO.
Modified: llvm/trunk/lib/Object/TapiFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/TapiFile.cpp?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/lib/Object/TapiFile.cpp (original)
+++ llvm/trunk/lib/Object/TapiFile.cpp Tue Sep 10 17:00:53 2019
@@ -40,7 +40,7 @@ static uint32_t getFlags(const Symbol *S
TapiFile::TapiFile(MemoryBufferRef Source, const InterfaceFile &interface,
Architecture Arch)
- : SymbolicFile(ID_TapiFile, Source) {
+ : SymbolicFile(ID_TapiFile, Source), Arch(Arch) {
for (const auto *Symbol : interface.symbols()) {
if (!Symbol->getArchitectures().has(Arch))
continue;
Modified: llvm/trunk/lib/TextAPI/MachO/Architecture.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TextAPI/MachO/Architecture.cpp?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/lib/TextAPI/MachO/Architecture.cpp (original)
+++ llvm/trunk/lib/TextAPI/MachO/Architecture.cpp Tue Sep 10 17:00:53 2019
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/TextAPI/MachO/Architecture.h"
+#include "llvm/TextAPI/MachO/ArchitectureSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/MachO.h"
@@ -18,7 +19,7 @@ namespace llvm {
namespace MachO {
Architecture getArchitectureFromCpuType(uint32_t CPUType, uint32_t CPUSubType) {
-#define ARCHINFO(Arch, Type, Subtype) \
+#define ARCHINFO(Arch, Type, Subtype, NumBits) \
if (CPUType == (Type) && \
(CPUSubType & ~MachO::CPU_SUBTYPE_MASK) == (Subtype)) \
return AK_##Arch;
@@ -30,7 +31,7 @@ Architecture getArchitectureFromCpuType(
Architecture getArchitectureFromName(StringRef Name) {
return StringSwitch<Architecture>(Name)
-#define ARCHINFO(Arch, Type, Subtype) .Case(#Arch, AK_##Arch)
+#define ARCHINFO(Arch, Type, Subtype, NumBits) .Case(#Arch, AK_##Arch)
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
.Default(AK_unknown);
@@ -38,7 +39,7 @@ Architecture getArchitectureFromName(Str
StringRef getArchitectureName(Architecture Arch) {
switch (Arch) {
-#define ARCHINFO(Arch, Type, Subtype) \
+#define ARCHINFO(Arch, Type, Subtype, NumBits) \
case AK_##Arch: \
return #Arch;
#include "llvm/TextAPI/MachO/Architecture.def"
@@ -54,7 +55,7 @@ StringRef getArchitectureName(Architectu
std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch) {
switch (Arch) {
-#define ARCHINFO(Arch, Type, Subtype) \
+#define ARCHINFO(Arch, Type, Subtype, NumBits) \
case AK_##Arch: \
return std::make_pair(Type, Subtype);
#include "llvm/TextAPI/MachO/Architecture.def"
@@ -68,6 +69,22 @@ std::pair<uint32_t, uint32_t> getCPUType
return std::make_pair(0, 0);
}
+bool is64Bit(Architecture Arch) {
+ switch (Arch) {
+#define ARCHINFO(Arch, Type, Subtype, NumBits) \
+ case AK_##Arch: \
+ return NumBits == 64;
+#include "llvm/TextAPI/MachO/Architecture.def"
+#undef ARCHINFO
+ case AK_unknown:
+ return false;
+ }
+
+ // Appease some compilers that cannot figure out that this is a fully covered
+ // switch statement.
+ return false;
+}
+
raw_ostream &operator<<(raw_ostream &OS, Architecture Arch) {
OS << getArchitectureName(Arch);
return OS;
Modified: llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp (original)
+++ llvm/trunk/lib/TextAPI/MachO/TextStubCommon.cpp Tue Sep 10 17:00:53 2019
@@ -84,7 +84,7 @@ QuotingType ScalarTraits<PlatformKind>::
void ScalarBitSetTraits<ArchitectureSet>::bitset(IO &IO,
ArchitectureSet &Archs) {
-#define ARCHINFO(arch, type, subtype) \
+#define ARCHINFO(arch, type, subtype, numbits) \
IO.bitSetCase(Archs, #arch, 1U << static_cast<int>(AK_##arch));
#include "llvm/TextAPI/MachO/Architecture.def"
#undef ARCHINFO
Added: llvm/trunk/test/Object/Inputs/tapi-invalid-v1.tbd
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/tapi-invalid-v1.tbd?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/Inputs/tapi-invalid-v1.tbd (added)
+++ llvm/trunk/test/Object/Inputs/tapi-invalid-v1.tbd Tue Sep 10 17:00:53 2019
@@ -0,0 +1,21 @@
+--- !tapi-tbd-v1
+
+archs: [ armv7, armv7s, arm64 ]
+
+platform: ios
+install-name: /u/l/libfoo.dylib
+current-version: 1.2.3
+compatibility-version: 1.0
+swift-version: 0
+objc-constraint: none
+expors:
+ - archs: [ arm64, armv7 ]
+ allowed-clients: [ client ]
+ re-exports: [ ]
+ symbols: [ _sym, _test, _a, _b, ]
+ objc-classes: []
+ objc-ivars: []
+
+ weak-def-symbols: []
+ thread-local-symbols: []
+...
Added: llvm/trunk/test/Object/Inputs/tapi-invalid-v2.tbd
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/tapi-invalid-v2.tbd?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/Inputs/tapi-invalid-v2.tbd (added)
+++ llvm/trunk/test/Object/Inputs/tapi-invalid-v2.tbd Tue Sep 10 17:00:53 2019
@@ -0,0 +1,29 @@
+--- !tapi-tbd-v2
+uuids: [ "armv7: 00000000-0000-0000-0000-000000000000",
+ "armv7s: 11111111-1111-1111-1111-111111111111",
+ "arm64: 22222222-2222-2222-2222-222222222222" ]
+platform: ios
+flags: [ installapi ]
+install-name: /u/l/libfoo.dylib
+current-version: 1.2.3
+compatibility-version: 1.0
+swift-version: 0
+objc-constraint: retain_release
+parent-umbrella: Umbrella.dylib
+exports:
+ - archs: [ armv7, armv7s, arm64 ]
+ allowable-clients: [ client ]
+ re-exports: [ ]
+ symbols: [ _sym1, _sym2, _sym3 ]
+ objc-classes: []
+ objc-ivars: []
+
+ weak-def-symbols: []
+ thread-local-symbols: []
+undefineds:
+ - archs: [ arm64 ]
+ symbols: [ _sym ]
+ objc-classes: []
+ objc-ivars: []
+ weak-ref-symbols: []
+...
Added: llvm/trunk/test/Object/Inputs/tapi-invalid-v3.tbd
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/tapi-invalid-v3.tbd?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/Inputs/tapi-invalid-v3.tbd (added)
+++ llvm/trunk/test/Object/Inputs/tapi-invalid-v3.tbd Tue Sep 10 17:00:53 2019
@@ -0,0 +1,24 @@
+--- !tapi-tbd-v3
+archs: [ i386, armv7, armv7s ]
+platform: ios
+install-name: /usr/lib/libfoo.dylib
+swift-abi-version: 3
+exports:
+ - archs: [ i386, armv7, armv7s ]
+ re-exports: [ /usr/lib/external/liba.dylib ]
+ symbols: [ _sym1, _sym2 ]
+ objc-classes: [ NSString, NSBlockPredicate ]
+ objc-eh-types: [ NSString ]
+ objc-ivars: [ NSBlockPredicate._block ]
+ - archs: [ i386 ]
+ symbols: [ _sym3 ]
+--- !tapi-tbd-v3
+archs: [ armv7, armv7s ]
+platform: ios
+install-name: /usr/lib/liba.dylib
+swift-version: 3
+exports:
+ - archs: [ armv7, armv7s ]
+ re-exports: [ /usr/lib/internal/liba.dylib ]
+ symbols: [ _sym10, _sym11 ]
+...
Added: llvm/trunk/test/Object/Inputs/tapi-v1.tbd
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/tapi-v1.tbd?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/Inputs/tapi-v1.tbd (added)
+++ llvm/trunk/test/Object/Inputs/tapi-v1.tbd Tue Sep 10 17:00:53 2019
@@ -0,0 +1,21 @@
+--- !tapi-tbd-v1
+
+archs: [ armv7, armv7s ]
+
+platform: ios
+install-name: /u/l/libfoo.dylib
+current-version: 1.2.3
+compatibility-version: 1.0
+swift-version: 0
+objc-constraint: none
+exports:
+ - archs: [ armv7 ]
+ allowed-clients: [ client ]
+ re-exports: [ ]
+ symbols: [ _sym, ]
+ objc-classes: []
+ objc-ivars: []
+
+ weak-def-symbols: []
+ thread-local-symbols: [_sym]
+...
Added: llvm/trunk/test/Object/Inputs/tapi-v2.tbd
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/tapi-v2.tbd?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/Inputs/tapi-v2.tbd (added)
+++ llvm/trunk/test/Object/Inputs/tapi-v2.tbd Tue Sep 10 17:00:53 2019
@@ -0,0 +1,30 @@
+--- !tapi-tbd-v2
+archs: [ armv7, armv7s, arm64 ]
+uuids: [ "armv7: 00000000-0000-0000-0000-000000000000",
+ "armv7s: 11111111-1111-1111-1111-111111111111",
+ "arm64: 22222222-2222-2222-2222-222222222222" ]
+platform: ios
+flags: [ installapi ]
+install-name: /u/l/libfoo.dylib
+current-version: 1.2.3
+compatibility-version: 1.0
+swift-version: 0
+objc-constraint: retain_release
+parent-umbrella: Umbrella.dylib
+exports:
+ - archs: [ armv7, armv7s, arm64 ]
+ allowable-clients: [ client ]
+ re-exports: [ ]
+ symbols: [ _sym1, _sym2, _sym3 ]
+ objc-classes: []
+ objc-ivars: []
+
+ weak-def-symbols: []
+ thread-local-symbols: []
+undefineds:
+ - archs: [ arm64 ]
+ symbols: [ _sym ]
+ objc-classes: []
+ objc-ivars: []
+ weak-ref-symbols: []
+...
Added: llvm/trunk/test/Object/Inputs/tapi-v3.tbd
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/tapi-v3.tbd?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/Inputs/tapi-v3.tbd (added)
+++ llvm/trunk/test/Object/Inputs/tapi-v3.tbd Tue Sep 10 17:00:53 2019
@@ -0,0 +1,24 @@
+--- !tapi-tbd-v3
+archs: [ i386, armv7, armv7s ]
+platform: ios
+install-name: /usr/lib/libfoo.dylib
+swift-abi-version: 3
+exports:
+ - archs: [ i386, armv7, armv7s ]
+ re-exports: [ /usr/lib/external/liba.dylib ]
+ symbols: [ _sym1, _sym2 ]
+ objc-classes: [ NSString, NSBlockPredicate ]
+ objc-eh-types: [ NSString ]
+ objc-ivars: [ NSBlockPredicate._block ]
+ - archs: [ i386 ]
+ symbols: [ _sym3 ]
+--- !tapi-tbd-v3
+archs: [ armv7, armv7s ]
+platform: ios
+install-name: /usr/lib/liba.dylib
+swift-abi-version: 3
+exports:
+ - archs: [ armv7, armv7s ]
+ re-exports: [ /usr/lib/internal/liba.dylib ]
+ symbols: [ _sym10, _sym11 ]
+...
Added: llvm/trunk/test/Object/nm-tapi-invalids.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-tapi-invalids.test?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/nm-tapi-invalids.test (added)
+++ llvm/trunk/test/Object/nm-tapi-invalids.test Tue Sep 10 17:00:53 2019
@@ -0,0 +1,20 @@
+RUN: not llvm-nm %p/Inputs/tapi-invalid-v1.tbd 2>&1\
+RUN: | Filecheck %s -check-prefix v1
+
+RUN: not llvm-nm %p/Inputs/tapi-invalid-v2.tbd 2>&1\
+RUN: | Filecheck %s -check-prefix v2
+
+RUN: not llvm-nm %p/Inputs/tapi-invalid-v3.tbd 2>&1\
+RUN: | Filecheck %s -check-prefix v3
+
+# Typo Check
+v1: tapi-invalid-v1.tbd malformed file
+v1: tapi-invalid-v1.tbd:12:2: error: unknown key 'expors'
+
+# Missing required key
+v2: tapi-invalid-v2.tbd malformed file
+v2: tapi-invalid-v2.tbd:2:1: error: missing required key 'archs'
+
+# v2 key in v3 specified file
+v3: tapi-invalid-v3.tbd malformed file
+v3: tapi-invalid-v3.tbd:19:16: error: unknown key 'swift-version'
Added: llvm/trunk/test/Object/nm-tapi.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-tapi.test?rev=371576&view=auto
==============================================================================
--- llvm/trunk/test/Object/nm-tapi.test (added)
+++ llvm/trunk/test/Object/nm-tapi.test Tue Sep 10 17:00:53 2019
@@ -0,0 +1,56 @@
+RUN: llvm-nm %p/Inputs/tapi-v1.tbd 2>&1\
+RUN: | Filecheck %s -check-prefix v1
+
+RUN: llvm-nm %p/Inputs/tapi-v2.tbd \
+RUN: | Filecheck %s -check-prefix v2
+
+RUN: llvm-nm %p/Inputs/tapi-v3.tbd \
+RUN: | Filecheck %s -check-prefix v3
+
+v1: no symbols
+v1: tapi-v1.tbd (for architecture armv7):
+v1: 00000000 S _sym
+v1: tapi-v1.tbd (for architecture armv7s):
+
+v2: tapi-v2.tbd (for architecture armv7):
+v2: 00000000 S _sym1
+v2: 00000000 S _sym2
+v2: 00000000 S _sym3
+v2: tapi-v2.tbd (for architecture armv7s):
+v2: 00000000 S _sym1
+v2: 00000000 S _sym2
+v2: 00000000 S _sym3
+v2: tapi-v2.tbd (for architecture arm64):
+v2: U _sym
+v2: 0000000000000000 S _sym1
+v2: 0000000000000000 S _sym2
+v2: 0000000000000000 S _sym3
+
+v3: tapi-v3.tbd (for architecture i386):
+v3: 00000000 S _OBJC_CLASS_$_NSBlockPredicate
+v3: 00000000 S _OBJC_CLASS_$_NSString
+v3: 00000000 S _OBJC_EHTYPE_$_NSString
+v3: 00000000 S _OBJC_IVAR_$_NSBlockPredicate._block
+v3: 00000000 S _OBJC_METACLASS_$_NSBlockPredicate
+v3: 00000000 S _OBJC_METACLASS_$_NSString
+v3: 00000000 S _sym1
+v3: 00000000 S _sym2
+v3: 00000000 S _sym3
+v3: tapi-v3.tbd (for architecture armv7):
+v3: 00000000 S _OBJC_CLASS_$_NSBlockPredicate
+v3: 00000000 S _OBJC_CLASS_$_NSString
+v3: 00000000 S _OBJC_EHTYPE_$_NSString
+v3: 00000000 S _OBJC_IVAR_$_NSBlockPredicate._block
+v3: 00000000 S _OBJC_METACLASS_$_NSBlockPredicate
+v3: 00000000 S _OBJC_METACLASS_$_NSString
+v3: 00000000 S _sym1
+v3: 00000000 S _sym2
+v3: tapi-v3.tbd (for architecture armv7s):
+v3: 00000000 S _OBJC_CLASS_$_NSBlockPredicate
+v3: 00000000 S _OBJC_CLASS_$_NSString
+v3: 00000000 S _OBJC_EHTYPE_$_NSString
+v3: 00000000 S _OBJC_IVAR_$_NSBlockPredicate._block
+v3: 00000000 S _OBJC_METACLASS_$_NSBlockPredicate
+v3: 00000000 S _OBJC_METACLASS_$_NSString
+v3: 00000000 S _sym1
+v3: 00000000 S _sym2
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=371576&r1=371575&r2=371576&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Tue Sep 10 17:00:53 2019
@@ -28,6 +28,8 @@
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/TapiFile.h"
+#include "llvm/Object/TapiUniversal.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
@@ -336,6 +338,8 @@ static char isSymbolList64Bit(SymbolicFi
return false;
if (isa<WasmObjectFile>(Obj))
return false;
+ if (TapiFile *Tapi = dyn_cast<TapiFile>(&Obj))
+ return Tapi->is64Bit();
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))
return MachO->is64Bit();
return cast<ELFObjectFileBase>(Obj).getBytesInAddress() == 8;
@@ -1041,6 +1045,10 @@ static char getSymbolNMTypeChar(MachOObj
return '?';
}
+static char getSymbolNMTypeChar(TapiFile &Obj, basic_symbol_iterator I) {
+ return 's';
+}
+
static char getSymbolNMTypeChar(WasmObjectFile &Obj, basic_symbol_iterator I) {
uint32_t Flags = I->getFlags();
if (Flags & SymbolRef::SF_Executable)
@@ -1133,6 +1141,8 @@ static char getNMSectionTagAndName(Symbo
Ret = getSymbolNMTypeChar(*MachO, I);
else if (WasmObjectFile *Wasm = dyn_cast<WasmObjectFile>(&Obj))
Ret = getSymbolNMTypeChar(*Wasm, I);
+ else if (TapiFile *Tapi = dyn_cast<TapiFile>(&Obj))
+ Ret = getSymbolNMTypeChar(*Tapi, I);
else
Ret = getSymbolNMTypeChar(cast<ELFObjectFileBase>(Obj), I);
@@ -2063,6 +2073,26 @@ static void dumpSymbolNamesFromFile(std:
}
return;
}
+
+ if (TapiUniversal *TU = dyn_cast<TapiUniversal>(&Bin)) {
+ for (auto &I : TU->objects()) {
+ auto ObjOrErr = I.getAsObjectFile();
+ if (ObjOrErr) {
+ auto &Obj = *ObjOrErr.get();
+ outs() << "\n"
+ << Obj.getFileName() << " (for architecture "
+ << I.getArchFlagName() << ")"
+ << ":\n";
+ dumpSymbolNamesFromObject(Obj, false, {}, I.getArchFlagName());
+ } else if (auto E =
+ isNotObjectErrorInvalidFileType(ObjOrErr.takeError())) {
+ error(std::move(E), Filename, I.getArchFlagName());
+ }
+ }
+
+ return;
+ }
+
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&Bin)) {
if (!MachOPrintSizeWarning && PrintSize && isa<MachOObjectFile>(O)) {
WithColor::warning(errs(), ToolName)
More information about the llvm-commits
mailing list