1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[llvm][clang][IFS] Enhancing the llvm-ifs yaml format for symbol lists.

Prior to this change the clang interface stubs format resembled
something ending with a symbol list like this:

 Symbols:
   a: { Type: Func }

This was problematic because we didn't actually want a map format and
also because we didn't like that an empty symbol list required
"Symbols: {}". That is to say without the empty {} llvm-ifs would crash
on an empty list.

With this new format it is much more clear which field is the symbol
name, and instead the [] that is used to express an empty symbol vector
is optional, ie:

Symbols:
 - { Name: a, Type: Func }

or

Symbols: []

or

Symbols:

This further diverges the format from existing llvm-elftapi. This is a
good thing because although the format originally came from the same
place, they are not the same in any way.

Differential Revision: https://reviews.llvm.org/D76979
This commit is contained in:
Puyan Lotfi 2020-03-28 04:08:27 -04:00
parent 74804cc814
commit a3e3cecf73
23 changed files with 143 additions and 118 deletions

View File

@ -1,8 +1,8 @@
# NOTE: Used by weak-mismatch.ifs # NOTE: Used by weak-mismatch.ifs
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
foobar: { Type: Object, Size: 2 } - { Name: foobar, Type: Object, Size: 2 }
... ...

View File

@ -1,8 +1,8 @@
# NOTE: Used by weak-mismatch.ifs # NOTE: Used by weak-mismatch.ifs
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
foobar: { Type: Func } - { Name: foobar, Type: Func }
... ...

View File

@ -5,10 +5,10 @@
# CHECK-IFS-NEXT: Filenames: # CHECK-IFS-NEXT: Filenames:
# CHECK-IFS-NEXT: ObjectFileFormat Values: TBD ELF # CHECK-IFS-NEXT: ObjectFileFormat Values: TBD ELF
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-apple-unknown Triple: x86_64-apple-unknown
ObjectFileFormat: TBD ObjectFileFormat: TBD
Symbols: Symbols:
a: { Type: Func } - { Name: a, Type: Func }
... ...

View File

@ -5,10 +5,10 @@
# CHECK-IFS-NEXT: Filenames: # CHECK-IFS-NEXT: Filenames:
# CHECK-IFS-NEXT: Triple Values: mips-unknown-linux x86_64-unknown-linux-gnu # CHECK-IFS-NEXT: Triple Values: mips-unknown-linux x86_64-unknown-linux-gnu
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: mips-unknown-linux Triple: mips-unknown-linux
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
a: { Type: Func } - { Name: a, Type: Func }
... ...

View File

@ -5,12 +5,12 @@
# RUN: FileCheck %s --check-prefixes=CHECK-IFS2 # RUN: FileCheck %s --check-prefixes=CHECK-IFS2
# CHECK-IFS: error: Interface Stub: IfsVersion Mismatch. # CHECK-IFS: error: Interface Stub: IfsVersion Mismatch.
# CHECK-IFS2: error: Interface Stub: Bad IfsVersion: 0.0, llvm-ifs supported version: 1.2. # CHECK-IFS2: error: Interface Stub: Bad IfsVersion: 0.0, llvm-ifs supported version: 2.0.
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 0.0 IfsVersion: 0.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
a: { Type: Func } - { Name: a, Type: Func }
... ...

View File

@ -7,10 +7,10 @@
# CHECK-IFS-NEXT: Filename: # CHECK-IFS-NEXT: Filename:
# CHECK-IFS-NEXT: Size Values: 1 4 # CHECK-IFS-NEXT: Size Values: 1 4
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
b: { Type: Object, Size: 1 } - { Name: b, Type: Object, Size: 1 }
... ...

View File

@ -7,10 +7,10 @@
# CHECK-IFS-NEXT: Filename: # CHECK-IFS-NEXT: Filename:
# CHECK-IFS-NEXT: Type Values: Object Func # CHECK-IFS-NEXT: Type Values: Object Func
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
a: { Type: Object, Size: 1 } - { Name: a, Type: Object, Size: 1 }
... ...

View File

@ -2,12 +2,12 @@
# RUN: FileCheck %s --check-prefixes=CHECK-IFS # RUN: FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: Symbols: # CHECK-IFS: Symbols:
# CHECK-IFS-NEXT: a: { Type: Func, Weak: true } # CHECK-IFS-NEXT: - { Name: a, Type: Func, Weak: true }
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
a: { Type: Func, Weak: true } - { Name: a, Type: Func, Weak: true }
... ...

View File

@ -1,25 +1,25 @@
# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s # RUN: llvm-ifs -action write-ifs -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s
# RUN: llvm-ifs -action write-ifs -o - %s %S/weak.ifs | FileCheck --check-prefixes=CHECK-MERGE %s # RUN: llvm-ifs -action write-ifs -o - %s %S/weak.ifs | FileCheck --check-prefixes=CHECK-MERGE %s
# CHECK-DEFAULT: --- !experimental-ifs-v1 # CHECK-DEFAULT: --- !experimental-ifs-v2
# CHECK-DEFAULT-NEXT: IfsVersion: 1.2 # CHECK-DEFAULT-NEXT: IfsVersion: 2.0
# CHECK-DEFAULT-NEXT: Triple: '' # CHECK-DEFAULT-NEXT: Triple: ''
# CHECK-DEFAULT-NEXT: ObjectFileFormat: ELF # CHECK-DEFAULT-NEXT: ObjectFileFormat: ELF
# CHECK-DEFAULT-NEXT: Symbols: {} # CHECK-DEFAULT-NEXT: Symbols: []
# CHECK-DEFAULT-NEXT: ... # CHECK-DEFAULT-NEXT: ...
# CHECK-MERGE: --- !experimental-ifs-v1 # CHECK-MERGE: --- !experimental-ifs-v2
# CHECK-MERGE-NEXT: IfsVersion: 1.0 # CHECK-MERGE-NEXT: IfsVersion: 2.0
# CHECK-MERGE-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-MERGE-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-MERGE-NEXT: ObjectFileFormat: ELF # CHECK-MERGE-NEXT: ObjectFileFormat: ELF
# CHECK-MERGE-NEXT: Symbols: # CHECK-MERGE-NEXT: Symbols:
# CHECK-MERGE-DAG: _Z8weakFuncv: { Type: Func, Weak: true } # CHECK-MERGE-DAG: - { Name: _Z8weakFuncv, Type: Func, Weak: true }
# CHECK-MERGE-DAG: _Z10strongFuncv: { Type: Func } # CHECK-MERGE-DAG: - { Name: _Z10strongFuncv, Type: Func }
# CHECK-MERGE: ... # CHECK-MERGE: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.2 IfsVersion: 2.0
Triple: '' Triple: ''
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: {} Symbols: []
... ...

View File

@ -0,0 +1,15 @@
# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s
# CHECK: --- !experimental-ifs-v2
# CHECK-NEXT: IfsVersion: 2.0
# CHECK-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-NEXT: ObjectFileFormat: ELF
# CHECK-NEXT: Symbols: []
# CHECK: ...
--- !experimental-ifs-v2
IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF
Symbols: []
...

View File

@ -0,0 +1,15 @@
# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s
# CHECK: --- !experimental-ifs-v2
# CHECK-NEXT: IfsVersion: 2.0
# CHECK-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-NEXT: ObjectFileFormat: ELF
# CHECK-NEXT: Symbols: []
# CHECK: ...
--- !experimental-ifs-v2
IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF
Symbols:
...

View File

@ -10,13 +10,13 @@
# RUN: llvm-ifs -action write-ifs -o - %s %s | \ # RUN: llvm-ifs -action write-ifs -o - %s %s | \
# RUN: FileCheck %s --check-prefixes=CHECK-MERGE-IFS # RUN: FileCheck %s --check-prefixes=CHECK-MERGE-IFS
# CHECK-IFS: --- !experimental-ifs-v1 # CHECK-IFS: --- !experimental-ifs-v2
# CHECK-IFS-NEXT: IfsVersion: 1.0 # CHECK-IFS-NEXT: IfsVersion: 2.0
# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-IFS-NEXT: ObjectFileFormat: ELF # CHECK-IFS-NEXT: ObjectFileFormat: ELF
# CHECK-IFS-NEXT: Symbols: # CHECK-IFS-NEXT: Symbols:
# CHECK-IFS-DAG: a: { Type: Func } # CHECK-IFS-DAG: - { Name: a, Type: Func }
# CHECK-IFS-DAG: b: { Type: Object, Size: 4 } # CHECK-IFS-DAG: - { Name: b, Type: Object, Size: 4 }
# CHECK-IFS: ... # CHECK-IFS: ...
# CHECK-ELF: ELF Header: # CHECK-ELF: ELF Header:
@ -39,18 +39,18 @@
# CHECK-DARWIN-TBD3-NEXT: ... # CHECK-DARWIN-TBD3-NEXT: ...
# Here we are testing to see if two identical symbols will merge. # Here we are testing to see if two identical symbols will merge.
# CHECK-MERGE-IFS: --- !experimental-ifs-v1 # CHECK-MERGE-IFS: --- !experimental-ifs-v2
# CHECK-MERGE-IFS-NEXT: IfsVersion: 1.0 # CHECK-MERGE-IFS-NEXT: IfsVersion: 2.0
# CHECK-MERGE-IFS-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-MERGE-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-MERGE-IFS-NEXT: ObjectFileFormat: ELF # CHECK-MERGE-IFS-NEXT: ObjectFileFormat: ELF
# CHECK-MERGE-IFS-NEXT: Symbols: # CHECK-MERGE-IFS-NEXT: Symbols:
# CHECK-MERGE-IFS-NEXT: a: { Type: Func } # CHECK-MERGE-IFS-NEXT: - { Name: a, Type: Func }
# CHECK-MERGE-IFS-NEXT: ... # CHECK-MERGE-IFS-NEXT: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
a: { Type: Func } - { Name: a, Type: Func }
... ...

View File

@ -13,10 +13,10 @@
# CHECK-NEXT: symbols: [ __Z3fooi ] # CHECK-NEXT: symbols: [ __Z3fooi ]
# CHECK-NEXT: ... # CHECK-NEXT: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: arm64-apple-ios Triple: arm64-apple-ios
ObjectFileFormat: TBD ObjectFileFormat: TBD
Symbols: Symbols:
__Z3fooi: { Type: Func } - { Name: __Z3fooi, Type: Func }
... ...

View File

@ -13,10 +13,10 @@
# CHECK-NEXT: symbols: [ __Z3fooi ] # CHECK-NEXT: symbols: [ __Z3fooi ]
# CHECK-NEXT: ... # CHECK-NEXT: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: arm64-apple-macosx Triple: arm64-apple-macosx
ObjectFileFormat: TBD ObjectFileFormat: TBD
Symbols: Symbols:
__Z3fooi: { Type: Func } - { Name: __Z3fooi, Type: Func }
... ...

View File

@ -4,17 +4,17 @@
# RUN: llvm-ifs -action write-bin -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \ # RUN: llvm-ifs -action write-bin -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \
# RUN: llvm-readelf --all | FileCheck %s --check-prefixes=CHECK-ELF # RUN: llvm-readelf --all | FileCheck %s --check-prefixes=CHECK-ELF
# CHECK-IFS: --- !experimental-ifs-v1 # CHECK-IFS: --- !experimental-ifs-v2
# CHECK-IFS-NEXT: IfsVersion: 1.0 # CHECK-IFS-NEXT: IfsVersion: 2.0
# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-IFS-NEXT: ObjectFileFormat: ELF # CHECK-IFS-NEXT: ObjectFileFormat: ELF
# CHECK-IFS-NEXT: Symbols: # CHECK-IFS-NEXT: Symbols:
# CHECK-IFS-DAG: e: { Type: Object, Size: 8 } # CHECK-IFS-DAG: - { Name: e, Type: Object, Size: 8 }
# CHECK-IFS-DAG: a: { Type: Func } # CHECK-IFS-DAG: - { Name: a, Type: Func }
# CHECK-IFS-DAG: f: { Type: Object, Size: 2 } # CHECK-IFS-DAG: - { Name: f, Type: Object, Size: 2 }
# CHECK-IFS-DAG: _Z10strongFuncv: { Type: Func } # CHECK-IFS-DAG: - { Name: _Z10strongFuncv, Type: Func }
# CHECK-IFS-DAG: _Z8weakFuncv: { Type: Func, Weak: true } # CHECK-IFS-DAG: - { Name: _Z8weakFuncv, Type: Func, Weak: true }
# CHECK-IFS-DAG: b: { Type: Object, Size: 4 } # CHECK-IFS-DAG: - { Name: b, Type: Object, Size: 4 }
# CHECK-IFS: ... # CHECK-IFS: ...
# CHECK-ELF: FUNC GLOBAL DEFAULT 1 _Z10strongFuncv # CHECK-ELF: FUNC GLOBAL DEFAULT 1 _Z10strongFuncv
@ -24,11 +24,11 @@
# CHECK-ELF: OBJECT GLOBAL DEFAULT 1 e # CHECK-ELF: OBJECT GLOBAL DEFAULT 1 e
# CHECK-ELF: OBJECT GLOBAL DEFAULT 1 f # CHECK-ELF: OBJECT GLOBAL DEFAULT 1 f
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
e: { Type: Object, Size: 8 } - { Name: e, Type: Object, Size: 8 }
f: { Type: Object, Size: 2 } - { Name: f, Type: Object, Size: 2 }
... ...

View File

@ -4,12 +4,12 @@
# RUN: llvm-ifs -action write-bin -o - %s | \ # RUN: llvm-ifs -action write-bin -o - %s | \
# RUN: llvm-readelf --all | FileCheck %s --check-prefixes=CHECK-ELF # RUN: llvm-readelf --all | FileCheck %s --check-prefixes=CHECK-ELF
# CHECK-IFS: --- !experimental-ifs-v1 # CHECK-IFS: --- !experimental-ifs-v2
# CHECK-IFS-NEXT: IfsVersion: 1.0 # CHECK-IFS-NEXT: IfsVersion: 2.0
# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-IFS-NEXT: ObjectFileFormat: ELF # CHECK-IFS-NEXT: ObjectFileFormat: ELF
# CHECK-IFS-NEXT: Symbols: # CHECK-IFS-NEXT: Symbols:
# CHECK-IFS-NEXT: b: { Type: Object, Size: 4 } # CHECK-IFS-NEXT: - { Name: b, Type: Object, Size: 4 }
# CHECK-IFS-NEXT: ... # CHECK-IFS-NEXT: ...
# CHECK-ELF: ELF Header: # CHECK-ELF: ELF Header:
@ -19,10 +19,10 @@
# CHECK-ELF-NOT: FUNC GLOBAL DEFAULT 1 a # CHECK-ELF-NOT: FUNC GLOBAL DEFAULT 1 a
# CHECK-ELF: OBJECT GLOBAL DEFAULT 1 b # CHECK-ELF: OBJECT GLOBAL DEFAULT 1 b
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
b: { Type: Object, Size: 4 } - { Name: b, Type: Object, Size: 4 }
... ...

View File

@ -1,17 +1,17 @@
# RUN: llvm-ifs -action write-ifs -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS # RUN: llvm-ifs -action write-ifs -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: --- !experimental-ifs-v1 # CHECK-IFS: --- !experimental-ifs-v2
# CHECK-IFS-NEXT: IfsVersion: 1.0 # CHECK-IFS-NEXT: IfsVersion: 2.0
# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-IFS-NEXT: ObjectFileFormat: ELF # CHECK-IFS-NEXT: ObjectFileFormat: ELF
# CHECK-IFS-NEXT: Symbols: # CHECK-IFS-NEXT: Symbols:
# CHECK-IFS-DAG: _Z8weakFuncv: { Type: Func } # CHECK-IFS-DAG: - { Name: _Z8weakFuncv, Type: Func }
# CHECK-IFS: ... # CHECK-IFS: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
_Z8weakFuncv: { Type: Func } - { Name: _Z8weakFuncv, Type: Func }
... ...

View File

@ -13,10 +13,10 @@
# CHECK-NEXT: symbols: [ __Z3fooi ] # CHECK-NEXT: symbols: [ __Z3fooi ]
# CHECK-NEXT: ... # CHECK-NEXT: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: arm64-apple-tvos Triple: arm64-apple-tvos
ObjectFileFormat: TBD ObjectFileFormat: TBD
Symbols: Symbols:
__Z3fooi: { Type: Func } - { Name: __Z3fooi, Type: Func }
... ...

View File

@ -1,9 +1,9 @@
# RUN: llvm-ifs -action write-ifs -o - %s %S/object.ifs # RUN: llvm-ifs -action write-ifs -o - %s %S/object.ifs
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.1 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
a: { Type: Func } - { Name: a, Type: Func }
... ...

View File

@ -13,10 +13,10 @@
# CHECK-NEXT: symbols: [ __Z3fooi ] # CHECK-NEXT: symbols: [ __Z3fooi ]
# CHECK-NEXT: ... # CHECK-NEXT: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: arm64-apple-watchos Triple: arm64-apple-watchos
ObjectFileFormat: TBD ObjectFileFormat: TBD
Symbols: Symbols:
__Z3fooi: { Type: Func } - { Name: __Z3fooi, Type: Func }
... ...

View File

@ -10,10 +10,10 @@
# CHECK-TYPE-NEXT: Filename: # CHECK-TYPE-NEXT: Filename:
# CHECK-TYPE-NEXT: Type Values: Object Func # CHECK-TYPE-NEXT: Type Values: Object Func
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
foobar: { Type: Object, Size: 1, Weak: true } - { Name: foobar, Type: Object, Size: 1, Weak: true }
... ...

View File

@ -1,19 +1,19 @@
# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s --check-prefixes=CHECK-IFS # RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: --- !experimental-ifs-v1 # CHECK-IFS: --- !experimental-ifs-v2
# CHECK-IFS-NEXT: IfsVersion: 1.0 # CHECK-IFS-NEXT: IfsVersion: 2.0
# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu # CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
# CHECK-IFS-NEXT: ObjectFileFormat: ELF # CHECK-IFS-NEXT: ObjectFileFormat: ELF
# CHECK-IFS-NEXT: Symbols: # CHECK-IFS-NEXT: Symbols:
# CHECK-IFS-DAG: _Z8weakFuncv: { Type: Func, Weak: true } # CHECK-IFS-DAG: - { Name: _Z8weakFuncv, Type: Func, Weak: true }
# CHECK-IFS-DAG: _Z10strongFuncv: { Type: Func } # CHECK-IFS-DAG: - { Name: _Z10strongFuncv, Type: Func }
# CHECK-IFS: ... # CHECK-IFS: ...
--- !experimental-ifs-v1 --- !experimental-ifs-v2
IfsVersion: 1.0 IfsVersion: 2.0
Triple: x86_64-unknown-linux-gnu Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF ObjectFileFormat: ELF
Symbols: Symbols:
_Z8weakFuncv: { Type: Func, Weak: true } - { Name: _Z8weakFuncv, Type: Func, Weak: true }
_Z10strongFuncv: { Type: Func } - { Name: _Z10strongFuncv, Type: Func }
... ...

View File

@ -26,6 +26,7 @@
#include "llvm/TextAPI/MachO/TextAPIWriter.h" #include "llvm/TextAPI/MachO/TextAPIWriter.h"
#include <set> #include <set>
#include <string> #include <string>
#include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::yaml; using namespace llvm::yaml;
@ -34,8 +35,8 @@ using namespace llvm::MachO;
#define DEBUG_TYPE "llvm-ifs" #define DEBUG_TYPE "llvm-ifs"
namespace { namespace {
const VersionTuple IFSVersionCurrent(1, 2); const VersionTuple IFSVersionCurrent(2, 0);
} } // end anonymous namespace
static cl::opt<std::string> Action("action", cl::desc("<llvm-ifs action>"), static cl::opt<std::string> Action("action", cl::desc("<llvm-ifs action>"),
cl::value_desc("write-ifs | write-bin"), cl::value_desc("write-ifs | write-bin"),
@ -76,6 +77,7 @@ std::string getTypeName(IFSSymbolType Type) {
} }
struct IFSSymbol { struct IFSSymbol {
IFSSymbol() = default;
IFSSymbol(std::string SymbolName) : Name(SymbolName) {} IFSSymbol(std::string SymbolName) : Name(SymbolName) {}
std::string Name; std::string Name;
uint64_t Size; uint64_t Size;
@ -85,6 +87,8 @@ struct IFSSymbol {
bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; } bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; }
}; };
LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol)
namespace llvm { namespace llvm {
namespace yaml { namespace yaml {
/// YAML traits for IFSSymbolType. /// YAML traits for IFSSymbolType.
@ -124,6 +128,7 @@ template <> struct ScalarTraits<VersionTuple> {
/// YAML traits for IFSSymbol. /// YAML traits for IFSSymbol.
template <> struct MappingTraits<IFSSymbol> { template <> struct MappingTraits<IFSSymbol> {
static void mapping(IO &IO, IFSSymbol &Symbol) { static void mapping(IO &IO, IFSSymbol &Symbol) {
IO.mapRequired("Name", Symbol.Name);
IO.mapRequired("Type", Symbol.Type); IO.mapRequired("Type", Symbol.Type);
// The need for symbol size depends on the symbol type. // The need for symbol size depends on the symbol type.
if (Symbol.Type == IFSSymbolType::NoType) if (Symbol.Type == IFSSymbolType::NoType)
@ -140,20 +145,6 @@ template <> struct MappingTraits<IFSSymbol> {
static const bool flow = true; static const bool flow = true;
}; };
/// YAML traits for set of IFSSymbols.
template <> struct CustomMappingTraits<std::set<IFSSymbol>> {
static void inputOne(IO &IO, StringRef Key, std::set<IFSSymbol> &Set) {
std::string Name = Key.str();
IFSSymbol Sym(Name);
IO.mapRequired(Name.c_str(), Sym);
Set.insert(Sym);
}
static void output(IO &IO, std::set<IFSSymbol> &Set) {
for (auto &Sym : Set)
IO.mapRequired(Sym.Name.c_str(), const_cast<IFSSymbol &>(Sym));
}
};
} // namespace yaml } // namespace yaml
} // namespace llvm } // namespace llvm
@ -167,7 +158,7 @@ public:
std::string ObjectFileFormat; std::string ObjectFileFormat;
Optional<std::string> SOName; Optional<std::string> SOName;
std::vector<std::string> NeededLibs; std::vector<std::string> NeededLibs;
std::set<IFSSymbol> Symbols; std::vector<IFSSymbol> Symbols;
IFSStub() = default; IFSStub() = default;
IFSStub(const IFSStub &Stub) IFSStub(const IFSStub &Stub)
@ -186,14 +177,18 @@ namespace yaml {
/// YAML traits for IFSStub objects. /// YAML traits for IFSStub objects.
template <> struct MappingTraits<IFSStub> { template <> struct MappingTraits<IFSStub> {
static void mapping(IO &IO, IFSStub &Stub) { static void mapping(IO &IO, IFSStub &Stub) {
if (!IO.mapTag("!experimental-ifs-v1", true)) if (!IO.mapTag("!experimental-ifs-v2", true))
IO.setError("Not a .ifs YAML file."); IO.setError("Not a .ifs YAML file.");
auto OldContext = IO.getContext();
IO.setContext(&Stub);
IO.mapRequired("IfsVersion", Stub.IfsVersion); IO.mapRequired("IfsVersion", Stub.IfsVersion);
IO.mapOptional("Triple", Stub.Triple); IO.mapOptional("Triple", Stub.Triple);
IO.mapOptional("ObjectFileFormat", Stub.ObjectFileFormat); IO.mapOptional("ObjectFileFormat", Stub.ObjectFileFormat);
IO.mapOptional("SOName", Stub.SOName); IO.mapOptional("SOName", Stub.SOName);
IO.mapOptional("NeededLibs", Stub.NeededLibs); IO.mapOptional("NeededLibs", Stub.NeededLibs);
IO.mapRequired("Symbols", Stub.Symbols); IO.mapRequired("Symbols", Stub.Symbols);
IO.setContext(&OldContext);
} }
}; };
} // namespace yaml } // namespace yaml
@ -218,7 +213,7 @@ static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
return std::move(Stub); return std::move(Stub);
} }
int writeTbdStub(const llvm::Triple &T, const std::set<IFSSymbol> &Symbols, int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
const StringRef Format, raw_ostream &Out) { const StringRef Format, raw_ostream &Out) {
auto PlatformKindOrError = auto PlatformKindOrError =
@ -280,7 +275,7 @@ int writeTbdStub(const llvm::Triple &T, const std::set<IFSSymbol> &Symbols,
return 0; return 0;
} }
int writeElfStub(const llvm::Triple &T, const std::set<IFSSymbol> &Symbols, int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
const StringRef Format, raw_ostream &Out) { const StringRef Format, raw_ostream &Out) {
SmallString<0> Storage; SmallString<0> Storage;
Storage.clear(); Storage.clear();
@ -387,8 +382,8 @@ int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
// TODO: Drop ObjectFileFormat, it can be subsumed from the triple. // TODO: Drop ObjectFileFormat, it can be subsumed from the triple.
// New Interface Stubs Yaml Format: // New Interface Stubs Yaml Format:
// --- !experimental-ifs-v1 // --- !experimental-ifs-v2
// IfsVersion: 1.0 // IfsVersion: 2.0
// Triple: <llvm triple> // Triple: <llvm triple>
// ObjectFileFormat: <ELF | others not yet supported> // ObjectFileFormat: <ELF | others not yet supported>
// Symbols: // Symbols:
@ -517,7 +512,7 @@ int main(int argc, char *argv[]) {
} }
for (auto &Entry : SymbolMap) for (auto &Entry : SymbolMap)
Stub.Symbols.insert(Entry.second); Stub.Symbols.push_back(Entry.second);
std::error_code SysErr; std::error_code SysErr;