aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-readobj
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-12-31 15:45:31 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-12-31 15:45:31 +0000
commitad784790ad28023ef5041beac6c23a8250778f3f (patch)
treedcf0d8236fdc704eb35a812ad6a27016e0bd4be5 /tools/llvm-readobj
parent1318e14f3e9d786ea108d99ecaee7b5baa9b8fd0 (diff)
downloadexternal_llvm-ad784790ad28023ef5041beac6c23a8250778f3f.zip
external_llvm-ad784790ad28023ef5041beac6c23a8250778f3f.tar.gz
external_llvm-ad784790ad28023ef5041beac6c23a8250778f3f.tar.bz2
Check for errors. Extracted from a patch by Sami Liedes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171301 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-readobj')
-rw-r--r--tools/llvm-readobj/llvm-readobj.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp
index 252a377..8f8804a 100644
--- a/tools/llvm-readobj/llvm-readobj.cpp
+++ b/tools/llvm-readobj/llvm-readobj.cpp
@@ -69,6 +69,11 @@ static std::string getSymbolFlagStr(uint32_t Flags) {
return result;
}
+static void checkError(error_code ec, const char *msg) {
+ if (ec)
+ report_fatal_error(std::string(msg) + ": " + ec.message());
+}
+
static void
dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) {
StringRef Name;
@@ -77,12 +82,13 @@ dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) {
uint64_t Address;
uint64_t Size;
uint64_t FileOffset;
- Sym.getName(Name);
- Sym.getAddress(Address);
- Sym.getSize(Size);
- Sym.getFileOffset(FileOffset);
- Sym.getType(Type);
- Sym.getFlags(Flags);
+ checkError(Sym.getName(Name), "SymbolRef.getName() failed");
+ checkError(Sym.getAddress(Address), "SymbolRef.getAddress() failed");
+ checkError(Sym.getSize(Size), "SymbolRef.getSize() failed");
+ checkError(Sym.getFileOffset(FileOffset),
+ "SymbolRef.getFileOffset() failed");
+ checkError(Sym.getType(Type), "SymbolRef.getType() failed");
+ checkError(Sym.getFlags(Flags), "SymbolRef.getFlags() failed");
std::string FullName = Name;
// If this is a dynamic symbol from an ELF object, append