summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rtdyld
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2016-05-02 20:28:12 +0000
committerKevin Enderby <enderby@apple.com>2016-05-02 20:28:12 +0000
commit7bd8d994978d6404a79b28e04a802d070c45ba16 (patch)
treeb827e6424c503f1ec157ad5dd700b9a0fee9bc06 /llvm/tools/llvm-rtdyld
parent34c549ea02081e48946750adbc928ae57ff67bd9 (diff)
downloadbcm5719-llvm-7bd8d994978d6404a79b28e04a802d070c45ba16.tar.gz
bcm5719-llvm-7bd8d994978d6404a79b28e04a802d070c45ba16.zip
Thread Expected<...> up from libObject’s getType() for symbols to allow llvm-objdump to produce a good error message.
Produce another specific error message for a malformed Mach-O file when a symbol’s section index is more than the number of sections. The existing test case in test/Object/macho-invalid.test for macho-invalid-section-index-getSectionRawName now reports the error with the message indicating that a symbol at a specific index has a bad section index and that bad section index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: "// TODO: Actually report errors helpfully" and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. llvm-svn: 268298
Diffstat (limited to 'llvm/tools/llvm-rtdyld')
-rw-r--r--llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
index d65fde1d696..7d302f1faed 100644
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -335,9 +335,12 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
// Use symbol info to iterate functions in the object.
for (const auto &P : SymAddr) {
object::SymbolRef Sym = P.first;
- ErrorOr<SymbolRef::Type> TypeOrErr = Sym.getType();
- if (!TypeOrErr)
+ Expected<SymbolRef::Type> TypeOrErr = Sym.getType();
+ if (!TypeOrErr) {
+ // TODO: Actually report errors helpfully.
+ consumeError(TypeOrErr.takeError());
continue;
+ }
SymbolRef::Type Type = *TypeOrErr;
if (Type == object::SymbolRef::ST_Function) {
Expected<StringRef> Name = Sym.getName();
@@ -356,7 +359,13 @@ static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
// symbol in memory (rather than that in the unrelocated object file)
// and use that to query the DWARFContext.
if (!UseDebugObj && LoadObjects) {
- object::section_iterator Sec = *Sym.getSection();
+ auto SecOrErr = Sym.getSection();
+ if (!SecOrErr) {
+ // TODO: Actually report errors helpfully.
+ consumeError(SecOrErr.takeError());
+ continue;
+ }
+ object::section_iterator Sec = *SecOrErr;
StringRef SecName;
Sec->getName(SecName);
uint64_t SectionLoadAddress =
OpenPOWER on IntegriCloud