summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/CMakeLists.txt2
-rw-r--r--lld/ELF/Driver.cpp2
-rw-r--r--lld/ELF/DriverUtils.cpp2
-rw-r--r--lld/ELF/InputFiles.cpp2
-rw-r--r--lld/ELF/InputSection.cpp3
-rw-r--r--lld/ELF/LinkerScript.cpp2
-rw-r--r--lld/ELF/OutputSections.cpp2
-rw-r--r--lld/ELF/SymbolTable.cpp2
-rw-r--r--lld/ELF/SyntheticSections.cpp3
-rw-r--r--lld/ELF/Target.cpp5
-rw-r--r--lld/ELF/Thunks.cpp2
-rw-r--r--lld/ELF/Writer.cpp3
-rw-r--r--lld/include/lld/Support/Memory.h (renamed from lld/ELF/Memory.h)6
-rw-r--r--lld/lib/CMakeLists.txt1
-rw-r--r--lld/lib/Support/CMakeLists.txt9
-rw-r--r--lld/lib/Support/Memory.cpp (renamed from lld/ELF/Memory.cpp)10
16 files changed, 29 insertions, 27 deletions
diff --git a/lld/ELF/CMakeLists.txt b/lld/ELF/CMakeLists.txt
index 39cf8ec770a..9780e1ee1c9 100644
--- a/lld/ELF/CMakeLists.txt
+++ b/lld/ELF/CMakeLists.txt
@@ -14,7 +14,6 @@ add_lld_library(lldELF
LTO.cpp
LinkerScript.cpp
MarkLive.cpp
- Memory.cpp
Mips.cpp
OutputSections.cpp
Relocations.cpp
@@ -50,6 +49,7 @@ add_lld_library(lldELF
LINK_LIBS
lldConfig
lldCore
+ lldSupport
${PTHREAD_LIB}
DEPENDS
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 2095e7384dd..a2c96b87f34 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -14,7 +14,6 @@
#include "InputFiles.h"
#include "InputSection.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "Strings.h"
#include "SymbolTable.h"
#include "Target.h"
@@ -22,6 +21,7 @@
#include "Writer.h"
#include "lld/Config/Version.h"
#include "lld/Driver/Driver.h"
+#include "lld/Support/Memory.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/CommandLine.h"
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 6a270a6d09d..179dfd356e6 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -15,10 +15,10 @@
#include "Driver.h"
#include "Error.h"
-#include "Memory.h"
#include "ScriptParser.h"
#include "lld/Config/Version.h"
#include "lld/Core/Reproduce.h"
+#include "lld/Support/Memory.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 06a19f5a24d..37ebfa7b304 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -12,9 +12,9 @@
#include "Error.h"
#include "InputSection.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "SymbolTable.h"
#include "Symbols.h"
+#include "lld/Support/Memory.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/CodeGen/Analysis.h"
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index f11b7b79308..975882e0fa5 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -13,13 +13,12 @@
#include "Error.h"
#include "InputFiles.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "OutputSections.h"
#include "Relocations.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "Thunks.h"
-
+#include "lld/Support/Memory.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
#include <mutex>
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 50ce95506c8..1a19f55994b 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -15,7 +15,6 @@
#include "Config.h"
#include "Driver.h"
#include "InputSection.h"
-#include "Memory.h"
#include "OutputSections.h"
#include "ScriptParser.h"
#include "Strings.h"
@@ -24,6 +23,7 @@
#include "SyntheticSections.h"
#include "Target.h"
#include "Writer.h"
+#include "lld/Support/Memory.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index cfb8ac9c568..f8daa57fd85 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -11,12 +11,12 @@
#include "Config.h"
#include "EhFrame.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "Strings.h"
#include "SymbolTable.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "Threads.h"
+#include "lld/Support/Memory.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 078fbb30943..25e435d9e58 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -18,8 +18,8 @@
#include "Config.h"
#include "Error.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "Symbols.h"
+#include "lld/Support/Memory.h"
#include "llvm/ADT/STLExtras.h"
using namespace llvm;
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index d69100a22d4..e833251fd55 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -19,15 +19,14 @@
#include "Error.h"
#include "InputFiles.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "OutputSections.h"
#include "Strings.h"
#include "SymbolTable.h"
#include "Target.h"
#include "Threads.h"
#include "Writer.h"
-
#include "lld/Config/Version.h"
+#include "lld/Support/Memory.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/MD5.h"
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 73fab279b88..aa8873667c7 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -27,17 +27,16 @@
#include "Target.h"
#include "Error.h"
#include "InputFiles.h"
-#include "Memory.h"
#include "OutputSections.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Thunks.h"
#include "Writer.h"
-
+#include "lld/Support/Memory.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Object/ELF.h"
-#include "llvm/Support/Endian.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/Endian.h"
using namespace llvm;
using namespace llvm::object;
diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp
index 34b630ac251..e7a1efe35da 100644
--- a/lld/ELF/Thunks.cpp
+++ b/lld/ELF/Thunks.cpp
@@ -25,10 +25,10 @@
#include "Config.h"
#include "Error.h"
#include "InputSection.h"
-#include "Memory.h"
#include "OutputSections.h"
#include "Symbols.h"
#include "Target.h"
+#include "lld/Support/Memory.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/Endian.h"
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index be9be49fc53..c63b8834bd9 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -10,14 +10,13 @@
#include "Writer.h"
#include "Config.h"
#include "LinkerScript.h"
-#include "Memory.h"
#include "OutputSections.h"
#include "Relocations.h"
#include "Strings.h"
#include "SymbolTable.h"
#include "SyntheticSections.h"
#include "Target.h"
-
+#include "lld/Support/Memory.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/FileOutputBuffer.h"
diff --git a/lld/ELF/Memory.h b/lld/include/lld/Support/Memory.h
index 9479fd05c32..1ed5ec99c97 100644
--- a/lld/ELF/Memory.h
+++ b/lld/include/lld/Support/Memory.h
@@ -19,15 +19,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLD_ELF_MEMORY_H
-#define LLD_ELF_MEMORY_H
+#ifndef LLD_MEMORY_H
+#define LLD_MEMORY_H
#include "llvm/Support/Allocator.h"
#include "llvm/Support/StringSaver.h"
#include <vector>
namespace lld {
-namespace elf {
// Use this arena if your object doesn't have a destructor.
extern llvm::BumpPtrAllocator BAlloc;
@@ -56,6 +55,5 @@ template <typename T, typename... U> inline T *make(U &&... Args) {
void freeArena();
}
-}
#endif
diff --git a/lld/lib/CMakeLists.txt b/lld/lib/CMakeLists.txt
index 699f5e93f8a..acd5322302f 100644
--- a/lld/lib/CMakeLists.txt
+++ b/lld/lib/CMakeLists.txt
@@ -2,3 +2,4 @@ add_subdirectory(Config)
add_subdirectory(Core)
add_subdirectory(Driver)
add_subdirectory(ReaderWriter)
+add_subdirectory(Support)
diff --git a/lld/lib/Support/CMakeLists.txt b/lld/lib/Support/CMakeLists.txt
new file mode 100644
index 00000000000..18dccdbc50c
--- /dev/null
+++ b/lld/lib/Support/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_lld_library(lldSupport
+ Memory.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLD_INCLUDE_DIR}/lld/Support
+
+ LINK_LIBS
+ LLVMSupport
+)
diff --git a/lld/ELF/Memory.cpp b/lld/lib/Support/Memory.cpp
index 7771317eb4c..9bdcdcc8fdb 100644
--- a/lld/ELF/Memory.cpp
+++ b/lld/lib/Support/Memory.cpp
@@ -7,21 +7,19 @@
//
//===----------------------------------------------------------------------===//
-#include "Memory.h"
+#include "lld/Support/Memory.h"
using namespace llvm;
-using namespace lld;
-using namespace lld::elf;
namespace lld {
-BumpPtrAllocator elf::BAlloc;
-StringSaver elf::Saver{elf::BAlloc};
+BumpPtrAllocator BAlloc;
+StringSaver Saver{BAlloc};
SpecificAllocBase::SpecificAllocBase() { Instances.push_back(this); }
std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
-void elf::freeArena() {
+void freeArena() {
for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
Alloc->reset();
BAlloc.Reset();
OpenPOWER on IntegriCloud