Page MenuHomePhabricator

[AArch64] SLSHardening: compute correct thunk name for X29.
ClosedPublic

Authored by kristof.beyls on Jun 17 2020, 2:34 AM.

Details

Summary

The enum values for AArch64 registers are not all consecutive.
Therefore, the computation
"__llvm_slsblr_thunk_x" + utostr(Reg - AArch64::X0)
is not always correct. utostr(Reg - AArch64::X0) will not generate the
expected string for the registers that do not have consecutive values in
the enum.
This happened to work for most registers, but does not for AArch64::FP
(i.e. register X29).
This can get triggered when the X29 is not used as a frame pointer.

Diff Detail

Event Timeline

kristof.beyls created this revision.Jun 17 2020, 2:34 AM
ostannard added inline comments.Jun 17 2020, 2:46 AM
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
144–145

I think it would be better to change these two arrays into one array of structs, so that the relationship between them is more obvious.

189

Could just return SLSBLRThunkNames[i] here.

200

Same as above,

Updated version based on @ostannard feedback.

kristof.beyls marked 6 inline comments as done.Jun 17 2020, 6:44 AM
kristof.beyls added inline comments.
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
144–145

Yes, agreed. Thanks for the suggestion. I think it made the code quite a bit nicer.

189

After changing the structure of SLSBLRThunks, it seemed better to just search inline using llvm::find_if rather than in a separate function, so this comment does not apply anymore to the new version of the code.

200

Same reply as above too.

This revision is now accepted and ready to land.Jun 17 2020, 7:41 AM
This revision was automatically updated to reflect the committed changes.
kristof.beyls marked 3 inline comments as done.