[llvm] r174639 - [Object][ELF] Fix crash on no dynamic section.
Michael J. Spencer
bigcheesegs at gmail.com
Thu Feb 7 10:26:45 PST 2013
Author: mspencer
Date: Thu Feb 7 12:26:45 2013
New Revision: 174639
URL: http://llvm.org/viewvc/llvm-project?rev=174639&view=rev
Log:
[Object][ELF] Fix crash on no dynamic section.
Added:
llvm/trunk/test/Object/readobj.test
Modified:
llvm/trunk/include/llvm/Object/ELF.h
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=174639&r1=174638&r2=174639&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Feb 7 12:26:45 2013
@@ -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>::be
}
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>::getLibra
;
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));
}
Added: llvm/trunk/test/Object/readobj.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/readobj.test?rev=174639&view=auto
==============================================================================
--- llvm/trunk/test/Object/readobj.test (added)
+++ llvm/trunk/test/Object/readobj.test Thu Feb 7 12:26:45 2013
@@ -0,0 +1,2 @@
+// Don't crash while reading non-dynamic files.
+RUN: llvm-readobj %p/Inputs/trivial-object-test.elf-x86-64
More information about the llvm-commits
mailing list