diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-07 18:26:45 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-07 18:26:45 +0000 |
commit | 3a967eac1e74ec24337fb88a4d5d975684878049 (patch) | |
tree | f1fbb530f0fee63f394026a0f13ece2f0fc0cfc8 | |
parent | 85425d77b8ed75fb5996b2df795530ca163d79d5 (diff) | |
download | bcm5719-llvm-3a967eac1e74ec24337fb88a4d5d975684878049.tar.gz bcm5719-llvm-3a967eac1e74ec24337fb88a4d5d975684878049.zip |
[Object][ELF] Fix crash on no dynamic section.
llvm-svn: 174639
-rw-r--r-- | llvm/include/llvm/Object/ELF.h | 8 | ||||
-rw-r--r-- | llvm/test/Object/readobj.test | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index a84461020e3..4a5eebf0266 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -513,6 +513,8 @@ public: return Tmp; } + const char *get() const { return Current; } + private: const uint64_t EntitySize; const char *Current; @@ -2292,7 +2294,7 @@ library_iterator ELFObjectFile<ELFT>::begin_libraries_needed() const { } DataRefImpl DRI; - DRI.p = reinterpret_cast<uintptr_t>(&*i); + DRI.p = reinterpret_cast<uintptr_t>(i.get()); return library_iterator(LibraryRef(DRI, this)); } @@ -2312,7 +2314,7 @@ error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data, ; DataRefImpl DRI; - DRI.p = reinterpret_cast<uintptr_t>(&*i); + DRI.p = reinterpret_cast<uintptr_t>(i.get()); Result = LibraryRef(DRI, this); return object_error::success; } @@ -2343,7 +2345,7 @@ template<class ELFT> library_iterator ELFObjectFile<ELFT>::end_libraries_needed() const { dyn_iterator e = end_dynamic_table(); DataRefImpl DRI; - DRI.p = reinterpret_cast<uintptr_t>(&*e); + DRI.p = reinterpret_cast<uintptr_t>(e.get()); return library_iterator(LibraryRef(DRI, this)); } diff --git a/llvm/test/Object/readobj.test b/llvm/test/Object/readobj.test new file mode 100644 index 00000000000..e29f40492d7 --- /dev/null +++ b/llvm/test/Object/readobj.test @@ -0,0 +1,2 @@ +// Don't crash while reading non-dynamic files. +RUN: llvm-readobj %p/Inputs/trivial-object-test.elf-x86-64 |