This is an archive of the discontinued LLVM Phabricator instance.

[ELF/AArch64] Factor out overflow check into a separate function.
ClosedPublic

Authored by ikudrin on Nov 23 2015, 5:58 AM.

Details

Summary

This patch mainly extracts overflow checks for AArch64 relocations into a separate function.

In addition, it corrects checks for R_AARCH64_PREL16 and R_AARCH64_PREL32 relocations.

Diff Detail

Event Timeline

ikudrin updated this revision to Diff 40919.Nov 23 2015, 5:58 AM
ikudrin retitled this revision from to [ELF/AArch64] Factor out overflow check into a separate function..
ikudrin updated this object.
ikudrin added reviewers: ruiu, davide.
ikudrin added a project: lld.
ikudrin added a subscriber: llvm-commits.
davide edited edge metadata.Nov 23 2015, 8:32 AM

This, in principle, seems reasonable. I wonder if we can extend the check also to other targets (e.g. x86_64), but maybe that can be done later.

davide accepted this revision.Nov 23 2015, 8:33 AM
davide edited edge metadata.
davide added inline comments.
ELF/Target.cpp
785

This and PREL16 fix bugs (changing the argument of check from SA to SA - P). I'd commit that separately, because it's a functional change.

This revision is now accepted and ready to land.Nov 23 2015, 8:33 AM
This revision was automatically updated to reflect the committed changes.
ruiu edited edge metadata.Nov 23 2015, 10:04 AM

I'm not in favor of this change, and I wouldn't do that. The previous code was super clear that it errors if isInt check fails. Now you have to take a look at the definition of checkAArch64OutOfRange function. You saved one line per a function call, but it doesn't seem like a good tradeoff from code readability point of view.