1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[Object][ELF] Fix crash on no dynamic section.

llvm-svn: 174639
This commit is contained in:
Michael J. Spencer 2013-02-07 18:26:45 +00:00
parent a3945f0d83
commit d9e9c95c02
2 changed files with 7 additions and 3 deletions

View File

@ -513,6 +513,8 @@ public:
return Tmp; return Tmp;
} }
const char *get() const { return Current; }
private: private:
const uint64_t EntitySize; const uint64_t EntitySize;
const char *Current; const char *Current;
@ -2292,7 +2294,7 @@ library_iterator ELFObjectFile<ELFT>::begin_libraries_needed() const {
} }
DataRefImpl DRI; DataRefImpl DRI;
DRI.p = reinterpret_cast<uintptr_t>(&*i); DRI.p = reinterpret_cast<uintptr_t>(i.get());
return library_iterator(LibraryRef(DRI, this)); return library_iterator(LibraryRef(DRI, this));
} }
@ -2312,7 +2314,7 @@ error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data,
; ;
DataRefImpl DRI; DataRefImpl DRI;
DRI.p = reinterpret_cast<uintptr_t>(&*i); DRI.p = reinterpret_cast<uintptr_t>(i.get());
Result = LibraryRef(DRI, this); Result = LibraryRef(DRI, this);
return object_error::success; return object_error::success;
} }
@ -2343,7 +2345,7 @@ template<class ELFT>
library_iterator ELFObjectFile<ELFT>::end_libraries_needed() const { library_iterator ELFObjectFile<ELFT>::end_libraries_needed() const {
dyn_iterator e = end_dynamic_table(); dyn_iterator e = end_dynamic_table();
DataRefImpl DRI; DataRefImpl DRI;
DRI.p = reinterpret_cast<uintptr_t>(&*e); DRI.p = reinterpret_cast<uintptr_t>(e.get());
return library_iterator(LibraryRef(DRI, this)); return library_iterator(LibraryRef(DRI, this));
} }

2
test/Object/readobj.test Normal file
View File

@ -0,0 +1,2 @@
// Don't crash while reading non-dynamic files.
RUN: llvm-readobj %p/Inputs/trivial-object-test.elf-x86-64