[PATCH] D138337: Add support for kcfi-seal optimization with LTO

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 19 17:06:34 PST 2022


MaskRay added a comment.

(Sorry for my belated response.)

If we make ThinLTO properly track combined the address-taken property, and combine precise `addressTaken` and `VisibleToRegularObj`, it seems that we can use this condition to decide whether ENDBR is needed with an appropriate code model:

`F.hasAddressTaken() || (!F.hasLocalLinkage() && (VisibleToRegularObj || !F.hasHiddenVisibility()))`

(For AArch64, even an local linkage symbol may be reached by a range extension thunk. For x86-64 we can rule out range extension thunks, but there is a caution, as internally I know pending feature requests to use range extension thunks even for small code model to decrease relocation overflow pressure.)

Then we don't even need another compiler option like `-mibt-seal`. The Linux kernel `Makefile` uses `-fvisibility=hidden` for Clang LTO. I think it can use `-fvisibility=hidden` for non-LTO as well, if it doesn't have dynamic linking semantics.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138337/new/

https://reviews.llvm.org/D138337



More information about the cfe-commits mailing list