A simple refactoring patch which let us use DataExtractor::getSLEB128 rather than using a lambda function.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Object/ELF.cpp | ||
---|---|---|
13 | Can you remove the LEB128.h include? |
In principle, looks fine, but two pre-merge bots are complaining about an unhandled Error somewhere.
Thanks @jhenderson. I added one more check after uint64_t NumRelocsInGroup = Data.getSLEB128(Cur); to solve the issue.
So, if the previous build bot failure was due to an unhandled Error, that means that this error path doesn't have any testing. Basically, there needs to be a test for each individual getSLEB128 call, in case the section happens to be corrupted at that specific point (e.g. a truncated SLEB or one that goes outside the uint64_t range). Given that this is in the Object library, it would also probably make most sense for those tests to be gtest unit tests rather than lit stuff.
If I'm following things correctly, I don't think you've made the testing situation any worse, so if you'd prefer to defer that to a separate change, that's fine by me.
llvm/lib/Object/ELF.cpp | ||
---|---|---|
383 | Add a comment saying what the 4 here represents, i.e. something like DataExtractor::Cursor Cur(/*Offset=*/4); |
A minor nit from me, the rest looks fine.
llvm/lib/Object/ELF.cpp | ||
---|---|---|
435 | Looks like you can remove these 2 lines and do the following? for (uint64_t I = 0; Cur && I != NumRelocsInGroup; ++I) { It is a bit shorter, anyways the Cur is checked right below. |
I agree that the testing is not extensive. However, I think as long as we make sure the Cursor error is eventually taken (by takeError), there won't be any unhandled error problem. The previous diff posed the problem that the following return from the function (at line 396) could potentially left the Cursor error unhandled.
if (NumRelocsInGroup > NumRelocs) return createError("relocation group unexpectedly large");
I am trying to say that we only need to guard the function returns (which is already done). So I don't have a strong opinion on making the tests any better.
If I'm following things correctly, I don't think you've made the testing situation any worse, so if you'd prefer to defer that to a separate change, that's fine by me.
llvm/lib/Object/ELF.cpp | ||
---|---|---|
435 | Great suggestion. Thanks. |
Sorry, I got caught up with things yesterday and didn't get to all the review requests I had to field.
I guess the test case I'm thinking of is showing that the malformed group reloc count value means we don't get the "relocation group unexpectedly large" error. I don't feel strongly enough about this though to push for more testing if you don't want to add it.
Thanks for the response. I see your point now. But the "relocation group unexpectedly large" error has been tested by asm5.s in the same test file above. So I think we should be good to land.
I am surprised this patch hasn't been automatically updated to show the committed status after I pushed it (https://github.com/llvm/llvm-project/commit/3ca502a7d60787abe14db1fa541950ff79c7585b). Maybe I should've used arc land instead of git push?
Probably because you've used "Differential Revision". The latter word should be "revision"
No, it definitely should be Revision (upper-case). I always use git push, and my last commit worked fine - see rGb37a349ff2442e73ceafeee982afb430359e08b1. Your format looks the same as mine, so either Phabricator had a fit and just failed to link the two up this time, or something else is the matter. @mehdi_amini, any ideas?
Seems there is no difference what to use then. I believe I always used lower-case. E.g rG029644ee510792120f1c0daf32989b401d4ce871.
Closed [manually] by commit https://github.com/llvm/llvm-project/commit/3ca502a7d60787abe14db1fa541950ff79c7585b
Thanks @grimar and @jhenderson.
I think the 'differential revision' line was added automatically when I pushed.
Can you remove the LEB128.h include?