This patch improves the error messages reported for
note sections and phdrs and also makes a cleanup for
existent test case.
Details
Diff Detail
Event Timeline
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 205 | I'm not sure making this llvm_unreachable is correct: if you are using libObject as a library, you could pass in an invalid Phdr, which should report an error, not an assertion. | |
| 224 | Same comment about llvm_unreachable applies here. | |
| test/tools/llvm-readobj/gnu-notes.test | ||
| 1 | of the notes -> of notes | |
| 24 | Any particular reason you've changed these Offset values? | |
| 105 | I don't know what consistency says here, but it was very off-putting to see size listed as decimal, given offset is in hex. I'd prefer both to be hex if possible. | |
| 149 | Same comment here. | |
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 205 | Note that method name is notes_begin. I.e it expects to accept note Phdr and all I think that It is obviously a error in the code to pass Phdr not of type PT_NOTE here. | |
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 205 | Hmmm... okay, I'm not really convinced, but I don't feel strongly about it. Either way, this can be simplified to assert(Phdr.p_type != ELF::PT_NOTE && "Phdr is not of type PT_NOTE"). | |
- Addressed review comments.
| test/tools/llvm-readobj/gnu-notes.test | ||
|---|---|---|
| 24 | The original YAML contained redundant sections like .text, .eh_frame and also symbols. I cleaned it up and | |
It seems that my new test case triggered a unchecked error bug on bots.
I am going to recompile with LLVM_ENABLE_ABI_BREAKING_CHECKS to find the exact place.
Will reupload the fixed version after that.
- Fixed the reason of BB failture.
So the issue was in the original code. notes_begin() accepts a reference to
the Error object. When Error assignment operation happens it asserts with
LLVM_ENABLE_ABI_BREAKING_CHECKS because default Error::success() value
is never checked. Previously we just did not have a test case for such scenario
and so issue simply was never triggered.
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 224 | Alternatively, assert(Shdr.sh_type == ELF::SHT_NOTE && "Shdr is not of type SHT_NOTE");
if (Err)
return Elf_Note_Iterator(); // end() if Err is set
if (Shdr.sh_offset + Shdr.sh_size > getBufSize()) {
...
}
return Elf_Note_Iterator(base() + Shdr.sh_offset, Shdr.sh_size, Err); | |
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 224 | But that means that Err can be set to something before the call. Then if (Err) return Elf_Note_Iterator(); // end() if Err is set Will mark it as checked and that can hide the error. | |
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 224 |
I agree. Wait, I think there might be a better version: ErrorAsOutParameter ErrAsOutParam(&Err); What I worry about assert(!Err && "Err should have Error::success() value"); is that it sets the check bit in an assertion build. | |
- Addressed review comment.
| include/llvm/Object/ELF.h | ||
|---|---|---|
| 224 |
True. This could be be solved if Error::getPtr() wasn't private: assert(Err.getPtr() && ..
Cool, I did not know about this one, I used it, thanks! | |
I'm not sure making this llvm_unreachable is correct: if you are using libObject as a library, you could pass in an invalid Phdr, which should report an error, not an assertion.