diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-07-05 11:28:49 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-07-05 11:28:49 +0000 |
commit | d0921a4696e097c54fa67f573718561dbdbd3103 (patch) | |
tree | 08caf3fa2f8d695e1eb9eb66cf78b185c5cf4481 /llvm/lib/Object/ELF.cpp | |
parent | fdef18b42d02d69ca3a7be9c8c38a83ace51d9ff (diff) | |
download | bcm5719-llvm-d0921a4696e097c54fa67f573718561dbdbd3103.tar.gz bcm5719-llvm-d0921a4696e097c54fa67f573718561dbdbd3103.zip |
[Object/ELF.h] - Improve error reporting.
The errors coming from ELF.h are usually not very
useful because they are uninformative. This patch is a
first step to improve the situation.
I tested this patch with a run of check-llvm and found
that few messages are untested. In this patch, I did not
add more tests but marked all such cases with a "TODO" comment.
For all tested messages I extended the error text to
provide more details (see test cases changed).
Differential revision: https://reviews.llvm.org/D64014
llvm-svn: 365183
Diffstat (limited to 'llvm/lib/Object/ELF.cpp')
-rw-r--r-- | llvm/lib/Object/ELF.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp index f0ef53d2444..8660b1a64bd 100644 --- a/llvm/lib/Object/ELF.cpp +++ b/llvm/lib/Object/ELF.cpp @@ -537,12 +537,15 @@ Expected<typename ELFT::DynRange> ELFFile<ELFT>::dynamicEntries() const { } if (Dyn.empty()) + // TODO: this error is untested. return createError("invalid empty dynamic section"); if (DynSecSize % sizeof(Elf_Dyn) != 0) + // TODO: this error is untested. return createError("malformed dynamic section"); if (Dyn.back().d_tag != ELF::DT_NULL) + // TODO: this error is untested. return createError("dynamic sections must be DT_NULL terminated"); return Dyn; @@ -567,12 +570,14 @@ Expected<const uint8_t *> ELFFile<ELFT>::toMappedAddr(uint64_t VAddr) const { }); if (I == LoadSegments.begin()) - return createError("Virtual address is not in any segment"); + return createError("virtual address is not in any segment: 0x" + + Twine::utohexstr(VAddr)); --I; const Elf_Phdr &Phdr = **I; uint64_t Delta = VAddr - Phdr.p_vaddr; if (Delta >= Phdr.p_filesz) - return createError("Virtual address is not in any segment"); + return createError("virtual address is not in any segment: 0x" + + Twine::utohexstr(VAddr)); return base() + Phdr.p_offset + Delta; } |