summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-07-05 11:38:52 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-07-05 11:38:52 +0000
commitd5a8efe733ca2ce3039e81bbc6aa72a0804a7c9d (patch)
treeeb5914766e7d25ac90957d8001777da223c601da
parent45647d8f7458ed2d76252ce25347c2c75e769025 (diff)
downloadbcm5719-llvm-d5a8efe733ca2ce3039e81bbc6aa72a0804a7c9d.tar.gz
bcm5719-llvm-d5a8efe733ca2ce3039e81bbc6aa72a0804a7c9d.zip
This only needs a StringRef. No functionality change.
llvm-svn: 212371
-rw-r--r--llvm/include/llvm/Object/ELF.h20
-rw-r--r--llvm/include/llvm/Object/ELFObjectFile.h2
-rw-r--r--llvm/lib/Object/ELFObjectFile.cpp3
3 files changed, 13 insertions, 12 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index c968295b840..94420d1c568 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -40,11 +40,11 @@ StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type);
// Subclasses of ELFFile may need this for template instantiation
inline std::pair<unsigned char, unsigned char>
-getElfArchType(MemoryBuffer *Object) {
- if (Object->getBufferSize() < ELF::EI_NIDENT)
+getElfArchType(StringRef Object) {
+ if (Object.size() < ELF::EI_NIDENT)
return std::make_pair((uint8_t)ELF::ELFCLASSNONE,(uint8_t)ELF::ELFDATANONE);
- return std::make_pair((uint8_t) Object->getBufferStart()[ELF::EI_CLASS],
- (uint8_t) Object->getBufferStart()[ELF::EI_DATA]);
+ return std::make_pair((uint8_t)Object.begin()[ELF::EI_CLASS],
+ (uint8_t)Object.begin()[ELF::EI_DATA]);
}
template <class ELFT>
@@ -230,10 +230,10 @@ private:
typedef SmallVector<const Elf_Shdr *, 2> Sections_t;
typedef DenseMap<unsigned, unsigned> IndexMap_t;
- MemoryBuffer *Buf;
+ StringRef Buf;
const uint8_t *base() const {
- return reinterpret_cast<const uint8_t *>(Buf->getBufferStart());
+ return reinterpret_cast<const uint8_t *>(Buf.begin());
}
const Elf_Ehdr *Header;
@@ -317,7 +317,7 @@ public:
std::pair<const Elf_Shdr *, const Elf_Sym *>
getRelocationSymbol(const Elf_Shdr *RelSec, const RelT *Rel) const;
- ELFFile(MemoryBuffer *Object, std::error_code &ec);
+ ELFFile(StringRef Object, std::error_code &ec);
bool isMipsELF64() const {
return Header->e_machine == ELF::EM_MIPS &&
@@ -536,7 +536,7 @@ ELFFile<ELFT>::getSymbol(uint32_t Index) const {
template <class ELFT>
ErrorOr<ArrayRef<uint8_t> >
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
- if (Sec->sh_offset + Sec->sh_size > Buf->getBufferSize())
+ if (Sec->sh_offset + Sec->sh_size > Buf.size())
return object_error::parse_failed;
const uint8_t *Start = base() + Sec->sh_offset;
return ArrayRef<uint8_t>(Start, Sec->sh_size);
@@ -621,13 +621,13 @@ typename ELFFile<ELFT>::uintX_t ELFFile<ELFT>::getStringTableIndex() const {
}
template <class ELFT>
-ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, std::error_code &ec)
+ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &ec)
: Buf(Object), SectionHeaderTable(nullptr), dot_shstrtab_sec(nullptr),
dot_strtab_sec(nullptr), dot_symtab_sec(nullptr),
SymbolTableSectionHeaderIndex(nullptr), dot_gnu_version_sec(nullptr),
dot_gnu_version_r_sec(nullptr), dot_gnu_version_d_sec(nullptr),
dt_soname(nullptr) {
- const uint64_t FileSize = Buf->getBufferSize();
+ const uint64_t FileSize = Buf.size();
if (sizeof(Elf_Ehdr) > FileSize)
// FIXME: Proper error handling.
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index deff409c5dd..cfb6b08c703 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -779,7 +779,7 @@ ELFObjectFile<ELFT>::ELFObjectFile(std::unique_ptr<MemoryBuffer> Object,
support::little,
ELFT::Is64Bits),
std::move(Object)),
- EF(Data.get(), EC) {}
+ EF(Data->getBuffer(), EC) {}
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin_impl() const {
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index 0e6230d08c4..4f0f60b6242 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -19,7 +19,8 @@ using namespace object;
ErrorOr<ObjectFile *>
ObjectFile::createELFObjectFile(std::unique_ptr<MemoryBuffer> &Obj) {
- std::pair<unsigned char, unsigned char> Ident = getElfArchType(Obj.get());
+ std::pair<unsigned char, unsigned char> Ident =
+ getElfArchType(Obj->getBuffer());
std::size_t MaxAlignment =
1ULL << countTrailingZeros(uintptr_t(Obj->getBufferStart()));
OpenPOWER on IntegriCloud