2015-08-14 22:12:54 +08:00
|
|
|
//===- Config.h -------------------------------------------------*- C++ -*-===//
|
2015-07-25 05:03:07 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-07-25 05:03:07 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_ELF_CONFIG_H
|
|
|
|
#define LLD_ELF_CONFIG_H
|
|
|
|
|
2018-01-31 17:22:44 +08:00
|
|
|
#include "lld/Common/ErrorHandler.h"
|
2020-06-24 11:00:04 +08:00
|
|
|
#include "llvm/ADT/CachedHashString.h"
|
2015-11-12 17:52:08 +08:00
|
|
|
#include "llvm/ADT/MapVector.h"
|
2020-06-24 11:00:04 +08:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
2015-07-25 05:03:07 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-12-20 02:00:52 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/ELF.h"
|
2017-03-17 10:24:16 +08:00
|
|
|
#include "llvm/Support/CachePruning.h"
|
2017-03-01 07:43:26 +08:00
|
|
|
#include "llvm/Support/CodeGen.h"
|
2017-03-22 05:40:08 +08:00
|
|
|
#include "llvm/Support/Endian.h"
|
[ELF] Add --warn-backrefs-exclude=<glob>
D77522 changed --warn-backrefs to not warn for linking sandwich
problems (-ldef1 -lref -ldef2). This removed lots of false positives.
However, glibc still has some problems. libc.a defines some symbols
which are normally in libm.a and libpthread.a, e.g. __isnanl/raise.
For a linking order `-lm -lpthread -lc`, I have seen:
```
// different resolutions: GNU ld/gold select libc.a(s_isnan.o) as the definition
backward reference detected: __isnanl in libc.a(printf_fp.o) refers to libm.a(m_isnanl.o)
// different resolutions: GNU ld/gold select libc.a(raise.o) as the definition
backward reference detected: raise in libc.a(abort.o) refers to libpthread.a(pt-raise.o)
```
To facilitate deployment of --warn-backrefs, add --warn-backrefs-exclude= so that
certain known issues (which may be impractical to fix) can be whitelisted.
Deliberate choices:
* Not a comma-separated list (`--warn-backrefs-exclude=liba.a,libb.a`).
-Wl, splits the argument at commas, so we cannot use commas.
--export-dynamic-symbol is similar.
* Not in the style of `--warn-backrefs='*' --warn-backrefs=-liba.a`.
We just need exclusion, not inclusion. For easier build system
integration, we should avoid order dependency. With the current
scheme, we enable --warn-backrefs, and indivial libraries can add
--warn-backrefs-exclude=<glob> to their LDFLAGS.
Reviewed By: psmith
Differential Revision: https://reviews.llvm.org/D77512
2020-04-05 12:31:36 +08:00
|
|
|
#include "llvm/Support/GlobPattern.h"
|
2019-02-06 22:43:30 +08:00
|
|
|
#include <atomic>
|
2015-09-28 21:11:36 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
namespace lld {
|
2016-02-28 08:25:54 +08:00
|
|
|
namespace elf {
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-10-12 09:55:32 +08:00
|
|
|
class InputFile;
|
2018-04-18 07:30:05 +08:00
|
|
|
class InputSectionBase;
|
2015-10-10 05:12:40 +08:00
|
|
|
|
2015-10-07 17:13:03 +08:00
|
|
|
enum ELFKind {
|
|
|
|
ELFNoneKind,
|
|
|
|
ELF32LEKind,
|
|
|
|
ELF32BEKind,
|
|
|
|
ELF64LEKind,
|
|
|
|
ELF64BEKind
|
|
|
|
};
|
|
|
|
|
2016-08-31 16:38:11 +08:00
|
|
|
// For --build-id.
|
2016-09-14 19:32:57 +08:00
|
|
|
enum class BuildIdKind { None, Fast, Md5, Sha1, Hexstring, Uuid };
|
2016-04-08 06:49:21 +08:00
|
|
|
|
2017-01-26 05:23:06 +08:00
|
|
|
// For --discard-{all,locals,none}.
|
|
|
|
enum class DiscardPolicy { Default, All, Locals, None };
|
2016-08-31 16:46:30 +08:00
|
|
|
|
2018-07-19 06:49:31 +08:00
|
|
|
// For --icf={none,safe,all}.
|
|
|
|
enum class ICFLevel { None, Safe, All };
|
|
|
|
|
2016-08-31 16:38:11 +08:00
|
|
|
// For --strip-{all,debug}.
|
|
|
|
enum class StripPolicy { None, All, Debug };
|
|
|
|
|
|
|
|
// For --unresolved-symbols.
|
2018-08-14 19:55:31 +08:00
|
|
|
enum class UnresolvedPolicy { ReportError, Warn, Ignore };
|
2016-06-29 20:35:04 +08:00
|
|
|
|
2017-10-25 23:20:30 +08:00
|
|
|
// For --orphan-handling.
|
|
|
|
enum class OrphanHandlingPolicy { Place, Warn, Error };
|
|
|
|
|
2016-09-17 04:21:55 +08:00
|
|
|
// For --sort-section and linkerscript sorting rules.
|
2016-09-17 05:14:55 +08:00
|
|
|
enum class SortSectionPolicy { Default, None, Alignment, Name, Priority };
|
2016-09-17 04:21:55 +08:00
|
|
|
|
2016-10-18 02:12:24 +08:00
|
|
|
// For --target2
|
|
|
|
enum class Target2Policy { Abs, Rel, GotRel };
|
|
|
|
|
2018-07-31 21:41:59 +08:00
|
|
|
// For tracking ARM Float Argument PCS
|
|
|
|
enum class ARMVFPArgKind { Default, Base, VFP, ToolChain };
|
|
|
|
|
2019-09-25 11:39:31 +08:00
|
|
|
// For -z noseparate-code, -z separate-code and -z separate-loadable-segments.
|
|
|
|
enum class SeparateSegmentKind { None, Code, Loadable };
|
|
|
|
|
2019-10-22 01:27:51 +08:00
|
|
|
// For -z *stack
|
|
|
|
enum class GnuStackKind { None, Exec, NoExec };
|
|
|
|
|
2016-07-16 20:26:39 +08:00
|
|
|
struct SymbolVersion {
|
|
|
|
llvm::StringRef name;
|
|
|
|
bool isExternCpp;
|
2016-11-18 14:30:08 +08:00
|
|
|
bool hasWildcard;
|
2016-07-16 20:26:39 +08:00
|
|
|
};
|
|
|
|
|
2016-06-20 19:55:12 +08:00
|
|
|
// This struct contains symbols version definition that
|
|
|
|
// can be found in version script if it is used for link.
|
2016-07-16 12:02:00 +08:00
|
|
|
struct VersionDefinition {
|
2016-06-20 19:55:12 +08:00
|
|
|
llvm::StringRef name;
|
2019-08-05 22:31:39 +08:00
|
|
|
uint16_t id;
|
|
|
|
std::vector<SymbolVersion> patterns;
|
2016-06-20 19:55:12 +08:00
|
|
|
};
|
|
|
|
|
2016-01-06 01:55:05 +08:00
|
|
|
// This struct contains the global configuration for the linker.
|
|
|
|
// Most fields are direct mapping from the command line options
|
|
|
|
// and such fields have the same name as the corresponding options.
|
|
|
|
// Most fields are initialized by the driver.
|
2015-07-25 05:03:07 +08:00
|
|
|
struct Configuration {
|
2016-10-27 22:00:51 +08:00
|
|
|
uint8_t osabi = 0;
|
2019-06-05 11:04:46 +08:00
|
|
|
uint32_t andFeatures = 0;
|
2017-03-17 10:24:16 +08:00
|
|
|
llvm::CachePruningPolicy thinLTOCachePolicy;
|
2020-06-24 11:00:04 +08:00
|
|
|
llvm::SetVector<llvm::CachedHashString> dependencyFiles; // for --dependency-file
|
2016-09-14 21:07:13 +08:00
|
|
|
llvm::StringMap<uint64_t> sectionStartMap;
|
[ELF] Correct error message when OUTPUT_FORMAT is used
Any OUTPUT_FORMAT in a linker script overrides the emulation passed on
the command line, so record the passed bfdname and use that in the error
message about incompatible input files.
This prevents confusing error messages. For example, if you explicitly
pass `-m elf_x86_64` to LLD but accidentally include a linker script
which sets `OUTPUT_FORMAT(elf32-i386)`, LLD would previously complain
about your input files being compatible with elf_x86_64, which isn't the
actual issue, and is confusing because the input files are in fact
x86-64 ELF files.
Interestingly enough, this also prevents a segfault! When we don't pass
`-m` and we have an object file which is incompatible with the
`OUTPUT_FORMAT` set by a linker script, the object file is checked for
compatibility before it's added to the objectFiles vector.
config->emulation, objectFiles, and sharedFiles will all be empty, so
we'll attempt to access bitcodeFiles[0], but bitcodeFiles is also empty,
so we'll segfault. This commit prevents the segfault by adding
OUTPUT_FORMAT as a possible source of machine configuration, and it also
adds an llvm_unreachable to diagnose similar issues in the future.
Differential Revision: https://reviews.llvm.org/D76109
2020-03-13 06:25:36 +08:00
|
|
|
llvm::StringRef bfdname;
|
2017-07-21 02:17:55 +08:00
|
|
|
llvm::StringRef chroot;
|
2020-06-24 11:00:04 +08:00
|
|
|
llvm::StringRef dependencyFile;
|
2020-07-31 16:12:38 +08:00
|
|
|
llvm::StringRef dwoDir;
|
2020-06-24 11:00:04 +08:00
|
|
|
llvm::StringRef dynamicLinker;
|
2015-09-30 06:33:21 +08:00
|
|
|
llvm::StringRef entry;
|
2015-10-11 11:36:49 +08:00
|
|
|
llvm::StringRef emulation;
|
2015-10-08 03:34:51 +08:00
|
|
|
llvm::StringRef fini;
|
|
|
|
llvm::StringRef init;
|
2016-11-26 13:37:04 +08:00
|
|
|
llvm::StringRef ltoAAPipeline;
|
2019-03-12 06:51:38 +08:00
|
|
|
llvm::StringRef ltoCSProfileFile;
|
2016-11-26 13:37:04 +08:00
|
|
|
llvm::StringRef ltoNewPmPasses;
|
2018-05-09 06:37:57 +08:00
|
|
|
llvm::StringRef ltoObjPath;
|
2018-04-10 01:56:07 +08:00
|
|
|
llvm::StringRef ltoSampleProfile;
|
2017-01-14 05:05:46 +08:00
|
|
|
llvm::StringRef mapFile;
|
2015-10-07 08:25:09 +08:00
|
|
|
llvm::StringRef outputFile;
|
2017-02-14 01:49:18 +08:00
|
|
|
llvm::StringRef optRemarksFilename;
|
2020-11-18 02:37:59 +08:00
|
|
|
llvm::Optional<uint64_t> optRemarksHotnessThreshold = 0;
|
2019-03-13 05:22:27 +08:00
|
|
|
llvm::StringRef optRemarksPasses;
|
2019-06-18 00:06:00 +08:00
|
|
|
llvm::StringRef optRemarksFormat;
|
2018-02-07 06:37:05 +08:00
|
|
|
llvm::StringRef progName;
|
2020-04-28 10:30:09 +08:00
|
|
|
llvm::StringRef printArchiveStats;
|
2019-03-28 07:52:22 +08:00
|
|
|
llvm::StringRef printSymbolOrder;
|
2015-10-02 03:36:04 +08:00
|
|
|
llvm::StringRef soName;
|
2015-09-30 06:33:21 +08:00
|
|
|
llvm::StringRef sysroot;
|
2017-03-02 07:00:10 +08:00
|
|
|
llvm::StringRef thinLTOCacheDir;
|
2018-05-08 07:24:16 +08:00
|
|
|
llvm::StringRef thinLTOIndexOnlyArg;
|
2020-04-07 21:48:18 +08:00
|
|
|
llvm::StringRef ltoBasicBlockSections;
|
2018-05-17 05:04:08 +08:00
|
|
|
std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
|
2018-05-08 01:59:43 +08:00
|
|
|
std::pair<llvm::StringRef, llvm::StringRef> thinLTOPrefixReplace;
|
2017-04-30 07:06:43 +08:00
|
|
|
std::string rpath;
|
2016-07-16 12:09:27 +08:00
|
|
|
std::vector<VersionDefinition> versionDefinitions;
|
2016-09-02 17:13:05 +08:00
|
|
|
std::vector<llvm::StringRef> auxiliaryList;
|
2017-07-17 17:43:18 +08:00
|
|
|
std::vector<llvm::StringRef> filterList;
|
2015-10-11 11:28:42 +08:00
|
|
|
std::vector<llvm::StringRef> searchPaths;
|
2016-12-20 09:51:08 +08:00
|
|
|
std::vector<llvm::StringRef> symbolOrderingFile;
|
2020-05-22 04:19:44 +08:00
|
|
|
std::vector<llvm::StringRef> thinLTOModulesToCompile;
|
2015-10-20 01:35:12 +08:00
|
|
|
std::vector<llvm::StringRef> undefined;
|
2017-09-09 02:16:59 +08:00
|
|
|
std::vector<SymbolVersion> dynamicList;
|
2016-05-14 05:55:56 +08:00
|
|
|
std::vector<uint8_t> buildIdVector;
|
2018-04-18 07:30:05 +08:00
|
|
|
llvm::MapVector<std::pair<const InputSectionBase *, const InputSectionBase *>,
|
|
|
|
uint64_t>
|
|
|
|
callGraphProfile;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool allowMultipleDefinition;
|
2018-07-10 04:22:28 +08:00
|
|
|
bool androidPackDynRelocs;
|
2017-11-28 21:51:48 +08:00
|
|
|
bool armHasBlx = false;
|
|
|
|
bool armHasMovtMovw = false;
|
|
|
|
bool armJ1J2BranchEncoding = false;
|
2015-10-12 04:59:12 +08:00
|
|
|
bool asNeeded = false;
|
2021-05-15 00:40:32 +08:00
|
|
|
bool bsymbolic = false;
|
|
|
|
bool bsymbolicFunctions = false;
|
2018-10-26 07:15:23 +08:00
|
|
|
bool callGraphProfileSort;
|
2018-02-03 06:24:06 +08:00
|
|
|
bool checkSections;
|
2017-04-17 16:58:12 +08:00
|
|
|
bool compressDebugSections;
|
2018-03-15 04:29:45 +08:00
|
|
|
bool cref;
|
2020-07-09 01:10:43 +08:00
|
|
|
std::vector<std::pair<llvm::GlobPattern, uint64_t>> deadRelocInNonAlloc;
|
2017-01-24 11:41:20 +08:00
|
|
|
bool defineCommon;
|
2016-01-14 02:55:39 +08:00
|
|
|
bool demangle = true;
|
[ELF] Implement Dependent Libraries Feature
This patch implements a limited form of autolinking primarily designed to allow
either the --dependent-library compiler option, or "comment lib" pragmas (
https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=vs-2017) in
C/C++ e.g. #pragma comment(lib, "foo"), to cause an ELF linker to automatically
add the specified library to the link when processing the input file generated
by the compiler.
Currently this extension is unique to LLVM and LLD. However, care has been taken
to design this feature so that it could be supported by other ELF linkers.
The design goals were to provide:
- A simple linking model for developers to reason about.
- The ability to to override autolinking from the linker command line.
- Source code compatibility, where possible, with "comment lib" pragmas in other
environments (MSVC in particular).
Dependent library support is implemented differently for ELF platforms than on
the other platforms. Primarily this difference is that on ELF we pass the
dependent library specifiers directly to the linker without manipulating them.
This is in contrast to other platforms where they are mapped to a specific
linker option by the compiler. This difference is a result of the greater
variety of ELF linkers and the fact that ELF linkers tend to handle libraries in
a more complicated fashion than on other platforms. This forces us to defer
handling the specifiers to the linker.
In order to achieve a level of source code compatibility with other platforms
we have restricted this feature to work with libraries that meet the following
"reasonable" requirements:
1. There are no competing defined symbols in a given set of libraries, or
if they exist, the program owner doesn't care which is linked to their
program.
2. There may be circular dependencies between libraries.
The binary representation is a mergeable string section (SHF_MERGE,
SHF_STRINGS), called .deplibs, with custom type SHT_LLVM_DEPENDENT_LIBRARIES
(0x6fff4c04). The compiler forms this section by concatenating the arguments of
the "comment lib" pragmas and --dependent-library options in the order they are
encountered. Partial (-r, -Ur) links are handled by concatenating .deplibs
sections with the normal mergeable string section rules. As an example, #pragma
comment(lib, "foo") would result in:
.section ".deplibs","MS",@llvm_dependent_libraries,1
.asciz "foo"
For LTO, equivalent information to the contents of a the .deplibs section can be
retrieved by the LLD for bitcode input files.
LLD processes the dependent library specifiers in the following way:
1. Dependent libraries which are found from the specifiers in .deplibs sections
of relocatable object files are added when the linker decides to include that
file (which could itself be in a library) in the link. Dependent libraries
behave as if they were appended to the command line after all other options. As
a consequence the set of dependent libraries are searched last to resolve
symbols.
2. It is an error if a file cannot be found for a given specifier.
3. Any command line options in effect at the end of the command line parsing apply
to the dependent libraries, e.g. --whole-archive.
4. The linker tries to add a library or relocatable object file from each of the
strings in a .deplibs section by; first, handling the string as if it was
specified on the command line; second, by looking for the string in each of the
library search paths in turn; third, by looking for a lib<string>.a or
lib<string>.so (depending on the current mode of the linker) in each of the
library search paths.
5. A new command line option --no-dependent-libraries tells LLD to ignore the
dependent libraries.
Rationale for the above points:
1. Adding the dependent libraries last makes the process simple to understand
from a developers perspective. All linkers are able to implement this scheme.
2. Error-ing for libraries that are not found seems like better behavior than
failing the link during symbol resolution.
3. It seems useful for the user to be able to apply command line options which
will affect all of the dependent libraries. There is a potential problem of
surprise for developers, who might not realize that these options would apply
to these "invisible" input files; however, despite the potential for surprise,
this is easy for developers to reason about and gives developers the control
that they may require.
4. This algorithm takes into account all of the different ways that ELF linkers
find input files. The different search methods are tried by the linker in most
obvious to least obvious order.
5. I considered adding finer grained control over which dependent libraries were
ignored (e.g. MSVC has /nodefaultlib:<library>); however, I concluded that this
is not necessary: if finer control is required developers can fall back to using
the command line directly.
RFC thread: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.
Differential Revision: https://reviews.llvm.org/D60274
llvm-svn: 360984
2019-05-17 11:44:15 +08:00
|
|
|
bool dependentLibraries;
|
2016-04-03 11:39:09 +08:00
|
|
|
bool disableVerify;
|
2016-01-15 21:34:52 +08:00
|
|
|
bool ehFrameHdr;
|
2018-12-15 05:58:49 +08:00
|
|
|
bool emitLLVM;
|
2017-02-09 00:18:10 +08:00
|
|
|
bool emitRelocs;
|
2015-10-07 04:02:15 +08:00
|
|
|
bool enableNewDtags;
|
[AArch64] Support execute-only LOAD segments.
Summary:
This adds an LLD flag to mark executable LOAD segments execute-only for AArch64 targets.
In AArch64 the expectation is that code is execute-only compatible, so this just adds a linker option to enforce this.
Patch by: ivanlozano (Ivan Lozano)
Reviewers: srhines, echristo, peter.smith, eugenis, javed.absar, espindola, ruiu
Reviewed By: ruiu
Subscribers: dokyungs, emaste, arichardson, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D49456
llvm-svn: 338271
2018-07-31 01:02:46 +08:00
|
|
|
bool executeOnly;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool exportDynamic;
|
2017-12-05 23:59:05 +08:00
|
|
|
bool fixCortexA53Errata843419;
|
2019-09-16 17:38:38 +08:00
|
|
|
bool fixCortexA8;
|
2018-08-07 05:29:41 +08:00
|
|
|
bool formatBinary = false;
|
2020-12-07 22:28:17 +08:00
|
|
|
bool fortranCommon;
|
ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.
In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.
This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.
It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.
http://reviews.llvm.org/D13950
llvm-svn: 251043
2015-10-23 02:49:53 +08:00
|
|
|
bool gcSections;
|
2016-10-20 17:19:48 +08:00
|
|
|
bool gdbIndex;
|
2017-10-06 17:37:44 +08:00
|
|
|
bool gnuHash = false;
|
2018-02-03 05:44:06 +08:00
|
|
|
bool gnuUnique;
|
2017-09-16 02:05:02 +08:00
|
|
|
bool hasDynSymTab;
|
2018-01-10 09:37:36 +08:00
|
|
|
bool ignoreDataAddressEquality;
|
|
|
|
bool ignoreFunctionAddressEquality;
|
2019-03-12 06:51:38 +08:00
|
|
|
bool ltoCSProfileGenerate;
|
2018-04-10 01:56:07 +08:00
|
|
|
bool ltoDebugPassManager;
|
[lld] Support --lto-emit-asm and --plugin-opt=emit-asm
Summary: The switch --plugin-opt=emit-asm can be used with the gold linker to dump the final assembly code generated by LTO in a user-friendly way. Unfortunately it doesn't work with lld. I'm hooking it up with lld. With that switch, lld emits assembly code into the output file (specified by -o) and if there are multiple input files, each of their assembly code will be emitted into a separate file named by suffixing the output file name with a unique number, respectively. The linking then stops after generating those assembly files.
Reviewers: espindola, wenlei, tejohnson, MaskRay, grimar
Reviewed By: tejohnson, MaskRay, grimar
Subscribers: pcc, emaste, inglorion, arichardson, hiraditya, MaskRay, steven_wu, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77231
2020-04-02 01:01:23 +08:00
|
|
|
bool ltoEmitAsm;
|
2018-04-10 01:56:07 +08:00
|
|
|
bool ltoNewPassManager;
|
2021-01-21 01:24:43 +08:00
|
|
|
bool ltoPseudoProbeForProfiling;
|
2020-06-02 14:17:29 +08:00
|
|
|
bool ltoUniqueBasicBlockSectionNames;
|
2020-01-25 04:24:18 +08:00
|
|
|
bool ltoWholeProgramVisibility;
|
2017-12-15 19:09:41 +08:00
|
|
|
bool mergeArmExidx;
|
2016-11-06 06:58:01 +08:00
|
|
|
bool mipsN32Abi = false;
|
[LLD][ELF] Support --[no-]mmap-output-file with F_no_mmap
Summary:
Add a flag `F_no_mmap` to `FileOutputBuffer` to support
`--[no-]mmap-output-file` in ELF LLD. LLD currently explicitly ignores
this flag for compatibility with GNU ld and gold.
We need this flag to speed up link time for large binaries in certain
scenarios. When we link some of our larger binaries we find that LLD
takes 50+ GB of memory, which causes memory pressure. The memory
pressure causes the VM to flush dirty pages of the output file to disk.
This is normally okay, since we should be flushing cold pages. However,
when using BtrFS with compression we need to write 128KB at a time when
we flush a page. If any page in that 128KB block is written again, then
it must be flushed a second time, and so on. Since LLD doesn't write
sequentially this causes write amplification. The same 128KB block will
end up being flushed multiple times, causing the linker to many times
more IO than necessary. We've observed 3-5x faster builds with
-no-mmap-output-file when we hit this scenario.
The bad scenario only applies to compressed filesystems, which group
together multiple pages into a single compressed block. I've tested
BtrFS, but the problem will be present for any compressed filesystem
on Linux, since it is caused by the VM.
Silently ignoring --no-mmap-output-file caused a silent regression when
we switched from gold to lld. We pass --no-mmap-output-file to fix this
edge case, but since lld silently ignored the flag we didn't realize it
wasn't being respected.
Benchmark building a 9 GB binary that exposes this edge case. I linked 3
times with --mmap-output-file and 3 times with --no-mmap-output-file and
took the average. The machine has 24 cores @ 2.4 GHz, 112 GB of RAM,
BtrFS mounted with -compress-force=zstd, and an 80% full disk.
| Mode | Time |
|---------|-------|
| mmap | 894 s |
| no mmap | 126 s |
When compression is disabled, BtrFS performs just as well with and
without mmap on this benchmark.
I was unable to reproduce the regression with any binaries in
lld-speed-test.
Reviewed By: ruiu, MaskRay
Differential Revision: https://reviews.llvm.org/D69294
2019-10-30 06:46:22 +08:00
|
|
|
bool mmapOutputFile;
|
2019-05-14 00:01:26 +08:00
|
|
|
bool nmagic;
|
2020-01-24 03:52:03 +08:00
|
|
|
bool noDynamicLinker = false;
|
2017-07-27 15:48:36 +08:00
|
|
|
bool noinhibitExec;
|
2016-09-03 03:20:33 +08:00
|
|
|
bool nostdlib;
|
2016-08-25 17:05:47 +08:00
|
|
|
bool oFormatBinary;
|
2017-02-25 09:52:03 +08:00
|
|
|
bool omagic;
|
2021-02-09 02:34:57 +08:00
|
|
|
bool optEB = false;
|
|
|
|
bool optEL = false;
|
2020-04-07 21:48:18 +08:00
|
|
|
bool optimizeBBJumps;
|
2017-02-14 01:49:18 +08:00
|
|
|
bool optRemarksWithHotness;
|
2019-01-16 20:09:13 +08:00
|
|
|
bool picThunk;
|
2016-03-17 13:57:33 +08:00
|
|
|
bool pie;
|
2015-12-10 17:12:18 +08:00
|
|
|
bool printGcSections;
|
2018-02-02 00:00:46 +08:00
|
|
|
bool printIcfSections;
|
2016-02-25 16:23:37 +08:00
|
|
|
bool relocatable;
|
2018-07-10 04:22:28 +08:00
|
|
|
bool relrPackDynRelocs;
|
2016-03-10 04:01:08 +08:00
|
|
|
bool saveTemps;
|
2021-03-19 01:18:19 +08:00
|
|
|
std::vector<std::pair<llvm::GlobPattern, uint32_t>> shuffleSections;
|
2016-11-28 18:05:20 +08:00
|
|
|
bool singleRoRx;
|
2015-10-01 01:26:13 +08:00
|
|
|
bool shared;
|
2020-06-02 02:27:53 +08:00
|
|
|
bool symbolic;
|
2015-10-02 00:42:03 +08:00
|
|
|
bool isStatic = false;
|
2017-10-06 17:37:44 +08:00
|
|
|
bool sysvHash = false;
|
2016-08-02 03:28:13 +08:00
|
|
|
bool target1Rel;
|
2016-03-29 16:45:40 +08:00
|
|
|
bool trace;
|
2018-05-08 07:14:12 +08:00
|
|
|
bool thinLTOEmitImportsFiles;
|
2018-05-03 05:40:07 +08:00
|
|
|
bool thinLTOIndexOnly;
|
2020-01-29 00:05:13 +08:00
|
|
|
bool timeTraceEnabled;
|
2018-09-20 08:26:44 +08:00
|
|
|
bool tocOptimize;
|
2020-08-17 22:30:14 +08:00
|
|
|
bool pcRelOptimize;
|
2018-02-03 05:44:06 +08:00
|
|
|
bool undefinedVersion;
|
[LLD] Add support for --unique option
Summary:
Places orphan sections into a unique output section. This prevents the merging of orphan sections of the same name.
Matches behaviour of GNU ld --unique. --unique=pattern is not implemented.
Motivated user case shown in the test has 2 local symbols as they would appear if C++ source has been compiled with -ffunction-sections. The merging of these sections in the case of a partial link (-r) may limit the effectiveness of -gc-sections of a subsequent link.
Reviewers: espindola, jhenderson, bd1976llvm, edd, andrewng, JonChesterfield, MaskRay, grimar, ruiu, psmith
Reviewed By: MaskRay, grimar
Subscribers: emaste, arichardson, MaskRay, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D75536
2020-03-09 23:43:20 +08:00
|
|
|
bool unique;
|
2018-07-10 04:08:55 +08:00
|
|
|
bool useAndroidRelrTags = false;
|
Add --warn-backrefs to maintain compatibility with other linkers
I'm proposing a new command line flag, --warn-backrefs in this patch.
The flag and the feature proposed below don't exist in GNU linkers
nor the current lld.
--warn-backrefs is an option to detect reverse or cyclic dependencies
between static archives, and it can be used to keep your program
compatible with GNU linkers after you switch to lld. I'll explain the
feature and why you may find it useful below.
lld's symbol resolution semantics is more relaxed than traditional
Unix linkers. Therefore,
ld.lld foo.a bar.o
succeeds even if bar.o contains an undefined symbol that have to be
resolved by some object file in foo.a. Traditional Unix linkers
don't allow this kind of backward reference, as they visit each
file only once from left to right in the command line while
resolving all undefined symbol at the moment of visiting.
In the above case, since there's no undefined symbol when a linker
visits foo.a, no files are pulled out from foo.a, and because the
linker forgets about foo.a after visiting, it can't resolve
undefined symbols that could have been resolved otherwise.
That lld accepts more relaxed form means (besides it makes more
sense) that you can accidentally write a command line or a build
file that works only with lld, even if you have a plan to
distribute it to wider users who may be using GNU linkers. With
--check-library-dependency, you can detect a library order that
doesn't work with other Unix linkers.
The option is also useful to detect cyclic dependencies between
static archives. Again, lld accepts
ld.lld foo.a bar.a
even if foo.a and bar.a depend on each other. With --warn-backrefs
it is handled as an error.
Here is how the option works. We assign a group ID to each file. A
file with a smaller group ID can pull out object files from an
archive file with an equal or greater group ID. Otherwise, it is a
reverse dependency and an error.
A file outside --{start,end}-group gets a fresh ID when
instantiated. All files within the same --{start,end}-group get the
same group ID. E.g.
ld.lld A B --start-group C D --end-group E
A and B form group 0, C, D and their member object files form group
1, and E forms group 2. I think that you can see how this group
assignment rule simulates the traditional linker's semantics.
Differential Revision: https://reviews.llvm.org/D45195
llvm-svn: 329636
2018-04-10 07:05:48 +08:00
|
|
|
bool warnBackrefs;
|
[ELF] Add --warn-backrefs-exclude=<glob>
D77522 changed --warn-backrefs to not warn for linking sandwich
problems (-ldef1 -lref -ldef2). This removed lots of false positives.
However, glibc still has some problems. libc.a defines some symbols
which are normally in libm.a and libpthread.a, e.g. __isnanl/raise.
For a linking order `-lm -lpthread -lc`, I have seen:
```
// different resolutions: GNU ld/gold select libc.a(s_isnan.o) as the definition
backward reference detected: __isnanl in libc.a(printf_fp.o) refers to libm.a(m_isnanl.o)
// different resolutions: GNU ld/gold select libc.a(raise.o) as the definition
backward reference detected: raise in libc.a(abort.o) refers to libpthread.a(pt-raise.o)
```
To facilitate deployment of --warn-backrefs, add --warn-backrefs-exclude= so that
certain known issues (which may be impractical to fix) can be whitelisted.
Deliberate choices:
* Not a comma-separated list (`--warn-backrefs-exclude=liba.a,libb.a`).
-Wl, splits the argument at commas, so we cannot use commas.
--export-dynamic-symbol is similar.
* Not in the style of `--warn-backrefs='*' --warn-backrefs=-liba.a`.
We just need exclusion, not inclusion. For easier build system
integration, we should avoid order dependency. With the current
scheme, we enable --warn-backrefs, and indivial libraries can add
--warn-backrefs-exclude=<glob> to their LDFLAGS.
Reviewed By: psmith
Differential Revision: https://reviews.llvm.org/D77512
2020-04-05 12:31:36 +08:00
|
|
|
std::vector<llvm::GlobPattern> warnBackrefsExclude;
|
2016-03-14 17:19:30 +08:00
|
|
|
bool warnCommon;
|
2016-12-07 12:06:21 +08:00
|
|
|
bool warnMissingEntry;
|
2018-02-14 21:36:22 +08:00
|
|
|
bool warnSymbolOrdering;
|
2018-02-06 04:55:46 +08:00
|
|
|
bool writeAddends;
|
2016-05-10 23:47:57 +08:00
|
|
|
bool zCombreloc;
|
2018-04-21 05:24:08 +08:00
|
|
|
bool zCopyreloc;
|
2020-02-14 12:57:03 +08:00
|
|
|
bool zForceBti;
|
2019-12-11 10:05:36 +08:00
|
|
|
bool zForceIbt;
|
2018-08-28 16:24:34 +08:00
|
|
|
bool zGlobal;
|
2018-02-21 07:49:17 +08:00
|
|
|
bool zHazardplt;
|
2019-05-14 23:25:21 +08:00
|
|
|
bool zIfuncNoplt;
|
2018-06-20 10:06:01 +08:00
|
|
|
bool zInitfirst;
|
2018-09-14 22:25:37 +08:00
|
|
|
bool zInterpose;
|
2018-05-09 07:19:50 +08:00
|
|
|
bool zKeepTextSectionPrefix;
|
2018-11-27 17:48:17 +08:00
|
|
|
bool zNodefaultlib;
|
2015-11-21 05:00:42 +08:00
|
|
|
bool zNodelete;
|
2017-03-23 08:54:16 +08:00
|
|
|
bool zNodlopen;
|
2015-11-21 05:00:42 +08:00
|
|
|
bool zNow;
|
|
|
|
bool zOrigin;
|
2020-02-14 12:57:03 +08:00
|
|
|
bool zPacPlt;
|
2015-11-24 18:15:50 +08:00
|
|
|
bool zRelro;
|
2017-05-27 03:12:38 +08:00
|
|
|
bool zRodynamic;
|
2019-12-11 10:05:36 +08:00
|
|
|
bool zShstk;
|
2021-02-26 07:46:37 +08:00
|
|
|
bool zStartStopGC;
|
2020-06-18 05:10:02 +08:00
|
|
|
uint8_t zStartStopVisibility;
|
2017-03-09 16:48:34 +08:00
|
|
|
bool zText;
|
Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to Spectre..
Summary:
First, we need to explain the core of the vulnerability. Note that this
is a very incomplete description, please see the Project Zero blog post
for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html
The basis for branch target injection is to direct speculative execution
of the processor to some "gadget" of executable code by poisoning the
prediction of indirect branches with the address of that gadget. The
gadget in turn contains an operation that provides a side channel for
reading data. Most commonly, this will look like a load of secret data
followed by a branch on the loaded value and then a load of some
predictable cache line. The attacker then uses timing of the processors
cache to determine which direction the branch took *in the speculative
execution*, and in turn what one bit of the loaded value was. Due to the
nature of these timing side channels and the branch predictor on Intel
processors, this allows an attacker to leak data only accessible to
a privileged domain (like the kernel) back into an unprivileged domain.
The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In many
cases, the compiler can simply use directed conditional branches and
a small search tree. LLVM already has support for lowering switches in
this way and the first step of this patch is to disable jump-table
lowering of switches and introduce a pass to rewrite explicit indirectbr
sequences into a switch over integers.
However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as
a trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures the
processor predicts the return to go to a controlled, known location. The
retpoline then "smashes" the return address pushed onto the stack by the
call with the desired target of the original indirect call. The result
is a predicted return to the next instruction after a call (which can be
used to trap speculative execution within an infinite loop) and an
actual indirect branch to an arbitrary address.
On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this device.
For 32-bit ABIs there isn't a guaranteed scratch register and so several
different retpoline variants are introduced to use a scratch register if
one is available in the calling convention and to otherwise use direct
stack push/pop sequences to pass the target address.
This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886
We also support a target feature that disables emission of the retpoline
thunk by the compiler to allow for custom thunks if users want them.
These are particularly useful in environments like kernels that
routinely do hot-patching on boot and want to hot-patch their thunk to
different code sequences. They can write this custom thunk and use
`-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.
There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.
The only other indirect branches remaining that we are aware of are from
precompiled runtimes (such as crt0.o and similar). The ones we have
found are not really attackable, and so we have not focused on them
here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.
For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z retpolineplt`
(or use similar functionality from some other linker). We strongly
recommend also using `-z now` as non-lazy binding allows the
retpoline-mitigated PLT to be substantially smaller.
When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typical workloads, and relatively minor hits (approximately 2%)
even for extremely syscall-heavy applications. This is largely due to
the small number of indirect branches that occur in performance
sensitive paths of the kernel.
When using these patches on statically linked applications, especially
C++ applications, you should expect to see a much more dramatic
performance hit. For microbenchmarks that are switch, indirect-, or
virtual-call heavy we have seen overheads ranging from 10% to 50%.
However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically reduce
the impact of hot indirect calls (by speculatively promoting them to
direct calls) and allow optimized search trees to be used to lower
switches. If you need to deploy these techniques in C++ applications, we
*strongly* recommend that you ensure all hot call targets are statically
linked (avoiding PLT indirection) and use both PGO and ThinLTO. Well
tuned servers using all of these techniques saw 5% - 10% overhead from
the use of retpoline.
We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality available
as soon as possible. Happy for more code review, but we'd really like to
get these patches landed and backported ASAP for obvious reasons. We're
planning to backport this to both 6.0 and 5.0 release streams and get
a 5.0 release with just this cherry picked ASAP for distros and vendors.
This patch is the work of a number of people over the past month: Eric, Reid,
Rui, and myself. I'm mailing it out as a single commit due to the time
sensitive nature of landing this and the need to backport it. Huge thanks to
everyone who helped out here, and everyone at Intel who helped out in
discussions about how to craft this. Also, credit goes to Paul Turner (at
Google, but not an LLVM contributor) for much of the underlying retpoline
design.
Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer
Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D41723
llvm-svn: 323155
2018-01-23 06:05:25 +08:00
|
|
|
bool zRetpolineplt;
|
2016-10-14 18:34:36 +08:00
|
|
|
bool zWxneeded;
|
2016-08-31 16:46:30 +08:00
|
|
|
DiscardPolicy discard;
|
2019-10-22 01:27:51 +08:00
|
|
|
GnuStackKind zGnustack;
|
2018-07-19 06:49:31 +08:00
|
|
|
ICFLevel icf;
|
2017-10-25 23:20:30 +08:00
|
|
|
OrphanHandlingPolicy orphanHandling;
|
2016-09-17 04:21:55 +08:00
|
|
|
SortSectionPolicy sortSection;
|
2017-02-25 10:12:37 +08:00
|
|
|
StripPolicy strip;
|
2016-06-29 20:35:04 +08:00
|
|
|
UnresolvedPolicy unresolvedSymbols;
|
2020-11-18 04:20:57 +08:00
|
|
|
UnresolvedPolicy unresolvedSymbolsInShlib;
|
2017-02-25 10:27:58 +08:00
|
|
|
Target2Policy target2;
|
2021-03-05 02:17:40 +08:00
|
|
|
bool Power10Stub;
|
2018-07-31 21:41:59 +08:00
|
|
|
ARMVFPArgKind armVFPArgs = ARMVFPArgKind::Default;
|
2016-04-08 06:49:21 +08:00
|
|
|
BuildIdKind buildId = BuildIdKind::None;
|
2019-09-25 11:39:31 +08:00
|
|
|
SeparateSegmentKind zSeparate;
|
2015-10-14 00:20:50 +08:00
|
|
|
ELFKind ekind = ELFNoneKind;
|
2015-10-07 17:13:03 +08:00
|
|
|
uint16_t emachine = llvm::ELF::EM_NONE;
|
2017-10-10 18:09:35 +08:00
|
|
|
llvm::Optional<uint64_t> imageBase;
|
2019-05-14 00:01:26 +08:00
|
|
|
uint64_t commonPageSize;
|
2016-09-28 23:20:47 +08:00
|
|
|
uint64_t maxPageSize;
|
2018-06-11 15:24:31 +08:00
|
|
|
uint64_t mipsGotSize;
|
2016-09-28 23:20:47 +08:00
|
|
|
uint64_t zStackSize;
|
2016-11-26 13:37:04 +08:00
|
|
|
unsigned ltoPartitions;
|
|
|
|
unsigned ltoo;
|
2016-04-01 05:15:31 +08:00
|
|
|
unsigned optimize;
|
2020-03-27 22:20:39 +08:00
|
|
|
StringRef thinLTOJobs;
|
2020-01-29 00:05:13 +08:00
|
|
|
unsigned timeTraceGranularity;
|
2018-10-17 01:13:01 +08:00
|
|
|
int32_t splitStackAdjustSize;
|
2017-02-14 13:45:47 +08:00
|
|
|
|
2017-03-18 07:29:01 +08:00
|
|
|
// The following config options do not directly correspond to any
|
2019-10-29 09:41:38 +08:00
|
|
|
// particular command line options.
|
2017-03-15 17:12:56 +08:00
|
|
|
|
2017-03-18 07:29:01 +08:00
|
|
|
// True if we need to pass through relocations in input files to the
|
|
|
|
// output file. Usually false because we consume relocations.
|
|
|
|
bool copyRelocs;
|
2017-03-18 07:28:41 +08:00
|
|
|
|
2017-03-22 08:01:11 +08:00
|
|
|
// True if the target is ELF64. False if ELF32.
|
|
|
|
bool is64;
|
|
|
|
|
|
|
|
// True if the target is little-endian. False if big-endian.
|
2017-03-18 07:29:01 +08:00
|
|
|
bool isLE;
|
|
|
|
|
2019-07-16 13:50:45 +08:00
|
|
|
// endianness::little if isLE is true. endianness::big otherwise.
|
2017-03-22 05:40:08 +08:00
|
|
|
llvm::support::endianness endianness;
|
|
|
|
|
2017-03-18 07:29:01 +08:00
|
|
|
// True if the target is the little-endian MIPS64.
|
|
|
|
//
|
|
|
|
// The reason why we have this variable only for the MIPS is because
|
|
|
|
// we use this often. Some ELF headers for MIPS64EL are in a
|
|
|
|
// mixed-endian (which is horrible and I'd say that's a serious spec
|
|
|
|
// bug), and we need to know whether we are reading MIPS ELF files or
|
|
|
|
// not in various places.
|
|
|
|
//
|
|
|
|
// (Note that MIPS64EL is not a typo for MIPS64LE. This is the official
|
|
|
|
// name whatever that means. A fun hypothesis is that "EL" is short for
|
|
|
|
// little-endian written in the little-endian order, but I don't know
|
|
|
|
// if that's true.)
|
|
|
|
bool isMips64EL;
|
2017-03-18 07:28:41 +08:00
|
|
|
|
2019-02-07 02:53:17 +08:00
|
|
|
// True if we need to set the DF_STATIC_TLS flag to an output file,
|
|
|
|
// which works as a hint to the dynamic loader that the file contains
|
|
|
|
// code compiled with the static TLS model. The thread-local variable
|
|
|
|
// compiled with the static TLS model is faster but less flexible, and
|
|
|
|
// it may not be loaded using dlopen().
|
|
|
|
//
|
|
|
|
// We set this flag to true when we see a relocation for the static TLS
|
|
|
|
// model. Once this becomes true, it will never become false.
|
|
|
|
//
|
|
|
|
// Since the flag is updated by multi-threaded code, we use std::atomic.
|
|
|
|
// (Writing to a variable is not considered thread-safe even if the
|
2019-02-07 04:36:02 +08:00
|
|
|
// variable is boolean and we always set the same value from all threads.)
|
2019-02-07 02:53:17 +08:00
|
|
|
std::atomic<bool> hasStaticTlsModel{false};
|
|
|
|
|
2017-10-25 01:01:40 +08:00
|
|
|
// Holds set of ELF header flags for the target.
|
|
|
|
uint32_t eflags = 0;
|
2017-10-02 22:56:41 +08:00
|
|
|
|
2017-03-07 08:43:53 +08:00
|
|
|
// The ELF spec defines two types of relocation table entries, RELA and
|
|
|
|
// REL. RELA is a triplet of (offset, info, addend) while REL is a
|
|
|
|
// tuple of (offset, info). Addends for REL are implicit and read from
|
|
|
|
// the location where the relocations are applied. So, REL is more
|
|
|
|
// compact than RELA but requires a bit of more work to process.
|
|
|
|
//
|
|
|
|
// (From the linker writer's view, this distinction is not necessary.
|
|
|
|
// If the ELF had chosen whichever and sticked with it, it would have
|
|
|
|
// been easier to write code to process relocations, but it's too late
|
|
|
|
// to change the spec.)
|
|
|
|
//
|
2017-03-18 07:29:01 +08:00
|
|
|
// Each ABI defines its relocation type. IsRela is true if target
|
|
|
|
// uses RELA. As far as we know, all 64-bit ABIs are using RELA. A
|
|
|
|
// few 32-bit ABIs are using RELA too.
|
|
|
|
bool isRela;
|
|
|
|
|
|
|
|
// True if we are creating position-independent code.
|
|
|
|
bool isPic;
|
|
|
|
|
|
|
|
// 4 for ELF32, 8 for ELF64.
|
|
|
|
int wordsize;
|
2015-07-25 05:03:07 +08:00
|
|
|
};
|
|
|
|
|
2016-01-06 01:55:05 +08:00
|
|
|
// The only instance of Configuration struct.
|
2015-07-25 05:03:07 +08:00
|
|
|
extern Configuration *config;
|
|
|
|
|
2019-08-05 22:31:39 +08:00
|
|
|
// The first two elements of versionDefinitions represent VER_NDX_LOCAL and
|
|
|
|
// VER_NDX_GLOBAL. This helper returns other elements.
|
|
|
|
static inline ArrayRef<VersionDefinition> namedVersionDefs() {
|
|
|
|
return llvm::makeArrayRef(config->versionDefinitions).slice(2);
|
|
|
|
}
|
|
|
|
|
2018-01-31 17:22:44 +08:00
|
|
|
static inline void errorOrWarn(const Twine &msg) {
|
|
|
|
if (!config->noinhibitExec)
|
|
|
|
error(msg);
|
|
|
|
else
|
|
|
|
warn(msg);
|
|
|
|
}
|
2016-02-28 08:25:54 +08:00
|
|
|
} // namespace elf
|
2015-07-25 05:03:07 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|