[lld] r319789 - [WebAssembly] Simplify check for emitting relocations

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 08:53:25 PST 2017


Author: sbc
Date: Tue Dec  5 08:53:25 2017
New Revision: 319789

URL: http://llvm.org/viewvc/llvm-project?rev=319789&view=rev
Log:
[WebAssembly] Simplify check for emitting relocations

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

Modified:
    lld/trunk/wasm/Driver.cpp
    lld/trunk/wasm/Writer.cpp

Modified: lld/trunk/wasm/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Driver.cpp?rev=319789&r1=319788&r2=319789&view=diff
==============================================================================
--- lld/trunk/wasm/Driver.cpp (original)
+++ lld/trunk/wasm/Driver.cpp Tue Dec  5 08:53:25 2017
@@ -257,6 +257,8 @@ void LinkerDriver::link(ArrayRef<const c
   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);

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=319789&r1=319788&r2=319789&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Tue Dec  5 08:53:25 2017
@@ -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()) {
@@ -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)
@@ -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();




More information about the llvm-commits mailing list