News for hackers. Stuff that matters.
Re:OpenBSD: Mandatory enforcement of indirect branch targets by Joker_vD on Friday July 14, 2023 @10:35AM (#36724590)
Well, if the function is marked "static", the compiler can actually check whether the function's address is taken in the current compilation unit or not and omit/emit ENDBR64 accordingly (passing pointers to static functions to code in another compilation units is legal, and should still work).
Re:OpenBSD: Mandatory enforcement of indirect branch targets by messe on Friday July 14, 2023 @10:40AM (#36724656)
Good catch. Yeah, as long as the functions address is never taken the compiler has a lot of leeway with static functions; it can even avoid emitting code for them entirely if it can prove their never called or if it's able to compute their results at compile-time.
Re:OpenBSD: Mandatory enforcement of indirect branch targets by josephg on Friday July 14, 2023 @11:46AM (#36725655)
Yep. Or inline them at every call site if that makes sense to do based on the optimization level and flags.