2017-11-18 02:14:09 +08:00
|
|
|
//===- Config.h -------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
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
|
2017-11-18 02:14:09 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_CONFIG_H
|
|
|
|
#define LLD_WASM_CONFIG_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-11-30 06:21:37 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "llvm/BinaryFormat/Wasm.h"
|
2018-05-31 02:07:52 +08:00
|
|
|
#include "llvm/Support/CachePruning.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
2020-05-02 00:14:59 +08:00
|
|
|
// For --unresolved-symbols.
|
|
|
|
// The `ImportFuncs` mode is an additional mode that corresponds to the
|
|
|
|
// --allow-undefined flag which turns undefined functions in imports
|
|
|
|
// as opposed ed to Ignore or Warn which turn them into unreachables.
|
|
|
|
enum class UnresolvedPolicy { ReportError, Warn, Ignore, ImportFuncs };
|
|
|
|
|
2019-05-09 00:20: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.
|
2017-11-18 02:14:09 +08:00
|
|
|
struct Configuration {
|
2020-10-08 05:48:37 +08:00
|
|
|
bool bsymbolic;
|
2019-03-26 12:11:05 +08:00
|
|
|
bool checkFeatures;
|
2018-09-27 08:46:54 +08:00
|
|
|
bool compressRelocations;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool demangle;
|
2018-05-31 02:07:52 +08:00
|
|
|
bool disableVerify;
|
2020-06-13 03:05:40 +08:00
|
|
|
bool experimentalPic;
|
2019-05-24 21:28:27 +08:00
|
|
|
bool emitRelocs;
|
2018-06-07 09:27:07 +08:00
|
|
|
bool exportAll;
|
2018-09-28 05:06:25 +08:00
|
|
|
bool exportDynamic;
|
2018-03-28 20:53:29 +08:00
|
|
|
bool exportTable;
|
2019-08-28 06:58:21 +08:00
|
|
|
bool growableTable;
|
2018-01-31 09:45:47 +08:00
|
|
|
bool gcSections;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool importMemory;
|
2018-11-07 01:59:32 +08:00
|
|
|
bool sharedMemory;
|
2018-03-28 20:53:29 +08:00
|
|
|
bool importTable;
|
2020-07-07 04:34:16 +08:00
|
|
|
llvm::Optional<bool> is64;
|
[WebAssembly] Add a flag to control merging data segments
Merging data segments produces smaller code sizes because each segment
has some boilerplate. Therefore, merging data segments is generally the
right approach, especially with wasm where binaries are typically
delivered over the network.
However, when analyzing wasm binaries, it can be helpful to get a
conservative picture of which functions are using which data
segments[0]. Perhaps there is a large data segment that you didn't
expect to be included in the wasm, introduced by some library you're
using, and you'd like to know which library it was. In this scenario,
merging data segments only makes the analysis worse.
Alternatively, perhaps you will remove some dead functions by-hand[1]
that can't be statically proven dead by the compiler or lld, and
removing these functions might make some data garbage collect-able, and
you'd like to run `--gc-sections` again so that this now-unused data can
be collected. If the segments were originally merged, then a single use
of the merged data segment will entrench all of the data.
[0] https://github.com/rustwasm/twiggy
[1] https://github.com/fitzgen/wasm-snip
Patch by Nick Fitzgerald!
Differential Revision: https://reviews.llvm.org/D46417
llvm-svn: 332013
2018-05-11 02:23:51 +08:00
|
|
|
bool mergeDataSegments;
|
2018-11-15 08:37:21 +08:00
|
|
|
bool pie;
|
2018-01-31 09:45:47 +08:00
|
|
|
bool printGcSections;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool relocatable;
|
2018-05-31 02:07:52 +08:00
|
|
|
bool saveTemps;
|
2018-11-15 08:37:21 +08:00
|
|
|
bool shared;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool stripAll;
|
|
|
|
bool stripDebug;
|
2018-05-04 01:21:53 +08:00
|
|
|
bool stackFirst;
|
2019-02-06 10:35:18 +08:00
|
|
|
bool trace;
|
2020-04-04 07:18:29 +08:00
|
|
|
uint64_t globalBase;
|
|
|
|
uint64_t initialMemory;
|
|
|
|
uint64_t maxMemory;
|
|
|
|
uint64_t zStackSize;
|
2018-05-31 02:07:52 +08:00
|
|
|
unsigned ltoPartitions;
|
|
|
|
unsigned ltoo;
|
|
|
|
unsigned optimize;
|
2020-03-27 22:20:39 +08:00
|
|
|
llvm::StringRef thinLTOJobs;
|
2020-12-02 04:22:27 +08:00
|
|
|
bool ltoNewPassManager;
|
|
|
|
bool ltoDebugPassManager;
|
2020-05-02 00:14:59 +08:00
|
|
|
UnresolvedPolicy unresolvedSymbols;
|
2019-05-09 00:20:05 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
llvm::StringRef entry;
|
2020-03-28 07:52:27 +08:00
|
|
|
llvm::StringRef mapFile;
|
2017-11-18 02:14:09 +08:00
|
|
|
llvm::StringRef outputFile;
|
2018-05-31 02:07:52 +08:00
|
|
|
llvm::StringRef thinLTOCacheDir;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2017-11-30 06:21:37 +08:00
|
|
|
llvm::StringSet<> allowUndefinedSymbols;
|
2019-06-01 06:51:59 +08:00
|
|
|
llvm::StringSet<> exportedSymbols;
|
2021-04-05 23:00:30 +08:00
|
|
|
std::vector<llvm::StringRef> requiredExports;
|
2017-11-29 04:27:21 +08:00
|
|
|
std::vector<llvm::StringRef> searchPaths;
|
2018-05-31 02:07:52 +08:00
|
|
|
llvm::CachePruningPolicy thinLTOCachePolicy;
|
2019-03-26 12:11:05 +08:00
|
|
|
llvm::Optional<std::vector<std::string>> features;
|
2018-11-15 08:37:21 +08:00
|
|
|
|
2019-05-09 00:20:05 +08:00
|
|
|
// The following config options do not directly correspond to any
|
|
|
|
// particualr command line options.
|
|
|
|
|
2018-11-15 08:37:21 +08:00
|
|
|
// True if we are creating position-independent code.
|
|
|
|
bool isPic;
|
2019-08-27 12:19:34 +08:00
|
|
|
|
2021-02-13 03:01:41 +08:00
|
|
|
// True if we have an MVP input that uses __indirect_function_table and which
|
|
|
|
// requires it to be allocated to table number 0.
|
|
|
|
bool legacyFunctionTable = false;
|
|
|
|
|
2019-08-27 12:19:34 +08:00
|
|
|
// The table offset at which to place function addresses. We reserve zero
|
2020-01-07 02:21:05 +08:00
|
|
|
// for the null function pointer. This gets set to 1 for executables and 0
|
2019-08-27 12:19:34 +08:00
|
|
|
// for shared libraries (since they always added to a dynamic offset at
|
|
|
|
// runtime).
|
|
|
|
uint32_t tableBase = 0;
|
2017-11-18 02:14:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// The only instance of Configuration struct.
|
|
|
|
extern Configuration *config;
|
|
|
|
|
|
|
|
} // namespace wasm
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|