Skip to content

Commit

Permalink
[WebAssembly] Simplify check for emitting relocations
Browse files Browse the repository at this point in the history
This is a small change I split of from a larger one
that simplifies the condition that need to be checked
when decided if we need to emit relocation and all the
things they depend on (symbols, etc).

Differential Revision: https://reviews.llvm.org/D40825

llvm-svn: 319789
  • Loading branch information
sbc100 committed Dec 5, 2017
1 parent a4ca525 commit 22cfe52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lld/wasm/Driver.cpp
Expand Up @@ -257,6 +257,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Config->Sysroot = Args.getLastArgValue(OPT_sysroot);
errorHandler().Verbose = Args.hasArg(OPT_verbose);
ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true);
if (Config->Relocatable)
Config->EmitRelocs = true;

Config->InitialMemory = args::getInteger(Args, OPT_initial_memory, 0);
Config->GlobalBase = args::getInteger(Args, OPT_global_base, 1024);
Expand Down
6 changes: 3 additions & 3 deletions lld/wasm/Writer.cpp
Expand Up @@ -226,7 +226,7 @@ void Writer::createGlobalSection() {
writeGlobal(OS, Global);
}

if (Config->Relocatable || Config->EmitRelocs) {
if (Config->EmitRelocs) {
for (ObjFile *File : Symtab->ObjectFiles) {
uint32_t GlobalIndex = File->NumGlobalImports();
for (const WasmGlobal &Global : File->getWasmObj()->globals()) {
Expand Down Expand Up @@ -539,7 +539,7 @@ void Writer::createSections() {
createDataSection();

// Custom sections
if (Config->EmitRelocs || Config->Relocatable)
if (Config->EmitRelocs)
createRelocSections();
createLinkingSection();
if (!Config->StripDebug && !Config->StripAll)
Expand All @@ -565,7 +565,7 @@ void Writer::calculateOffsets() {
NumFunctions += WasmFile->functions().size();

// Global Index
if (Config->Relocatable || Config->EmitRelocs) {
if (Config->EmitRelocs) {
File->GlobalIndexOffset =
GlobalImports.size() - File->NumGlobalImports() + NumGlobals;
NumGlobals += WasmFile->globals().size();
Expand Down

0 comments on commit 22cfe52

Please sign in to comment.