diff options
Diffstat (limited to 'lib/Object')
-rw-r--r-- | lib/Object/ArchiveWriter.cpp | 16 | ||||
-rw-r--r-- | lib/Object/CMakeLists.txt | 3 | ||||
-rw-r--r-- | lib/Object/COFFObjectFile.cpp | 13 | ||||
-rw-r--r-- | lib/Object/COFFYAML.cpp | 6 | ||||
-rw-r--r-- | lib/Object/ELFYAML.cpp | 6 | ||||
-rw-r--r-- | lib/Object/IRObjectFile.cpp | 19 | ||||
-rw-r--r-- | lib/Object/MachOObjectFile.cpp | 7 | ||||
-rw-r--r-- | lib/Object/RecordStreamer.h | 2 |
8 files changed, 32 insertions, 40 deletions
diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp index 90a736f3baf4..00a56d13bfed 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp @@ -18,6 +18,8 @@ #include "llvm/Object/Archive.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Object/SymbolicFile.h" +#include "llvm/Support/EndianStream.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" #include "llvm/Support/Path.h" @@ -70,7 +72,7 @@ NewArchiveIterator::getFD(sys::fs::file_status &NewStatus) const { // Linux cannot open directories with open(2), although // cygwin and *bsd can. if (NewStatus.type() == sys::fs::file_type::directory_file) - return make_error_code(std::errc::is_a_directory); + return make_error_code(errc::is_a_directory); return NewFD; } @@ -82,9 +84,7 @@ static void printWithSpacePadding(raw_fd_ostream &OS, T Data, unsigned Size, OS << Data; unsigned SizeSoFar = OS.tell() - OldPos; if (Size > SizeSoFar) { - unsigned Remaining = Size - SizeSoFar; - for (unsigned I = 0; I < Remaining; ++I) - OS << ' '; + OS.indent(Size - SizeSoFar); } else if (Size < SizeSoFar) { assert(MayTruncate && "Data doesn't fit in Size"); // Some of the data this is used for (like UID) can be larger than the @@ -93,12 +93,8 @@ static void printWithSpacePadding(raw_fd_ostream &OS, T Data, unsigned Size, } } -static void print32BE(raw_fd_ostream &Out, unsigned Val) { - // FIXME: Should use Endian.h here. - for (int I = 3; I >= 0; --I) { - char V = (Val >> (8 * I)) & 0xff; - Out << V; - } +static void print32BE(raw_ostream &Out, uint32_t Val) { + support::endian::Writer<support::big>(Out).write(Val); } static void printRestOfMemberHeader(raw_fd_ostream &Out, diff --git a/lib/Object/CMakeLists.txt b/lib/Object/CMakeLists.txt index 17aac8b41211..de809187191b 100644 --- a/lib/Object/CMakeLists.txt +++ b/lib/Object/CMakeLists.txt @@ -18,4 +18,7 @@ add_llvm_library(LLVMObject ADDITIONAL_HEADER_DIRS ${LLVM_MAIN_INCLUDE_DIR}/llvm/Object + + DEPENDS + intrinsics_gen ) diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index 1055b987d7ef..e2f559eec72d 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -991,19 +991,6 @@ symbol_iterator COFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { return symbol_iterator(SymbolRef(Ref, this)); } -section_iterator COFFObjectFile::getRelocationSection(DataRefImpl Rel) const { - symbol_iterator Sym = getRelocationSymbol(Rel); - if (Sym == symbol_end()) - return section_end(); - COFFSymbolRef Symb = getCOFFSymbol(*Sym); - if (!Symb.isSection()) - return section_end(); - section_iterator Res(section_end()); - if (getSymbolSection(Sym->getRawDataRefImpl(),Res)) - return section_end(); - return Res; -} - std::error_code COFFObjectFile::getRelocationType(DataRefImpl Rel, uint64_t &Res) const { const coff_relocation* R = toRel(Rel); diff --git a/lib/Object/COFFYAML.cpp b/lib/Object/COFFYAML.cpp index 9a24b531da9e..dda4b7f8c87e 100644 --- a/lib/Object/COFFYAML.cpp +++ b/lib/Object/COFFYAML.cpp @@ -335,7 +335,7 @@ struct NDLLCharacteristics { COFF::DLLCharacteristics Characteristics; }; -} +} // namespace void MappingTraits<COFFYAML::Relocation>::mapping(IO &IO, COFFYAML::Relocation &Rel) { @@ -497,5 +497,5 @@ void MappingTraits<COFFYAML::Object>::mapping(IO &IO, COFFYAML::Object &Obj) { IO.mapRequired("symbols", Obj.Symbols); } -} -} +} // namespace yaml +} // namespace llvm diff --git a/lib/Object/ELFYAML.cpp b/lib/Object/ELFYAML.cpp index 78087d62ada0..50730a99655c 100644 --- a/lib/Object/ELFYAML.cpp +++ b/lib/Object/ELFYAML.cpp @@ -44,7 +44,7 @@ ScalarEnumerationTraits<ELFYAML::ELF_EM>::enumeration(IO &IO, ECase(EM_386) ECase(EM_68K) ECase(EM_88K) - ECase(EM_486) + ECase(EM_IAMCU) ECase(EM_860) ECase(EM_MIPS) ECase(EM_S370) @@ -590,7 +590,7 @@ struct NormalizedOther { ELFYAML::ELF_STV Visibility; ELFYAML::ELF_STO Other; }; -} +} // namespace void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) { IO.mapOptional("Name", Symbol.Name, StringRef()); @@ -723,7 +723,7 @@ struct NormalizedMips64RelType { ELFYAML::ELF_REL Type3; ELFYAML::ELF_RSS SpecSym; }; -} +} // namespace void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO, ELFYAML::Relocation &Rel) { diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index e89cb8ead36d..e90e08d786f1 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -45,22 +45,22 @@ IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod) if (InlineAsm.empty()) return; - StringRef Triple = M->getTargetTriple(); + Triple TT(M->getTargetTriple()); std::string Err; - const Target *T = TargetRegistry::lookupTarget(Triple, Err); + const Target *T = TargetRegistry::lookupTarget(TT.str(), Err); if (!T) return; - std::unique_ptr<MCRegisterInfo> MRI(T->createMCRegInfo(Triple)); + std::unique_ptr<MCRegisterInfo> MRI(T->createMCRegInfo(TT.str())); if (!MRI) return; - std::unique_ptr<MCAsmInfo> MAI(T->createMCAsmInfo(*MRI, Triple)); + std::unique_ptr<MCAsmInfo> MAI(T->createMCAsmInfo(*MRI, TT.str())); if (!MAI) return; std::unique_ptr<MCSubtargetInfo> STI( - T->createMCSubtargetInfo(Triple, "", "")); + T->createMCSubtargetInfo(TT.str(), "", "")); if (!STI) return; @@ -70,7 +70,7 @@ IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod) MCObjectFileInfo MOFI; MCContext MCCtx(MAI.get(), MRI.get(), &MOFI); - MOFI.InitMCObjectFileInfo(Triple, Reloc::Default, CodeModel::Default, MCCtx); + MOFI.InitMCObjectFileInfo(TT, Reloc::Default, CodeModel::Default, MCCtx); std::unique_ptr<RecordStreamer> Streamer(new RecordStreamer(MCCtx)); T->createNullTargetStreamer(*Streamer); @@ -198,6 +198,9 @@ std::error_code IRObjectFile::printSymbolName(raw_ostream &OS, return std::error_code(); } + if (GV->hasDLLImportStorageClass()) + OS << "__imp_"; + if (Mang) Mang->getNameWithPrefix(OS, GV, false); else @@ -301,12 +304,12 @@ llvm::object::IRObjectFile::create(MemoryBufferRef Object, std::unique_ptr<MemoryBuffer> Buff( MemoryBuffer::getMemBuffer(BCOrErr.get(), false)); - ErrorOr<Module *> MOrErr = + ErrorOr<std::unique_ptr<Module>> MOrErr = getLazyBitcodeModule(std::move(Buff), Context, nullptr, /*ShouldLazyLoadMetadata*/ true); if (std::error_code EC = MOrErr.getError()) return EC; - std::unique_ptr<Module> M(MOrErr.get()); + std::unique_ptr<Module> &M = MOrErr.get(); return llvm::make_unique<IRObjectFile>(Object, std::move(M)); } diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index d02ca48a7d19..f76dd0d3f7ce 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -1232,6 +1232,7 @@ bool MachOObjectFile::isValidArch(StringRef ArchFlag) { .Case("armv5e", true) .Case("armv6", true) .Case("armv6m", true) + .Case("armv7", true) .Case("armv7em", true) .Case("armv7k", true) .Case("armv7m", true) @@ -2011,9 +2012,11 @@ MachOObjectFile::getAnyRelocationSection( const MachO::any_relocation_info &RE) const { if (isRelocationScattered(RE) || getPlainRelocationExternal(RE)) return *section_end(); - unsigned SecNum = getPlainRelocationSymbolNum(RE) - 1; + unsigned SecNum = getPlainRelocationSymbolNum(RE); + if (SecNum == MachO::R_ABS || SecNum > Sections.size()) + return *section_end(); DataRefImpl DRI; - DRI.d.a = SecNum; + DRI.d.a = SecNum - 1; return SectionRef(DRI, this); } diff --git a/lib/Object/RecordStreamer.h b/lib/Object/RecordStreamer.h index d8610610c332..d694a9fb8b0d 100644 --- a/lib/Object/RecordStreamer.h +++ b/lib/Object/RecordStreamer.h @@ -38,5 +38,5 @@ public: void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override; }; -} +} // namespace llvm #endif |