CoreDriver implements a driver for a hypothetical platform.
It is intended to be used in unittests. However, it is actually
redundant because the features are tested using the real driver
for the real platforms. So we can remove this.
http://reviews.llvm.org/D17698
llvm-svn: 262421
bool link(llvm::ArrayRef<const char *> args, raw_ostream &diag = llvm::errs());
}
-/// Driver for lld unit tests
-class CoreDriver : public Driver {
-public:
- /// Parses command line arguments same as lld-core and performs link.
- /// Returns true iff there was an error.
- static bool link(llvm::ArrayRef<const char *> args,
- raw_ostream &diag = llvm::errs());
-
- /// Uses lld-core command line options to fill in options struct.
- /// Returns true iff there was an error.
- static bool parse(llvm::ArrayRef<const char *> args, CoreLinkingContext &info,
- raw_ostream &diag = llvm::errs());
-
-private:
- CoreDriver() = delete;
-};
-
} // end namespace lld
#endif
-set(LLVM_TARGET_DEFINITIONS CoreOptions.td)
-tablegen(LLVM CoreOptions.inc -gen-opt-parser-defs)
set(LLVM_TARGET_DEFINITIONS DarwinLdOptions.td)
tablegen(LLVM DarwinLdOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(DriverOptionsTableGen)
add_lld_library(lldDriver
- CoreDriver.cpp
DarwinLdDriver.cpp
Driver.cpp
+++ /dev/null
-//===- lib/Driver/CoreDriver.cpp ------------------------------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lld/Core/Reader.h"
-#include "lld/Driver/Driver.h"
-#include "lld/ReaderWriter/CoreLinkingContext.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/Option/Arg.h"
-#include "llvm/Option/Option.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Host.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/PrettyStackTrace.h"
-#include "llvm/Support/Signals.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace lld;
-
-namespace {
-
-// Create enum with OPT_xxx values for each option in CoreOptions.td
-enum {
- OPT_INVALID = 0,
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELP, META) \
- OPT_##ID,
-#include "CoreOptions.inc"
-#undef OPTION
-};
-
-// Create prefix string literals used in CoreOptions.td
-#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
-#include "CoreOptions.inc"
-#undef PREFIX
-
-// Create table mapping all options defined in CoreOptions.td
-static const llvm::opt::OptTable::Info infoTable[] = {
-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR) \
- { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, llvm::opt::Option::KIND##Class, \
- PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS },
-#include "CoreOptions.inc"
-#undef OPTION
-};
-
-// Create OptTable class for parsing actual command line arguments
-class CoreOptTable : public llvm::opt::OptTable {
-public:
- CoreOptTable() : OptTable(infoTable) {}
-};
-
-} // namespace anonymous
-
-
-namespace lld {
-
-static const Registry::KindStrings coreKindStrings[] = {
- { CoreLinkingContext::TEST_RELOC_CALL32, "call32" },
- { CoreLinkingContext::TEST_RELOC_PCREL32, "pcrel32" },
- { CoreLinkingContext::TEST_RELOC_GOT_LOAD32, "gotLoad32" },
- { CoreLinkingContext::TEST_RELOC_GOT_USE32, "gotUse32" },
- { CoreLinkingContext::TEST_RELOC_LEA32_WAS_GOT, "lea32wasGot" },
- LLD_KIND_STRING_END
-};
-
-bool CoreDriver::link(llvm::ArrayRef<const char *> args,
- raw_ostream &diagnostics) {
- CoreLinkingContext ctx;
-
- // Register possible input file parsers.
- ctx.registry().addSupportYamlFiles();
- ctx.registry().addKindTable(Reference::KindNamespace::testing,
- Reference::KindArch::all, coreKindStrings);
-
- if (!parse(args, ctx))
- return false;
- return Driver::link(ctx);
-}
-
-bool CoreDriver::parse(llvm::ArrayRef<const char *> args,
- CoreLinkingContext &ctx, raw_ostream &diagnostics) {
- // Parse command line options using CoreOptions.td
- CoreOptTable table;
- unsigned missingIndex;
- unsigned missingCount;
- llvm::opt::InputArgList parsedArgs =
- table.ParseArgs(args.slice(1), missingIndex, missingCount);
- if (missingCount) {
- diagnostics << "error: missing arg value for '"
- << parsedArgs.getArgString(missingIndex) << "' expected "
- << missingCount << " argument(s).\n";
- return false;
- }
-
- // Set default options
- ctx.setOutputPath("-");
- ctx.setDeadStripping(false);
- ctx.setGlobalsAreDeadStripRoots(false);
- ctx.setPrintRemainingUndefines(false);
- ctx.setAllowRemainingUndefines(true);
- ctx.setSearchArchivesToOverrideTentativeDefinitions(false);
-
- // Process all the arguments and create input files.
- for (auto inputArg : parsedArgs) {
- switch (inputArg->getOption().getID()) {
- case OPT_mllvm:
- ctx.appendLLVMOption(inputArg->getValue());
- break;
-
- case OPT_entry:
- ctx.setEntrySymbolName(inputArg->getValue());
- break;
-
- case OPT_output:
- ctx.setOutputPath(inputArg->getValue());
- break;
-
- case OPT_dead_strip:
- ctx.setDeadStripping(true);
- break;
-
- case OPT_keep_globals:
- ctx.setGlobalsAreDeadStripRoots(true);
- break;
-
- case OPT_undefines_are_errors:
- ctx.setPrintRemainingUndefines(true);
- ctx.setAllowRemainingUndefines(false);
- break;
-
- case OPT_commons_search_archives:
- ctx.setSearchArchivesToOverrideTentativeDefinitions(true);
- break;
-
- case OPT_add_pass:
- ctx.addPassNamed(inputArg->getValue());
- break;
-
- case OPT_INPUT: {
- std::vector<std::unique_ptr<File>> files
- = loadFile(ctx, inputArg->getValue(), false);
- for (std::unique_ptr<File> &file : files)
- ctx.getNodes().push_back(llvm::make_unique<FileNode>(std::move(file)));
- break;
- }
-
- default:
- break;
- }
- }
-
- parseLLVMOptions(ctx);
-
- if (ctx.getNodes().empty()) {
- diagnostics << "No input files\n";
- return false;
- }
-
- // Validate the combination of options used.
- return ctx.validate(diagnostics);
-}
-
-} // namespace lld
+++ /dev/null
-include "llvm/Option/OptParser.td"
-
-def output : Separate<["-"], "o">;
-def entry : Separate<["-"], "e">;
-
-def dead_strip : Flag<["--"], "dead-strip">;
-def undefines_are_errors : Flag<["--"], "undefines-are-errors">;
-def keep_globals : Flag<["--"], "keep-globals">;
-def commons_search_archives : Flag<["--"], "commons-search-archives">;
-
-def add_pass : Separate<["--"], "add-pass">;
-
-def target : Separate<["-"], "target">, HelpText<"Target triple to link for">;
-def mllvm : Separate<["-"], "mllvm">, HelpText<"Options to pass to LLVM">;
-
+++ /dev/null
---- !archive
-members:
- - name: bar.o
- content: !native
- defined-atoms:
- - name: bar
- scope: global
- type: code
-
- - name: bar2
- type: code
-
- - name: baz.o
- content: !native
- defined-atoms:
- - name: baz
- scope: global
- type: code
-
- - name: baz2
- type: code
+++ /dev/null
---- !archive
-members:
- - name: bar1.o
- content: !native
- defined-atoms:
- - name: bar1
- scope: global
- type: code
-
- - name: bar1b
- type: code
-
- undefined-atoms:
- - name: baz1
-
- - name: bar2.o
- content: !native
- defined-atoms:
- - name: bar2
- scope: global
- type: code
-
- - name: bar2b
- type: code
+++ /dev/null
---- !archive
-members:
- - name: baz1.o
- content: !native
- defined-atoms:
- - name: baz1
- scope: global
- type: code
-
- - name: baz1b
- type: code
-
- - name: baz2.o
- content: !native
- defined-atoms:
- - name: baz2
- scope: global
- type: code
-
- - name: baz2b
- type: code
+++ /dev/null
---- !archive
-members:
- - name: bar.o
- content: !native
- defined-atoms:
- - name: bar
- scope: global
- type: data
-
- - name: bar2
- type: data
+++ /dev/null
-defined-atoms:
- - name: f1
- merge: as-weak
- scope: global
- references:
- - kind: associate
- target: f2
- - name: f2
+++ /dev/null
-defined-atoms:
- - name: _inlineFunc1
- scope: global
- type: code
- merge: as-weak
-
- - name: _inlineFunc2
- scope: global
- type: code
- merge: as-addressed-weak
-
- - name: _inlineFunc3
- scope: global
- type: code
- merge: as-weak
-
- - name: _inlineFunc4
- scope: global
- type: code
- merge: as-addressed-weak
+++ /dev/null
----
-defined-atoms:
- - name: _none
- code-model: none
+++ /dev/null
----
-defined-atoms:
- - name: _mips_pic
- code-model: mips-pic
+++ /dev/null
----
-defined-atoms:
- - name: _mips_micro
- code-model: mips-micro
+++ /dev/null
----
-defined-atoms:
- - name: _mips_micro_pic
- code-model: mips-micro-pic
+++ /dev/null
----
-defined-atoms:
- - name: _mips_16
- code-model: mips-16
+++ /dev/null
----
-defined-atoms:
- - ref-name: L1
- type: constant
- content: [ 01, 02 ]
- - ref-name: L2
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
+++ /dev/null
----
-defined-atoms:
- - ref-name: L2
- type: constant
- merge: by-content
- content: [ 01, 23, 45, 67, 89, AB, CD, EF ]
- - ref-name: L3
- type: constant
- merge: by-content
- content: [ 01, 02, 03 ]
+++ /dev/null
----
-defined-atoms:
- - ref-name: L2
- type: c-string
- merge: by-content
- content: [ 68, 65, 6c, 6c, 6f, 00 ]
+++ /dev/null
----
-defined-atoms:
- - ref-name: L2
- type: c-string
- merge: by-content
- content: [ 74, 68, 65, 72, 65, 00 ]
+++ /dev/null
----
-defined-atoms:
- - ref-name: L1
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
- section-choice: custom-required
- section-name: .mysection
-
- - ref-name: L2
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
- section-choice: custom-required
- section-name: .mysection2
+++ /dev/null
----
-defined-atoms:
- - ref-name: L1
- type: constant
- merge: by-content
- content: [ 05, 06, 07, 08 ]
- section-choice: custom-required
- section-name: .mysection
-
- - ref-name: L2
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
+++ /dev/null
----
-defined-atoms:
- - name: _foo2
- dead-strip: never
+++ /dev/null
----
-defined-atoms:
- - name: _foo3
- dead-strip: always
+++ /dev/null
----
-defined-atoms:
- - name: mydead2
- scope: global
- type: data
-
- - name: bar
- scope: global
- type: data
+++ /dev/null
----
-defined-atoms:
- - name: baz
- scope: global
- type: code
-
- - name: mydead3
- type: code
+++ /dev/null
----
-defined-atoms:
- - name: myglobal2
- scope: global
- type: data
-
- - name: bar
- scope: hidden
- type: data
+++ /dev/null
----
-defined-atoms:
- - name: baz
- scope: hidden
- type: code
-
- - name: mydead
- type: code
+++ /dev/null
----
-absolute-atoms:
- - name: absatom
- value: 0
- scope: global
+++ /dev/null
----
-undefined-atoms:
- - name: f3
- can-be-null: never
+++ /dev/null
----
-undefined-atoms:
- - name: f1
- can-be-null: never
+++ /dev/null
----
-defined-atoms:
- - name: _inlineFunc
- scope: global
- type: code
- merge: as-weak
+++ /dev/null
----
-defined-atoms:
- - name: _inlineFunc
- scope: global
- type: code
- merge: as-weak
+++ /dev/null
----
-defined-atoms:
- - name: _foo
- scope: global
- type: data
+++ /dev/null
-undefined-atoms:
- - name: f1
- can-be-null: never
+++ /dev/null
----
-undefined-atoms:
- - name: f3
- can-be-null: never
+++ /dev/null
----
-undefined-atoms:
- - name: f1
- can-be-null: never
+++ /dev/null
----
-shared-library-atoms:
- - name: foo2
- load-name: libc.so
-
- - name: foo3
- load-name: libc.so
-
- - name: bar2
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: bar3
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: mismatchNull1
- load-name: libc.so
-
- - name: mismatchNull2
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: mismatchload1
- load-name: libb.so
-
- - name: mismatchload2
- load-name: liba.so
+++ /dev/null
----
-defined-atoms:
- - name: _foo
- scope: global
- type: data
- content: [ 00, 00, 00, 00 ]
+++ /dev/null
----
-defined-atoms:
- - name: bar
- type: code
-
-undefined-atoms:
- - name: malloc
- - name: myfunc
+++ /dev/null
----
-defined-atoms:
- - name: myfunc
- scope: global
- type: code
-
-undefined-atoms:
- - name: free
+++ /dev/null
----
-defined-atoms:
- - name: bar
- type: code
-
-undefined-atoms:
- - name: malloc
- - name: myfunc
+++ /dev/null
----
-defined-atoms:
- - name: myfunc
- scope: global
- type: code
-
-undefined-atoms:
- - name: free
+++ /dev/null
-defined-atoms:
- - name: fallback1
-
-undefined-atoms:
- - name: def1
- fallback:
- name: fallback3
+++ /dev/null
----
-undefined-atoms:
- - name: bar1
- can-be-null: never
- - name: bar2
- can-be-null: at-runtime
- - name: bar3
- can-be-null: at-buildtime
- - name: bar4
- can-be-null: at-runtime
- - name: bar5
- can-be-null: at-buildtime
- - name: bar6
- can-be-null: never
- - name: bar7
- can-be-null: at-buildtime
- - name: bar8
- can-be-null: never
- - name: bar9
- can-be-null: at-runtime
+++ /dev/null
----
-defined-atoms:
- - name: _foo
- scope: global
- type: data
+++ /dev/null
----
-defined-atoms:
- - name: _foo
- merge: as-weak
- scope: global
- type: data
+++ /dev/null
-# RUN: lld -core --dead-strip %s | FileCheck %s
-
-#
-# Test that absolute symbols are parsed and preserved
-#
-
----
-absolute-atoms:
- - name: putchar
- value: 0xFFFF0040
-
- - name: reset
- value: 0xFFFF0080
-
-...
-
-
-# CHECK: absolute-atoms:
-# CHECK: name: putchar
-# CHECK: value: 0x00000000FFFF0040
-# CHECK: name: reset
-# CHECK: value: 0x00000000FFFF0080
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that absolute symbols with local scope do not cause name conflict
-#
----
-absolute-atoms:
- - name: putchar
- ref-name: pc1
- value: 0xFFFF0040
- scope: static
-
- - name: putchar
- ref-name: pc2
- value: 0xFFFF0040
- scope: static
-...
-
-# CHECK: ---
-# CHECK: absolute-atoms:
-# CHECK: - name: putchar
-# CHECK: value: 0x00000000FFFF0040
-# CHECK: - name: putchar
-# CHECK: value: 0x00000000FFFF0040
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/archive-basic.objtxt | FileCheck %s
-
-#
-# Tests archives in YAML. Tests that an undefined in a regular file will load
-# all atoms in select archive members.
-#
-
---- !native
-defined-atoms:
- - name: foo
- type: code
-
-undefined-atoms:
- - name: bar
-
-...
-
-# CHECK: name: foo
-# CHECK-NOT: undefined-atoms:
-# CHECK: name: bar
-# CHECK: name: bar2
-# CHECK-NOT: name: baz
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/archive-chain.objtxt %p/Inputs/archive-chain2.objtxt | FileCheck %s
-
-#
-# Tests that an undefine in one archive can force a load from another archive.
-#
-
---- !native
-defined-atoms:
- - name: foo
- type: code
-
-undefined-atoms:
- - name: bar1
-...
-
-# CHECK: name: foo
-# CHECK: name: bar1
-# CHECK: name: bar1b
-# CHECK-NOT: name: bar2
-# CHECK: name: baz1
-# CHECK: name: baz1b
-# CHECK-NOT: name: baz2
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/archive-tentdef-search.objtxt | FileCheck -check-prefix=CHK1 %s
-# RUN: lld -core --commons-search-archives %s %p/Inputs/archive-tentdef-search.objtxt | FileCheck -check-prefix=CHK2 %s
-
-#
-# Tests that -commons-search-archives cause core linker to look for overrides
-# of tentative definition in archives, and that not using that option
-# does not search.
-#
-
---- !native
-defined-atoms:
- - name: foo
- type: code
-
- - name: bar
- scope: global
- type: zero-fill
- merge: as-tentative
-...
-
-# CHK1: name: foo
-# CHK1: name: bar
-# CHK1: merge: as-tentative
-# CHK1: ...
-
-# CHK2: name: foo
-# CHK2: name: bar
-# CHK2-NOT: merge: as-tentative
-# CHK2: name: bar2
-# CHK2: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/associates.objtxt | FileCheck %s
-
----
-defined-atoms:
- - name: f1
- merge: as-weak
- scope: global
- references:
- - kind: associate
- target: f2
- - name: f2
-...
-
-# CHECK: defined-atoms:
-# CHECK: - name: f1
-# CHECK: scope: global
-# CHECK: references:
-# CHECK: - kind: associate
-# CHECK: target: f2
-# CHECK: - name: f2
-# CHECK-NOT: - name: f2
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/auto-hide-coalesce.objtxt | FileCheck %s
-
-#
-# Tests auto-hide bit during coalescing
-#
-
----
-defined-atoms:
- - name: _inlineFunc1
- scope: global
- type: code
- merge: as-weak
-
- - name: _inlineFunc2
- scope: global
- type: code
- merge: as-weak
-
- - name: _inlineFunc3
- scope: global
- type: code
- merge: as-addressed-weak
-
- - name: _inlineFunc4
- scope: global
- type: code
- merge: as-addressed-weak
-...
-
-
-# CHECK: name: _inlineFunc1
-# CHECK: merge: as-weak
-# CHECK: name: _inlineFunc3
-# CHECK: merge: as-addressed-weak
-# CHECK: name: _inlineFunc4
-# CHECK: merge: as-addressed-weak
-# CHECK: name: _inlineFunc2
-# CHECK: merge: as-addressed-weak
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/code-model-attributes.objtxt \
-# RUN: %p/Inputs/code-model-attributes2.objtxt \
-# RUN: %p/Inputs/code-model-attributes3.objtxt \
-# RUN: %p/Inputs/code-model-attributes4.objtxt \
-# RUN: %p/Inputs/code-model-attributes5.objtxt | FileCheck %s
-#
-# Test that code model attributes are preserved
-#
-
----
-defined-atoms:
- - name: _def
-...
-
-# CHECK: name: _def
-# CHECK-NOT: code-model: mips-pic
-# CHECK-NOT: code-model: mips-micro
-# CHECK-NOT: code-model: mips-micro-pic
-# CHECK-NOT: code-model: mips-16
-# CHECK: name: _none
-# CHECK-NOT: code-model: mips-pic
-# CHECK-NOT: code-model: mips-micro
-# CHECK-NOT: code-model: mips-micro-pic
-# CHECK-NOT: code-model: mips-16
-# CHECK: name: _mips_pic
-# CHECK: code-model: mips-pic
-# CHECK: name: _mips_micro
-# CHECK: code-model: mips-micro
-# CHECK: name: _mips_micro_pic
-# CHECK: code-model: mips-micro-pic
-# CHECK: name: _mips_16
-# CHECK: code-model: mips-16
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/constants-coalesce.objtxt \
-# RUN: %p/Inputs/constants-coalesce2.objtxt | FileCheck %s
-
-#
-# Test that duplicate merge-by-content anonymous constants are coalesced
-# and non-mergable duplicate constants are not coalesced.
-#
-
----
-defined-atoms:
- - ref-name: L4-byte
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
-
- - ref-name: L8-byte
- type: constant
- merge: by-content
- content: [ 01, 23, 45, 67, 89, AB, CD, EF ]
-
- - ref-name: L1
- type: constant
- content: [ 01, 02 ]
-...
-
-# CHECK-NOT: name:
-# CHECK: type: constant
-# CHECK: content: [ 01, 02, 03, 04 ]
-# CHECK: merge: by-content
-# CHECK: type: constant
-# CHECK: content: [ 01, 23, 45, 67, 89, AB, CD, EF ]
-# CHECK: merge: by-content
-# CHECK: type: constant
-# CHECK: content: [ 01, 02 ]
-# CHECK: type: constant
-# CHECK: content: [ 01, 02 ]
-# CHECK: type: constant
-# CHECK: content: [ 01, 02, 03 ]
-# CHECK: merge: by-content
-# CHECK: ...
-
-
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that duplicate c-strings are coalesced
-#
-
----
-defined-atoms:
- - ref-name: L0
- type: c-string
- merge: by-content
- content: [ 68, 65, 6c, 6c, 6f, 00 ]
-
- - ref-name: L1
- type: c-string
- merge: by-content
- content: [ 74, 68, 65, 72, 65, 00 ]
-...
-
-# CHECK-NOT: name:
-# CHECK: type: c-string
-# CHECK: content: [ 68, 65, 6C, 6C, 6F, 00 ]
-# CHECK: merge: by-content
-# CHECK: type: c-string
-# CHECK: content: [ 74, 68, 65, 72, 65, 00 ]
-# CHECK: merge: by-content
-# CHECK: ...
-
-
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/custom-section-coalesce.objtxt \
-# RUN: %p/Inputs/custom-section-coalesce2.objtxt | FileCheck %s
-
-#
-# Test that custom sections are preserved when duplicate merge-by-content
-# constants are coalesced.
-#
-
----
-defined-atoms:
- - ref-name: L1
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
- section-choice: custom-required
- section-name: .mysection
-
- - ref-name: L2
- type: constant
- merge: by-content
- content: [ 05, 06, 07, 08 ]
- section-choice: custom-required
- section-name: .mysection
-
- - ref-name: L3
- type: constant
- merge: by-content
- content: [ 01, 02, 03, 04 ]
-...
-
-
-# CHECK:defined-atoms:
-# CHECK: - type: constant
-# CHECK: content: [ 01, 02, 03, 04 ]
-# CHECK: merge: by-content
-# CHECK: section-choice: custom-required
-# CHECK: section-name: .mysection
-# CHECK: - type: constant
-# CHECK: content: [ 05, 06, 07, 08 ]
-# CHECK: merge: by-content
-# CHECK: section-choice: custom-required
-# CHECK: section-name: .mysection
-# CHECK: - type: constant
-# CHECK: content: [ 01, 02, 03, 04 ]
-# CHECK: merge: by-content
-# CHECK: - type: constant
-# CHECK: content: [ 01, 02, 03, 04 ]
-# CHECK: merge: by-content
-# CHECK: section-choice: custom-required
-# CHECK: section-name: .mysection2
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that custom sections are preserved
-#
-
----
-defined-atoms:
- - name: _foo1
- scope: global
- section-choice: content
-
- - name: _foo2
- scope: global
- section-choice: custom
- section-name: __foozle
-
- - name: _foo3
- scope: global
- section-choice: custom-required
- section-name: __boozle
-
-...
-
-
-# CHECK: name: _foo1
-# CHECK-NOT: section-name:
-# CHECK: name: _foo2
-# CHECK: section-choice: custom
-# CHECK: section-name: __foozle
-# CHECK: name: _foo3
-# CHECK: section-choice: custom-required
-# CHECK: section-name: __boozle
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/dead-strip-attributes.objtxt \
-# RUN: %p/Inputs/dead-strip-attributes2.objtxt | FileCheck %s
-
-#
-# Test that dead strip attributes are preserved
-#
-
----
-defined-atoms:
- - name: _foo1
- dead-strip: normal
-...
-
-
-# CHECK: name: _foo1
-# CHECK-NOT: dead-strip: never
-# CHECK-NOT: dead-strip: always
-# CHECK: name: _foo2
-# CHECK: dead-strip: never
-# CHECK: name: _foo3
-# CHECK: dead-strip: always
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core --dead-strip %s %p/Inputs/dead-strip-basic.objtxt %p/Inputs/dead-strip-basic2.objtxt | FileCheck -check-prefix=CHK1 %s
-# RUN: lld -core %s %p/Inputs/dead-strip-basic.objtxt %p/Inputs/dead-strip-basic2.objtxt | FileCheck -check-prefix=CHK2 %s
-
-#
-# Test that -dead-strip removes unreachable code and data
-# and that not using that option leaves them.
-#
-
----
-defined-atoms:
- - name: entry
- dead-strip: never
- references:
- - offset: 1
- kind: pcrel32
- target: bar
- - offset: 6
- kind: pcrel32
- target: baz
-
- - name: mydead1
- scope: global
-
-undefined-atoms:
- - name: bar
-
- - name: baz
-...
-
-
-# CHK1: name: entry
-# CHK1-NOT: name: mydead1
-# CHK1: name: bar
-# CHK1-NOT: name: mydead2
-# CHK1: name: baz
-# CHK1-NOT: name: mydead3
-# CHK1: ...
-
-# CHK2: name: entry
-# CHK2: name: mydead1
-# CHK2: name: mydead2
-# CHK2: name: bar
-# CHK2: name: baz
-# CHK2: name: mydead3
-# CHK2: ...
+++ /dev/null
-# RUN: lld -core --dead-strip --keep-globals %s %p/Inputs/dead-strip-globals.objtxt %p/Inputs/dead-strip-globals2.objtxt | FileCheck -check-prefix=CHK1 %s
-# RUN: lld -core --dead-strip %s %p/Inputs/dead-strip-globals.objtxt %p/Inputs/dead-strip-globals2.objtxt | FileCheck -check-prefix=CHK2 %s
-
-#
-# Test that -keep-globals prevents -dead-strip from removing globals.
-#
-
----
-defined-atoms:
- - name: entry
- dead-strip: never
- references:
- - offset: 1
- kind: pcrel32
- target: bar
- - offset: 6
- kind: pcrel32
- target: baz
-
- - name: myglobal1
- scope: global
-
-undefined-atoms:
- - name: bar
- - name: baz
-...
-
-
-# CHK1: name: entry
-# CHK1: name: myglobal1
-# CHK1: name: myglobal2
-# CHK1: name: bar
-# CHK1: name: baz
-# CHK1-NOT: name: mydead
-# CHK1: ...
-
-# CHK2: name: entry
-# CHK2-NOT: name: myglobal1
-# CHK2-NOT: name: myglobal2
-# CHK2: name: bar
-# CHK2: name: baz
-# CHK2-NOT: name: mydead
-# CHK2: ...
+++ /dev/null
-# RUN: lld -core --dead-strip %s | FileCheck -check-prefix=CHECK1 %s
-# RUN: lld -core %s | FileCheck -check-prefix=CHECK2 %s
-
----
-defined-atoms:
- - name: entry
- dead-strip: never
- scope: global
- references:
- - kind: layout-after
- offset: 0
- target: def
- - name: def
- scope: global
- - name: dead
- scope: global
-...
-
-# CHECK1: name: entry
-# CHECK1: name: def
-# CHECK1-NOT: name: dead
-
-# CHECK2: name: entry
-# CHECK2: name: def
-# CHECK2: name: dead
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that unknown atom attribute produces a readable error.
-#
-
----
-defined-atoms:
- - name: entry
- scope: hidden
- foobar: true
- dead-strip: never
-
-...
-
-
-# CHECK: error: unknown key 'foobar'
-# CHECK: foobar
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that an invalid hex byte produces a readable error.
-#
-
----
-defined-atoms:
- - name: entry
- scope: hidden
- content: [ A5, 00, 4G, 1F ]
-
-...
-
-
-# CHECK: error: invalid two-digit-hex number
-# CHECK: 4G
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that an out of range byte value produces a readable error.
-#
-
----
-defined-atoms:
- - name: entry
- scope: hidden
- content: [ A5, 1234, 00, 4F ]
-
-...
-
-
-# CHECK: error: out of range two-digit-hex number
-# CHECK: 1234
-
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that an unknown content type produces a readable error.
-#
-
----
-defined-atoms:
- - name: entry
- scope: hidden
- type: superluminal
- dead-strip: never
-
-...
-
-
-# CHECK: error: unknown enumerated scalar
-# CHECK: superluminal
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that a defined attribute on an undefined atom produces a readable error.
-#
-
----
-undefined-atoms:
- - name: foo
- type: code
-
-...
-
-
-# CHECK: error: unknown key 'type'
-
+++ /dev/null
-# RUN: not lld -core %s %p/Inputs/error-duplicate-absolutes.objtxt 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that duplicate absolute atoms produces a readable error.
-#
-
----
-absolute-atoms:
- - name: absatom
- value: 0
- scope: global
-undefined-atoms:
- - name: undefatom
-...
-
-
-# CHECK: SymbolTable: error while merging absatom
-# CHECK: LLVM ERROR: duplicate symbol error
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that unknown file attribute produces a readable error.
-#
-
----
-aardvark: true
-defined-atoms:
- - name: entry
- scope: hidden
-
-...
-
-
-# CHECK: error: unknown key 'aardvark'
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that unknown fixup attribute produces a readable error.
-#
-
----
-defined-atoms:
- - name: entry
- scope: hidden
- references:
- - offset: 3
- kind: pcrel32
- weasel: bar
- addend: 100
-
-...
-
-
-# CHECK: error: unknown key 'weasel'
+++ /dev/null
-# RUN: not lld -core %s 2> %t.err
-# RUN: FileCheck %s < %t.err
-
-#
-# Test that unbindable target name produces a readable error.
-#
-
----
-defined-atoms:
- - name: entry
- scope: hidden
- references:
- - offset: 3
- kind: pcrel32
- target: bar
- - offset: 5
- kind: pcrel32
- target: baz
-
-undefined-atoms:
- - name: bar
-
-...
-
-
-# CHECK: error: no such atom name: baz
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test addends in references
-#
-
----
-defined-atoms:
- - name: foo
- type: code
- content: [ 48, 8D, 3D, 00, 00, 00, 00,
- 48, 8D, 3D, 00, 00, 00, 00 ]
- references:
- - offset: 3
- kind: pcrel32
- target: bar
- addend: 100
- - offset: 10
- kind: pcrel32
- target: bar
- addend: -50
-
- - name: func
- type: code
- content: [ 48, 8D, 3D, 00, 00, 00, 00,
- 48, 8D, 3D, 00, 00, 00, 00 ]
- references:
- - offset: 3
- kind: pcrel32
- target: bar
- addend: 8000000000
- - offset: 10
- kind: pcrel32
- target: bar
- addend: -50
-
-undefined-atoms:
- - name: bar
-
-
-...
-
-# CHECK: name: foo
-# CHECK: references:
-# CHECK: addend: 100
-# CHECK: addend: -50
-# CHECK: name: func
-# CHECK: references:
-# CHECK: addend: 8000000000
-# CHECK: addend: -50
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test references referencing multiple atoms that have the same name
-#
-
----
-defined-atoms:
- - name: foo
- type: code
- content: [ E8, 00, 00, 00, 00, E8, 00, 00, 00, 00 ]
- references:
- - offset: 1
- kind: pcrel32
- target: bar_1
- - offset: 6
- kind: pcrel32
- target: bar_2
-
- - name: bar
- ref-name: bar_1
- scope: static
-
- - name: bar
- ref-name: bar_2
- scope: static
-
-
-...
-
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test references to simple named atoms
-#
-
----
-defined-atoms:
- - name: foo
- type: code
- content: [ E8, 00, 00, 00, 00,
- E8, 00, 00, 00, 00 ]
- references:
- - offset: 1
- kind: pcrel32
- target: bar
- - offset: 6
- kind: pcrel32
- target: baz
-
- - name: baz
- scope: static
- type: code
-
-undefined-atoms:
- - name: bar
-
-
-...
-
-# CHECK: name: foo
-# CHECK: references:
-# CHECK: target: bar
-# CHECK: target: baz
-# CHECK: ...
-
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test references to unnamed atoms
-#
-
----
-defined-atoms:
- - name: foo
- type: code
- content: [ 48, 8D, 3D, 00, 00, 00, 00,
- 48, 8D, 3D, 00, 00, 00, 00 ]
- references:
- - offset: 3
- kind: pcrel32
- target: LC1
- - offset: 10
- kind: pcrel32
- target: LC2
-
-
- - ref-name: LC1
- type: c-string
- merge: by-content
- content: [ 68, 65, 6c, 6c, 6f, 00 ]
-
- - ref-name: LC2
- type: c-string
- merge: by-content
- content: [ 74, 68, 65, 72, 65, 00 ]
-
-
-...
-
-# CHECK: name: foo
-# CHECK: references:
-# CHECK: offset: 3
-# CHECK: offset: 10
-# CHECK: ref-name:
-# CHECK: ref-name:
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/inline-coalesce.objtxt %p/Inputs/inline-coalesce2.objtxt | FileCheck %s
-
-#
-# Test that non-inlined inlined functions are silently coalesced
-#
-
----
-defined-atoms:
- - name: _inlineFunc
- scope: global
- type: code
- merge: as-weak
-...
-
-
-# CHECK: name: _inlineFunc
-# CHECK: merge: as-weak
-# CHECK-NOT: name: _inlineFunc
-# CHECK: ...
+++ /dev/null
-# RUN: not lld -core %s %p/Inputs/multiple-def-error.objtxt 2>&1 | FileCheck %s
-
-#
-# Test that multiple definitions cause an error
-#
-
-# CHECK: duplicate symbol
-
----
-defined-atoms:
- - name: _foo
- scope: global
- type: data
-...
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test permissions for known content types are implicit, but can be overridden.
-#
----
-defined-atoms:
- - name: one
- type: code
-
- - name: two
- type: data
- permissions: rw-
-
- - name: three
- type: const-data
-
- - name: four
- type: unknown
-
- - name: oddCode
- type: code
- permissions: rwx
-
- - name: oddData
- type: data
- permissions: rwx
-
- - name: oddConstData
- type: const-data
- permissions: rw-
-
- - name: oddUnknown
- type: unknown
- permissions: rw-
-
-...
-
-# CHECK: ---
-# CHECK: defined-atoms:
-# CHECK: - name: one
-# CHECK-NOT: permissions:
-# CHECK: - name: two
-# CHECK-NOT: permissions:
-# CHECK: - name: three
-# CHECK-NOT: permissions:
-# CHECK: - name: four
-# CHECK-NOT: permissions:
-# CHECK: - name: oddCode
-# CHECK: permissions: rwx
-# CHECK: - name: oddData
-# CHECK: permissions: rwx
-# CHECK: - name: oddConstData
-# CHECK: permissions: rw-
-# CHECK: - name: oddUnknown
-# CHECK: permissions: rw-
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s | FileCheck %s
-
-#
-# Test that shared-library symbols are parsed and preserved
-#
-
----
-shared-library-atoms:
- - name: malloc
- load-name: libc.so
- type: code
- size: 0
-
- - name: free
- load-name: libc.so
-
- - name: fast_malloc
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: stdout
- load-name: libc.so
- type: data
- size: 8
-
-...
-
-# CHECK: shared-library-atoms:
-# CHECK: name: malloc
-# CHECK: load-name: libc.so
-# CHECK: name: free
-# CHECK: load-name: libc.so
-# CHECK: name: fast_malloc
-# CHECK: load-name: libc.so
-# CHECK: can-be-null: at-runtime
-# CHECK: name: stdout
-# CHECK: load-name: libc.so
-# CHECK: type: data
-# CHECK: size: 8
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/shared-library-coalesce.objtxt | FileCheck %s
-
-#
-# Test that shared library symbols preserve their attributes and merge properly
-#
-
----
-shared-library-atoms:
- - name: foo1
- load-name: libc.so
-
- - name: foo2
- load-name: libc.so
-
- - name: bar1
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: bar2
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: mismatchNull1
- load-name: libc.so
- can-be-null: at-runtime
-
- - name: mismatchNull2
- load-name: libc.so
-
- - name: mismatchload1
- load-name: liba.so
-
- - name: mismatchload2
- load-name: libb.so
-
-...
-
-# CHECK: name: foo1
-# CHECK: name: foo2
-# CHECK: name: bar1
-# CHECK: can-be-null: at-runtime
-# CHECK: name: bar2
-# CHECK: can-be-null: at-runtime
-# CHECK: name: mismatchNull1
-# CHECK: can-be-null: at-runtime
-# CHECK: name: mismatchNull2
-# CHECK-NOT: can-be-null: at-runtime
-# CHECK: name: mismatchload1
-# CHECK: load-name: liba.so
-# CHECK: name: mismatchload2
-# CHECK: load-name: libb.so
-# CHECK: name: foo3
-# CHECK: name: bar3
-# CHECK: can-be-null: at-runtime
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/tent-merge.objtxt | FileCheck %s
-
-#
-# Test that a tentative definition and a regular global are merged into
-# one regular global
-#
-
----
-defined-atoms:
- - name: _foo
- merge: as-tentative
- scope: global
- type: zero-fill
- size: 4
-...
-
-
-# CHECK: name: _foo
-# CHECK-NOT: merge: as-tentative
+++ /dev/null
-# RUN: not lld -core --undefines-are-errors %s %p/Inputs/undef-coalesce-error.objtxt %p/Inputs/undef-coalesce-error2.objtxt 2> %t.err
-# RUN: FileCheck -check-prefix=CHECKERR %s < %t.err
-# RUN: lld -core %s %p/Inputs/undef-coalesce-error.objtxt %p/Inputs/undef-coalesce-error2.objtxt | FileCheck %s
-
-#
-# Test that -undefines-are-errors triggers and error
-# and that not using that option results in undefined atoms.
-#
-
----
-defined-atoms:
- - name: foo
- type: code
-
-undefined-atoms:
- - name: malloc
- - name: free
-...
-
-# CHECKERR: free
-# CHECKERR: malloc
-# CHECKERR: symbol(s) not found
-
-# CHECK: defined-atoms:
-# CHECK: name: foo
-# CHECK: name: bar
-# CHECK: name: myfunc
-# CHECK: undefined-atoms:
-# CHECK: name: malloc
-# CHECK: name: free
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/undef-coalesce.objtxt %p/Inputs/undef-coalesce2.objtxt | FileCheck %s
-
-#
-# Test that undefined symbols are coalesced with other undefined symbols
-# and definitions override them.
-#
-
----
-defined-atoms:
- - name: foo
- type: code
-
-undefined-atoms:
- - name: malloc
- - name: free
-...
-
-# CHECK: defined-atoms:
-# CHECK: name: foo
-# CHECK: name: bar
-# CHECK: name: myfunc
-# CHECK: scope: global
-# CHECK: undefined-atoms:
-# CHECK: name: malloc
-# CHECK: name: free
-# CHECK: ...
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/undef-weak-coalesce.objtxt| FileCheck %s
-
-#
-# Test that undefined symbols preserve their attributes and merge properly
-#
-
----
-undefined-atoms:
- - name: regular_func
- can-be-null: never
- - name: weak_import_func
- can-be-null: at-runtime
- - name: weak_func
- can-be-null: at-buildtime
- - name: bar1
- can-be-null: never
- - name: bar2
- can-be-null: at-runtime
- - name: bar3
- can-be-null: at-buildtime
- - name: bar4
- can-be-null: never
- - name: bar5
- can-be-null: at-runtime
- - name: bar6
- can-be-null: at-buildtime
- - name: bar7
- can-be-null: never
- - name: bar8
- can-be-null: at-runtime
- - name: bar9
- can-be-null: at-buildtime
-...
-
-# CHECK: - name: regular_func
-# CHECK-NEXT: - name: weak_import_func
-# CHECK-NEXT: can-be-null: at-runtime
-# CHECK-NEXT: - name: weak_func
-# CHECK-NEXT: can-be-null: at-buildtime
-# CHECK-NEXT: - name: bar1
-# CHECK-NEXT: - name: bar2
-# CHECK-NEXT: can-be-null: at-runtime
-# CHECK-NEXT: - name: bar3
-# CHECK-NEXT: can-be-null: at-buildtime
-# CHECK-NEXT: - name: bar4
-# CHECK-NEXT: - name: bar5
-# CHECK-NEXT: can-be-null: at-runtime
-# CHECK-NEXT: - name: bar7
-# CHECK-NEXT: - name: bar6
-# CHECK-NEXT: - name: bar8
-# CHECK-NEXT: - name: bar9
-# CHECK-NEXT: can-be-null: at-runtime
+++ /dev/null
-# RUN: lld -core %s %p/Inputs/weak-coalesce.objtxt \
-# RUN: %p/Inputs/weak-coalesce2.objtxt | FileCheck %s
-
----
-defined-atoms:
- - name: _foo
- merge: as-weak
- scope: global
- type: data
-...
-
-
-# CHECK: name: _foo
-# CHECK-NOT: merge: as-weak
-# CHECK-NOT: name: _foo
-# CHECK: ...
// This is the entry point to the lld driver. This is a thin wrapper which
// dispatches to the given platform specific driver.
//
-// If there is -flavor option or -core option, it is dispatched according
-// to the arguments. If the flavor parameter is not present, then it is
-// dispatched according to argv[0].
+// If there is -flavor option, it is dispatched according to the arguments.
+// If the flavor parameter is not present, then it is dispatched according
+// to argv[0].
//
//===----------------------------------------------------------------------===//
Gnu, // -flavor gnu
WinLink, // -flavor link
Darwin, // -flavor darwin
- Core // -flavor core or -core
};
LLVM_ATTRIBUTE_NORETURN static void die(const Twine &S) {
.Case("gnu", Gnu)
.Case("link", WinLink)
.Case("darwin", Darwin)
- .Case("core", Core)
.Default(Invalid);
}
}
static Flavor parseFlavor(std::vector<const char *> &V) {
- // If the first argument is -core, then core driver.
- if (V.size() > 1 && V[1] == StringRef("-core")) {
- V.erase(V.begin() + 1);
- return Core;
- }
-
// Parse -flavor option.
if (V.size() > 1 && V[1] == StringRef("-flavor")) {
if (V.size() <= 2)
return !coff::link(Args);
case Darwin:
return !DarwinLdDriver::linkMachO(Args);
- case Core:
- return !CoreDriver::link(Args);
default:
die("-flavor option is missing. Available flavors are "
"gnu, darwin or link.");