1 //===- llvm-ifs.cpp -------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===-----------------------------------------------------------------------===/
9 #include "ErrorCollector.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/ADT/StringSwitch.h"
12 #include "llvm/ADT/Triple.h"
13 #include "llvm/BinaryFormat/ELF.h"
14 #include "llvm/InterfaceStub/ELFObjHandler.h"
15 #include "llvm/InterfaceStub/IFSHandler.h"
16 #include "llvm/InterfaceStub/IFSStub.h"
17 #include "llvm/ObjectYAML/yaml2obj.h"
18 #include "llvm/Option/Arg.h"
19 #include "llvm/Option/ArgList.h"
20 #include "llvm/Option/Option.h"
21 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Support/Debug.h"
23 #include "llvm/Support/Errc.h"
24 #include "llvm/Support/Error.h"
25 #include "llvm/Support/FileOutputBuffer.h"
26 #include "llvm/Support/MemoryBuffer.h"
27 #include "llvm/Support/Path.h"
28 #include "llvm/Support/VersionTuple.h"
29 #include "llvm/Support/WithColor.h"
30 #include "llvm/Support/YAMLTraits.h"
31 #include "llvm/Support/raw_ostream.h"
32 #include "llvm/TextAPI/InterfaceFile.h"
33 #include "llvm/TextAPI/TextAPIReader.h"
34 #include "llvm/TextAPI/TextAPIWriter.h"
40 using namespace llvm::yaml
;
41 using namespace llvm::MachO
;
42 using namespace llvm::ifs
;
44 #define DEBUG_TYPE "llvm-ifs"
47 const VersionTuple
IfsVersionCurrent(3, 0);
49 enum class FileFormat
{ IFS
, ELF
, TBD
};
50 } // end anonymous namespace
52 using namespace llvm::opt
;
54 OPT_INVALID
= 0, // This is not an option ID.
55 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
56 HELPTEXT, METAVAR, VALUES) \
62 #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
66 const opt::OptTable::Info InfoTable
[] = {
67 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
68 HELPTEXT, METAVAR, VALUES) \
70 PREFIX, NAME, HELPTEXT, \
71 METAVAR, OPT_##ID, opt::Option::KIND##Class, \
72 PARAM, FLAGS, OPT_##GROUP, \
73 OPT_##ALIAS, ALIASARGS, VALUES},
78 class IFSOptTable
: public opt::OptTable
{
80 IFSOptTable() : OptTable(InfoTable
) { setGroupedShortOptions(true); }
84 std::vector
<std::string
> InputFilePaths
;
86 Optional
<FileFormat
> InputFormat
;
87 Optional
<FileFormat
> OutputFormat
;
89 Optional
<std::string
> HintIfsTarget
;
90 Optional
<std::string
> OptTargetTriple
;
91 Optional
<IFSArch
> OverrideArch
;
92 Optional
<IFSBitWidthType
> OverrideBitWidth
;
93 Optional
<IFSEndiannessType
> OverrideEndianness
;
95 bool StripIfsArch
= false;
96 bool StripIfsBitwidth
= false;
97 bool StripIfsEndianness
= false;
98 bool StripIfsTarget
= false;
99 bool StripNeeded
= false;
100 bool StripSize
= false;
101 bool StripUndefined
= false;
103 std::vector
<std::string
> Exclude
;
105 Optional
<std::string
> SoName
;
107 Optional
<std::string
> Output
;
108 Optional
<std::string
> OutputElf
;
109 Optional
<std::string
> OutputIfs
;
110 Optional
<std::string
> OutputTbd
;
112 bool WriteIfChanged
= false;
115 static std::string
getTypeName(IFSSymbolType Type
) {
117 case IFSSymbolType::NoType
:
119 case IFSSymbolType::Func
:
121 case IFSSymbolType::Object
:
123 case IFSSymbolType::TLS
:
125 case IFSSymbolType::Unknown
:
128 llvm_unreachable("Unexpected ifs symbol type.");
131 static Expected
<std::unique_ptr
<IFSStub
>>
132 readInputFile(Optional
<FileFormat
> &InputFormat
, StringRef FilePath
) {
134 ErrorOr
<std::unique_ptr
<MemoryBuffer
>> BufOrError
=
135 MemoryBuffer::getFileOrSTDIN(FilePath
, /*IsText=*/true);
137 return createStringError(BufOrError
.getError(), "Could not open `%s`",
140 std::unique_ptr
<MemoryBuffer
> FileReadBuffer
= std::move(*BufOrError
);
141 ErrorCollector
EC(/*UseFatalErrors=*/false);
143 // First try to read as a binary (fails fast if not binary).
144 if (!InputFormat
|| *InputFormat
== FileFormat::ELF
) {
145 Expected
<std::unique_ptr
<IFSStub
>> StubFromELF
=
146 readELFFile(FileReadBuffer
->getMemBufferRef());
148 InputFormat
= FileFormat::ELF
;
149 (*StubFromELF
)->IfsVersion
= IfsVersionCurrent
;
150 return std::move(*StubFromELF
);
152 EC
.addError(StubFromELF
.takeError(), "BinaryRead");
155 // Fall back to reading as a ifs.
156 if (!InputFormat
|| *InputFormat
== FileFormat::IFS
) {
157 Expected
<std::unique_ptr
<IFSStub
>> StubFromIFS
=
158 readIFSFromBuffer(FileReadBuffer
->getBuffer());
160 InputFormat
= FileFormat::IFS
;
161 if ((*StubFromIFS
)->IfsVersion
> IfsVersionCurrent
)
163 createStringError(errc::not_supported
,
165 (*StubFromIFS
)->IfsVersion
.getAsString() +
169 return std::move(*StubFromIFS
);
171 EC
.addError(StubFromIFS
.takeError(), "YamlParse");
175 // If both readers fail, build a new error that includes all information.
176 EC
.addError(createStringError(errc::not_supported
,
177 "No file readers succeeded reading `%s` "
178 "(unsupported/malformed file?)",
181 EC
.escalateToFatal();
182 return EC
.makeError();
185 static int writeTbdStub(const Triple
&T
, const std::vector
<IFSSymbol
> &Symbols
,
186 const StringRef Format
, raw_ostream
&Out
) {
188 auto PlatformTypeOrError
=
189 [](const llvm::Triple
&T
) -> llvm::Expected
<llvm::MachO::PlatformType
> {
191 return llvm::MachO::PLATFORM_MACOS
;
193 return llvm::MachO::PLATFORM_TVOS
;
195 return llvm::MachO::PLATFORM_WATCHOS
;
196 // Note: put isiOS last because tvOS and watchOS are also iOS according
199 return llvm::MachO::PLATFORM_IOS
;
201 return createStringError(errc::not_supported
, "Invalid Platform.\n");
204 if (!PlatformTypeOrError
)
207 PlatformType Plat
= PlatformTypeOrError
.get();
208 TargetList
Targets({Target(llvm::MachO::mapToArchitecture(T
), Plat
)});
211 File
.setFileType(FileType::TBD_V3
); // Only supporting v3 for now.
212 File
.addTargets(Targets
);
214 for (const auto &Symbol
: Symbols
) {
215 auto Name
= Symbol
.Name
;
216 auto Kind
= SymbolKind::GlobalSymbol
;
217 switch (Symbol
.Type
) {
219 case IFSSymbolType::NoType
:
220 Kind
= SymbolKind::GlobalSymbol
;
222 case IFSSymbolType::Object
:
223 Kind
= SymbolKind::GlobalSymbol
;
225 case IFSSymbolType::Func
:
226 Kind
= SymbolKind::GlobalSymbol
;
230 File
.addSymbol(Kind
, Name
, Targets
, SymbolFlags::WeakDefined
);
232 File
.addSymbol(Kind
, Name
, Targets
);
235 SmallString
<4096> Buffer
;
236 raw_svector_ostream
OS(Buffer
);
237 if (Error Result
= TextAPIWriter::writeToStream(OS
, File
))
243 static void fatalError(Error Err
) {
244 WithColor::defaultErrorHandler(std::move(Err
));
248 static void fatalError(Twine T
) {
249 WithColor::error() << T
.str() << '\n';
253 /// writeIFS() writes a Text-Based ELF stub to a file using the latest version
254 /// of the YAML parser.
255 static Error
writeIFS(StringRef FilePath
, IFSStub
&Stub
, bool WriteIfChanged
) {
256 // Write IFS to memory first.
258 raw_string_ostream
OutStr(IFSStr
);
259 Error YAMLErr
= writeIFSToOutputStream(OutStr
, Stub
);
264 if (WriteIfChanged
) {
265 if (ErrorOr
<std::unique_ptr
<MemoryBuffer
>> BufOrError
=
266 MemoryBuffer::getFile(FilePath
)) {
267 // Compare IFS output with the existing IFS file. If unchanged, avoid
268 // changing the file.
269 if ((*BufOrError
)->getBuffer() == IFSStr
)
270 return Error::success();
273 // Open IFS file for writing.
274 std::error_code SysErr
;
275 raw_fd_ostream
Out(FilePath
, SysErr
);
277 return createStringError(SysErr
, "Couldn't open `%s` for writing",
280 return Error::success();
283 static DriverConfig
parseArgs(int argc
, char *const *argv
) {
285 StringSaver
Saver(A
);
287 StringRef ToolName
= argv
[0];
288 llvm::opt::InputArgList Args
= Tbl
.parseArgs(
289 argc
, argv
, OPT_UNKNOWN
, Saver
, [&](StringRef Msg
) { fatalError(Msg
); });
290 if (Args
.hasArg(OPT_help
)) {
291 Tbl
.printHelp(llvm::outs(),
292 (Twine(ToolName
) + " <input_file> <output_file> [options]")
295 "shared object stubbing tool");
298 if (Args
.hasArg(OPT_version
)) {
299 llvm::outs() << ToolName
<< '\n';
300 cl::PrintVersionMessage();
305 for (const opt::Arg
*A
: Args
.filtered(OPT_INPUT
))
306 Config
.InputFilePaths
.push_back(A
->getValue());
307 if (const opt::Arg
*A
= Args
.getLastArg(OPT_input_format_EQ
)) {
308 Config
.InputFormat
= StringSwitch
<Optional
<FileFormat
>>(A
->getValue())
309 .Case("IFS", FileFormat::IFS
)
310 .Case("ELF", FileFormat::ELF
)
312 if (!Config
.InputFormat
)
313 fatalError(Twine("invalid argument '") + A
->getValue());
316 auto OptionNotFound
= [ToolName
](StringRef FlagName
, StringRef OptionName
) {
317 fatalError(Twine(ToolName
) + ": for the " + FlagName
+
318 " option: Cannot find option named '" + OptionName
+ "'!");
320 if (const opt::Arg
*A
= Args
.getLastArg(OPT_output_format_EQ
)) {
321 Config
.OutputFormat
= StringSwitch
<Optional
<FileFormat
>>(A
->getValue())
322 .Case("IFS", FileFormat::IFS
)
323 .Case("ELF", FileFormat::ELF
)
324 .Case("TBD", FileFormat::TBD
)
326 if (!Config
.OutputFormat
)
327 OptionNotFound("--output-format", A
->getValue());
329 if (const opt::Arg
*A
= Args
.getLastArg(OPT_arch_EQ
))
330 Config
.OverrideArch
= ELF::convertArchNameToEMachine(A
->getValue());
332 if (const opt::Arg
*A
= Args
.getLastArg(OPT_bitwidth_EQ
)) {
334 llvm::StringRef
S(A
->getValue());
335 if (!S
.getAsInteger
<size_t>(10, Width
) || Width
== 64 || Width
== 32)
336 Config
.OverrideBitWidth
=
337 Width
== 64 ? IFSBitWidthType::IFS64
: IFSBitWidthType::IFS32
;
339 OptionNotFound("--bitwidth", A
->getValue());
341 if (const opt::Arg
*A
= Args
.getLastArg(OPT_endianness_EQ
)) {
342 Config
.OverrideEndianness
=
343 StringSwitch
<Optional
<IFSEndiannessType
>>(A
->getValue())
344 .Case("little", IFSEndiannessType::Little
)
345 .Case("big", IFSEndiannessType::Big
)
347 if (!Config
.OverrideEndianness
)
348 OptionNotFound("--endianness", A
->getValue());
350 if (const opt::Arg
*A
= Args
.getLastArg(OPT_target_EQ
))
351 Config
.OptTargetTriple
= A
->getValue();
352 if (const opt::Arg
*A
= Args
.getLastArg(OPT_hint_ifs_target_EQ
))
353 Config
.HintIfsTarget
= A
->getValue();
355 Config
.StripIfsArch
= Args
.hasArg(OPT_strip_ifs_arch
);
356 Config
.StripIfsBitwidth
= Args
.hasArg(OPT_strip_ifs_bitwidth
);
357 Config
.StripIfsEndianness
= Args
.hasArg(OPT_strip_ifs_endianness
);
358 Config
.StripIfsTarget
= Args
.hasArg(OPT_strip_ifs_target
);
359 Config
.StripUndefined
= Args
.hasArg(OPT_strip_undefined
);
360 Config
.StripNeeded
= Args
.hasArg(OPT_strip_needed
);
361 Config
.StripSize
= Args
.hasArg(OPT_strip_size
);
363 for (const opt::Arg
*A
: Args
.filtered(OPT_exclude_EQ
))
364 Config
.Exclude
.push_back(A
->getValue());
365 if (const opt::Arg
*A
= Args
.getLastArg(OPT_soname_EQ
))
366 Config
.SoName
= A
->getValue();
367 if (const opt::Arg
*A
= Args
.getLastArg(OPT_output_EQ
))
368 Config
.Output
= A
->getValue();
369 if (const opt::Arg
*A
= Args
.getLastArg(OPT_output_elf_EQ
))
370 Config
.OutputElf
= A
->getValue();
371 if (const opt::Arg
*A
= Args
.getLastArg(OPT_output_ifs_EQ
))
372 Config
.OutputIfs
= A
->getValue();
373 if (const opt::Arg
*A
= Args
.getLastArg(OPT_output_tbd_EQ
))
374 Config
.OutputTbd
= A
->getValue();
375 Config
.WriteIfChanged
= Args
.hasArg(OPT_write_if_changed
);
379 int main(int argc
, char *argv
[]) {
380 DriverConfig Config
= parseArgs(argc
, argv
);
382 if (Config
.InputFilePaths
.empty())
383 Config
.InputFilePaths
.push_back("-");
385 // If input files are more than one, they can only be IFS files.
386 if (Config
.InputFilePaths
.size() > 1)
387 Config
.InputFormat
= FileFormat::IFS
;
389 // Attempt to merge input.
391 std::map
<std::string
, IFSSymbol
> SymbolMap
;
392 std::string PreviousInputFilePath
;
393 for (const std::string
&InputFilePath
: Config
.InputFilePaths
) {
394 Expected
<std::unique_ptr
<IFSStub
>> StubOrErr
=
395 readInputFile(Config
.InputFormat
, InputFilePath
);
397 fatalError(StubOrErr
.takeError());
399 std::unique_ptr
<IFSStub
> TargetStub
= std::move(StubOrErr
.get());
400 if (PreviousInputFilePath
.empty()) {
401 Stub
.IfsVersion
= TargetStub
->IfsVersion
;
402 Stub
.Target
= TargetStub
->Target
;
403 Stub
.SoName
= TargetStub
->SoName
;
404 Stub
.NeededLibs
= TargetStub
->NeededLibs
;
406 if (Stub
.IfsVersion
!= TargetStub
->IfsVersion
) {
407 if (Stub
.IfsVersion
.getMajor() != IfsVersionCurrent
.getMajor()) {
409 << "Interface Stub: IfsVersion Mismatch."
410 << "\nFilenames: " << PreviousInputFilePath
<< " "
411 << InputFilePath
<< "\nIfsVersion Values: " << Stub
.IfsVersion
412 << " " << TargetStub
->IfsVersion
<< "\n";
415 if (TargetStub
->IfsVersion
> Stub
.IfsVersion
)
416 Stub
.IfsVersion
= TargetStub
->IfsVersion
;
418 if (Stub
.Target
!= TargetStub
->Target
&& !TargetStub
->Target
.empty()) {
419 WithColor::error() << "Interface Stub: Target Mismatch."
420 << "\nFilenames: " << PreviousInputFilePath
<< " "
424 if (Stub
.SoName
!= TargetStub
->SoName
) {
425 WithColor::error() << "Interface Stub: SoName Mismatch."
426 << "\nFilenames: " << PreviousInputFilePath
<< " "
428 << "\nSoName Values: " << Stub
.SoName
<< " "
429 << TargetStub
->SoName
<< "\n";
432 if (Stub
.NeededLibs
!= TargetStub
->NeededLibs
) {
433 WithColor::error() << "Interface Stub: NeededLibs Mismatch."
434 << "\nFilenames: " << PreviousInputFilePath
<< " "
435 << InputFilePath
<< "\n";
440 for (auto Symbol
: TargetStub
->Symbols
) {
441 auto SI
= SymbolMap
.find(Symbol
.Name
);
442 if (SI
== SymbolMap
.end()) {
444 std::pair
<std::string
, IFSSymbol
>(Symbol
.Name
, Symbol
));
448 assert(Symbol
.Name
== SI
->second
.Name
&& "Symbol Names Must Match.");
451 if (Symbol
.Type
!= SI
->second
.Type
) {
452 WithColor::error() << "Interface Stub: Type Mismatch for "
453 << Symbol
.Name
<< ".\nFilename: " << InputFilePath
454 << "\nType Values: " << getTypeName(SI
->second
.Type
)
455 << " " << getTypeName(Symbol
.Type
) << "\n";
459 if (Symbol
.Size
!= SI
->second
.Size
) {
460 WithColor::error() << "Interface Stub: Size Mismatch for "
461 << Symbol
.Name
<< ".\nFilename: " << InputFilePath
462 << "\nSize Values: " << SI
->second
.Size
<< " "
463 << Symbol
.Size
<< "\n";
467 if (Symbol
.Weak
!= SI
->second
.Weak
) {
471 // TODO: Not checking Warning. Will be dropped.
474 PreviousInputFilePath
= InputFilePath
;
477 if (Stub
.IfsVersion
!= IfsVersionCurrent
)
478 if (Stub
.IfsVersion
.getMajor() != IfsVersionCurrent
.getMajor()) {
479 WithColor::error() << "Interface Stub: Bad IfsVersion: "
480 << Stub
.IfsVersion
<< ", llvm-ifs supported version: "
481 << IfsVersionCurrent
<< ".\n";
485 for (auto &Entry
: SymbolMap
)
486 Stub
.Symbols
.push_back(Entry
.second
);
488 // Change SoName before emitting stubs.
490 Stub
.SoName
= *Config
.SoName
;
492 Error OverrideError
=
493 overrideIFSTarget(Stub
, Config
.OverrideArch
, Config
.OverrideEndianness
,
494 Config
.OverrideBitWidth
, Config
.OptTargetTriple
);
496 fatalError(std::move(OverrideError
));
498 if (Config
.StripNeeded
)
499 Stub
.NeededLibs
.clear();
501 if (Error E
= filterIFSSyms(Stub
, Config
.StripUndefined
, Config
.Exclude
))
502 fatalError(std::move(E
));
504 if (Config
.StripSize
)
505 for (IFSSymbol
&Sym
: Stub
.Symbols
)
508 if (!Config
.OutputElf
&& !Config
.OutputIfs
&& !Config
.OutputTbd
) {
509 if (!Config
.OutputFormat
) {
510 WithColor::error() << "at least one output should be specified.";
513 } else if (Config
.OutputFormat
) {
514 WithColor::error() << "'--output-format' cannot be used with "
515 "'--output-{FILE_FORMAT}' options at the same time";
518 if (Config
.OutputFormat
) {
519 // TODO: Remove OutputFormat flag in the next revision.
520 WithColor::warning() << "--output-format option is deprecated, please use "
521 "--output-{FILE_FORMAT} options instead\n";
522 switch (*Config
.OutputFormat
) {
523 case FileFormat::TBD
: {
524 std::error_code SysErr
;
525 raw_fd_ostream
Out(*Config
.Output
, SysErr
);
527 WithColor::error() << "Couldn't open " << *Config
.Output
528 << " for writing.\n";
531 if (!Stub
.Target
.Triple
) {
533 << "Triple should be defined when output format is TBD";
536 return writeTbdStub(llvm::Triple(Stub
.Target
.Triple
.value()),
537 Stub
.Symbols
, "TBD", Out
);
539 case FileFormat::IFS
: {
540 Stub
.IfsVersion
= IfsVersionCurrent
;
541 if (Config
.InputFormat
.value() == FileFormat::ELF
&&
542 Config
.HintIfsTarget
) {
543 std::error_code
HintEC(1, std::generic_category());
544 IFSTarget HintTarget
= parseTriple(*Config
.HintIfsTarget
);
545 if (Stub
.Target
.Arch
.value() != HintTarget
.Arch
.value())
546 fatalError(make_error
<StringError
>(
547 "Triple hint does not match the actual architecture", HintEC
));
548 if (Stub
.Target
.Endianness
.value() != HintTarget
.Endianness
.value())
549 fatalError(make_error
<StringError
>(
550 "Triple hint does not match the actual endianness", HintEC
));
551 if (Stub
.Target
.BitWidth
.value() != HintTarget
.BitWidth
.value())
552 fatalError(make_error
<StringError
>(
553 "Triple hint does not match the actual bit width", HintEC
));
555 stripIFSTarget(Stub
, true, false, false, false);
556 Stub
.Target
.Triple
= Config
.HintIfsTarget
.value();
558 stripIFSTarget(Stub
, Config
.StripIfsTarget
, Config
.StripIfsArch
,
559 Config
.StripIfsEndianness
, Config
.StripIfsBitwidth
);
561 Error IFSWriteError
=
562 writeIFS(Config
.Output
.value(), Stub
, Config
.WriteIfChanged
);
564 fatalError(std::move(IFSWriteError
));
567 case FileFormat::ELF
: {
568 Error TargetError
= validateIFSTarget(Stub
, true);
570 fatalError(std::move(TargetError
));
571 Error BinaryWriteError
=
572 writeBinaryStub(*Config
.Output
, Stub
, Config
.WriteIfChanged
);
573 if (BinaryWriteError
)
574 fatalError(std::move(BinaryWriteError
));
579 // Check if output path for individual format.
580 if (Config
.OutputElf
) {
581 Error TargetError
= validateIFSTarget(Stub
, true);
583 fatalError(std::move(TargetError
));
584 Error BinaryWriteError
=
585 writeBinaryStub(*Config
.OutputElf
, Stub
, Config
.WriteIfChanged
);
586 if (BinaryWriteError
)
587 fatalError(std::move(BinaryWriteError
));
589 if (Config
.OutputIfs
) {
590 Stub
.IfsVersion
= IfsVersionCurrent
;
591 if (Config
.InputFormat
.value() == FileFormat::ELF
&&
592 Config
.HintIfsTarget
) {
593 std::error_code
HintEC(1, std::generic_category());
594 IFSTarget HintTarget
= parseTriple(*Config
.HintIfsTarget
);
595 if (Stub
.Target
.Arch
.value() != HintTarget
.Arch
.value())
596 fatalError(make_error
<StringError
>(
597 "Triple hint does not match the actual architecture", HintEC
));
598 if (Stub
.Target
.Endianness
.value() != HintTarget
.Endianness
.value())
599 fatalError(make_error
<StringError
>(
600 "Triple hint does not match the actual endianness", HintEC
));
601 if (Stub
.Target
.BitWidth
.value() != HintTarget
.BitWidth
.value())
602 fatalError(make_error
<StringError
>(
603 "Triple hint does not match the actual bit width", HintEC
));
605 stripIFSTarget(Stub
, true, false, false, false);
606 Stub
.Target
.Triple
= Config
.HintIfsTarget
.value();
608 stripIFSTarget(Stub
, Config
.StripIfsTarget
, Config
.StripIfsArch
,
609 Config
.StripIfsEndianness
, Config
.StripIfsBitwidth
);
611 Error IFSWriteError
=
612 writeIFS(Config
.OutputIfs
.value(), Stub
, Config
.WriteIfChanged
);
614 fatalError(std::move(IFSWriteError
));
616 if (Config
.OutputTbd
) {
617 std::error_code SysErr
;
618 raw_fd_ostream
Out(*Config
.OutputTbd
, SysErr
);
620 WithColor::error() << "Couldn't open " << *Config
.OutputTbd
621 << " for writing.\n";
624 if (!Stub
.Target
.Triple
) {
626 << "Triple should be defined when output format is TBD";
629 return writeTbdStub(llvm::Triple(Stub
.Target
.Triple
.value()),
630 Stub
.Symbols
, "TBD", Out
);