aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:49 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:49 +0000
commit2079716dfb3fb7e4e24b8b2e85eb6780b981a0af (patch)
tree3b0c58e50948b450b50b20ae5a38c005128edfb5 /lib
parentb9a1baec33e911ca24f51abf882d454e62047ea6 (diff)
downloadsrc-2079716dfb3fb7e4e24b8b2e85eb6780b981a0af.tar.gz
src-2079716dfb3fb7e4e24b8b2e85eb6780b981a0af.zip
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/Core/CMakeLists.txt3
-rw-r--r--lib/Core/Reader.cpp6
-rw-r--r--lib/Core/SymbolTable.cpp2
-rw-r--r--lib/Driver/DarwinLdDriver.cpp8
-rw-r--r--lib/ReaderWriter/FileArchive.cpp13
-rw-r--r--lib/ReaderWriter/MachO/ExecutableAtoms.h2
-rw-r--r--lib/ReaderWriter/MachO/MachOLinkingContext.cpp2
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFile.h2
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp15
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h2
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp6
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp5
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp6
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp3
-rw-r--r--lib/ReaderWriter/MachO/WriterMachO.cpp2
-rw-r--r--lib/ReaderWriter/YAML/ReaderWriterYAML.cpp2
16 files changed, 45 insertions, 34 deletions
diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt
index f2bf90509295..85046b93f34f 100644
--- a/lib/Core/CMakeLists.txt
+++ b/lib/Core/CMakeLists.txt
@@ -18,9 +18,10 @@ add_lld_library(lldCore
${LLD_INCLUDE_DIR}/lld/Core
LINK_COMPONENTS
+ BinaryFormat
MC
Support
-
+
LINK_LIBS
${LLVM_PTHREAD_LIB}
diff --git a/lib/Core/Reader.cpp b/lib/Core/Reader.cpp
index 24652abec688..5d8bbbbfe4d7 100644
--- a/lib/Core/Reader.cpp
+++ b/lib/Core/Reader.cpp
@@ -11,12 +11,16 @@
#include "lld/Core/File.h"
#include "lld/Core/Reference.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include <algorithm>
#include <memory>
+using llvm::file_magic;
+using llvm::identify_magic;
+
namespace lld {
YamlIOTaggedDocumentHandler::~YamlIOTaggedDocumentHandler() = default;
@@ -33,7 +37,7 @@ ErrorOr<std::unique_ptr<File>>
Registry::loadFile(std::unique_ptr<MemoryBuffer> mb) const {
// Get file magic.
StringRef content(mb->getBufferStart(), mb->getBufferSize());
- llvm::sys::fs::file_magic fileType = llvm::sys::fs::identify_magic(content);
+ file_magic fileType = identify_magic(content);
// Ask each registered reader if it can handle this file type or extension.
for (const std::unique_ptr<Reader> &reader : _readers) {
diff --git a/lib/Core/SymbolTable.cpp b/lib/Core/SymbolTable.cpp
index cacea5f30847..583c65acb5d3 100644
--- a/lib/Core/SymbolTable.cpp
+++ b/lib/Core/SymbolTable.cpp
@@ -161,7 +161,7 @@ bool SymbolTable::addByName(const Atom &newAtom) {
llvm::errs() << "Size mismatch: "
<< existing->name() << " (" << existingSize << ") "
<< newAtom.name() << " (" << newSize << ")\n";
- // fallthrough
+ LLVM_FALLTHROUGH;
}
case MCR_Error:
llvm::errs() << "Duplicate symbols: "
diff --git a/lib/Driver/DarwinLdDriver.cpp b/lib/Driver/DarwinLdDriver.cpp
index 9b4aede19aa2..c859c9802349 100644
--- a/lib/Driver/DarwinLdDriver.cpp
+++ b/lib/Driver/DarwinLdDriver.cpp
@@ -18,30 +18,30 @@
#include "lld/Core/File.h"
#include "lld/Core/Instrumentation.h"
#include "lld/Core/LLVM.h"
+#include "lld/Core/LinkingContext.h"
#include "lld/Core/Node.h"
#include "lld/Core/PassManager.h"
#include "lld/Core/Resolver.h"
#include "lld/Core/SharedLibraryFile.h"
#include "lld/Core/Simple.h"
-#include "lld/Core/LinkingContext.h"
#include "lld/ReaderWriter/MachOLinkingContext.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
-#include "llvm/Option/Option.h"
#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
diff --git a/lib/ReaderWriter/FileArchive.cpp b/lib/ReaderWriter/FileArchive.cpp
index 799f947a8c82..762d0871db06 100644
--- a/lib/ReaderWriter/FileArchive.cpp
+++ b/lib/ReaderWriter/FileArchive.cpp
@@ -11,15 +11,16 @@
#include "lld/Core/File.h"
#include "lld/Core/LLVM.h"
#include "lld/Core/Reader.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Object/Archive.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/Format.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/Object/Error.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
#include <set>
@@ -30,6 +31,8 @@
#include <vector>
using llvm::object::Archive;
+using llvm::file_magic;
+using llvm::identify_magic;
namespace lld {
@@ -201,7 +204,7 @@ public:
ArchiveReader(bool logLoading) : _logLoading(logLoading) {}
bool canParse(file_magic magic, MemoryBufferRef) const override {
- return magic == llvm::sys::fs::file_magic::archive;
+ return magic == file_magic::archive;
}
ErrorOr<std::unique_ptr<File>> loadFile(std::unique_ptr<MemoryBuffer> mb,
diff --git a/lib/ReaderWriter/MachO/ExecutableAtoms.h b/lib/ReaderWriter/MachO/ExecutableAtoms.h
index acced33b7e74..ab14e6d8c3e7 100644
--- a/lib/ReaderWriter/MachO/ExecutableAtoms.h
+++ b/lib/ReaderWriter/MachO/ExecutableAtoms.h
@@ -13,7 +13,7 @@
#include "Atoms.h"
#include "File.h"
-#include "llvm/Support/MachO.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h"
diff --git a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index db4a96823e74..7e7b559b150a 100644
--- a/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -22,11 +22,11 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Host.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/Path.h"
#include <algorithm>
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFile.h b/lib/ReaderWriter/MachO/MachONormalizedFile.h
index 60d76d4b5c9b..31b24dfd1025 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFile.h
+++ b/lib/ReaderWriter/MachO/MachONormalizedFile.h
@@ -48,10 +48,10 @@
#include "lld/ReaderWriter/MachOLinkingContext.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/YAMLTraits.h"
using llvm::BumpPtrAllocator;
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
index 23c7ea17f7e7..edbe576f0086 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -21,24 +21,25 @@
/// | normalized |
/// +------------+
-#include "MachONormalizedFile.h"
#include "ArchHandler.h"
+#include "MachONormalizedFile.h"
#include "MachONormalizedFileBinaryUtils.h"
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
#include "lld/Core/SharedLibraryFile.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/BinaryFormat/MachO.h"
+#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Object/MachO.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/Host.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <functional>
@@ -46,6 +47,7 @@
using namespace llvm::MachO;
using llvm::object::ExportEntry;
+using llvm::file_magic;
using llvm::object::MachOObjectFile;
namespace lld {
@@ -531,8 +533,7 @@ public:
MachOObjectReader(MachOLinkingContext &ctx) : _ctx(ctx) {}
bool canParse(file_magic magic, MemoryBufferRef mb) const override {
- return (magic == llvm::sys::fs::file_magic::macho_object &&
- mb.getBufferSize() > 32);
+ return (magic == file_magic::macho_object && mb.getBufferSize() > 32);
}
ErrorOr<std::unique_ptr<File>>
@@ -553,8 +554,8 @@ public:
bool canParse(file_magic magic, MemoryBufferRef mb) const override {
switch (magic) {
- case llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib:
- case llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub:
+ case file_magic::macho_dynamically_linked_shared_lib:
+ case file_magic::macho_dynamically_linked_shared_lib_stub:
return mb.getBufferSize() > 32;
default:
return false;
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index d69c5389e9d6..b38f7059228f 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -14,12 +14,12 @@
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/LEB128.h"
-#include "llvm/Support/MachO.h"
#include <system_error>
namespace lld {
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index e853faf9112e..bac41d2a52bf 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -25,11 +25,12 @@
#include "MachONormalizedFileBinaryUtils.h"
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
-#include "llvm/ADT/ilist.h"
-#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ilist.h"
+#include "llvm/ADT/ilist_node.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
@@ -37,7 +38,6 @@
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Host.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <functional>
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index ddd3259842e2..e58e3d2e7a4b 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -20,19 +20,19 @@
/// | Atoms |
/// +-------+
-#include "MachONormalizedFile.h"
#include "ArchHandler.h"
#include "DebugInfo.h"
+#include "MachONormalizedFile.h"
#include "MachONormalizedFileBinaryUtils.h"
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/MachO.h"
#include <map>
#include <system_error>
#include <unordered_set>
@@ -515,6 +515,7 @@ void Util::organizeSections() {
// Main executables, need a zero-page segment
segmentForName("__PAGEZERO");
// Fall into next case.
+ LLVM_FALLTHROUGH;
case llvm::MachO::MH_DYLIB:
case llvm::MachO::MH_BUNDLE:
// All dynamic code needs TEXT segment to hold the load commands.
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 4b17f7b3a85f..18fb71f16bcf 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -20,20 +20,20 @@
/// | Atoms |
/// +-------+
-#include "MachONormalizedFile.h"
#include "ArchHandler.h"
#include "Atoms.h"
#include "File.h"
+#include "MachONormalizedFile.h"
#include "MachONormalizedFileBinaryUtils.h"
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
+#include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
index 218170965eca..fe67fc88c467 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
@@ -23,17 +23,16 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include <system_error>
-
using llvm::StringRef;
using namespace llvm::yaml;
using namespace llvm::MachO;
diff --git a/lib/ReaderWriter/MachO/WriterMachO.cpp b/lib/ReaderWriter/MachO/WriterMachO.cpp
index f08487f21ac1..c457e7b55a43 100644
--- a/lib/ReaderWriter/MachO/WriterMachO.cpp
+++ b/lib/ReaderWriter/MachO/WriterMachO.cpp
@@ -12,10 +12,10 @@
#include "lld/Core/File.h"
#include "lld/Core/Writer.h"
#include "lld/ReaderWriter/MachOLinkingContext.h"
+#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
-#include "llvm/Support/MachO.h"
#include "llvm/Support/raw_ostream.h"
#include <system_error>
diff --git a/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 59ca43079a6d..4c88eb1d1476 100644
--- a/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -26,6 +26,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
@@ -43,6 +44,7 @@
#include <system_error>
#include <vector>
+using llvm::file_magic;
using llvm::yaml::MappingTraits;
using llvm::yaml::ScalarEnumerationTraits;
using llvm::yaml::ScalarTraits;