2017-11-18 02:14:09 +08:00
|
|
|
//===- Config.h -------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
|
|
|
struct Configuration {
|
2017-11-29 04:27:21 +08:00
|
|
|
bool AllowUndefined;
|
2018-05-19 07:28:05 +08:00
|
|
|
bool CompressRelocTargets;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool Demangle;
|
2018-03-28 20:53:29 +08:00
|
|
|
bool ExportTable;
|
2018-01-31 09:45:47 +08:00
|
|
|
bool GcSections;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool ImportMemory;
|
2018-03-28 20:53:29 +08:00
|
|
|
bool ImportTable;
|
[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-01-31 09:45:47 +08:00
|
|
|
bool PrintGcSections;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool Relocatable;
|
|
|
|
bool StripAll;
|
|
|
|
bool StripDebug;
|
2018-05-04 01:21:53 +08:00
|
|
|
bool StackFirst;
|
2017-11-29 04:27:21 +08:00
|
|
|
uint32_t GlobalBase;
|
|
|
|
uint32_t InitialMemory;
|
|
|
|
uint32_t MaxMemory;
|
2018-05-19 07:28:05 +08:00
|
|
|
uint32_t Optimize;
|
2017-11-29 04:27:21 +08:00
|
|
|
uint32_t ZStackSize;
|
2017-11-18 02:14:09 +08:00
|
|
|
llvm::StringRef Entry;
|
|
|
|
llvm::StringRef OutputFile;
|
|
|
|
|
2017-11-30 06:21:37 +08:00
|
|
|
llvm::StringSet<> AllowUndefinedSymbols;
|
2017-11-29 04:27:21 +08:00
|
|
|
std::vector<llvm::StringRef> SearchPaths;
|
2017-11-18 02:14:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// The only instance of Configuration struct.
|
|
|
|
extern Configuration *Config;
|
|
|
|
|
|
|
|
} // namespace wasm
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|