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.
Re:OpenBSD: Mandatory enforcement of indirect branch targets
by MobiusHorizons on Friday July 14, 2023 @10:42AM
(#36724692)
Is this theoretically something lto could remove?
Re:OpenBSD: Mandatory enforcement of indirect branch targets
by tedunangst on Friday July 14, 2023 @01:44PM
(#36727378)
If you disable dlopen and ld_preload.
Re:OpenBSD: Mandatory enforcement of indirect branch targets
by codedokode on Friday July 14, 2023 @06:15PM
(#36730687)
Dlopen() "sees" only functions marked as exported (with macro like DLLEXPORT on Windows), not every function or am I wrong? Is C that bad?
Re:OpenBSD: Mandatory enforcement of indirect branch targets
by tedunangst on Friday July 14, 2023 @06:24PM
(#36730750)
On openbsd at least, every global symbol is exported unless you use an explicit symbol list. It's unusual for executables.
And no, as I understand it, this is only for branch/calls not returns.