https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84908
--- Comment #11 from Jason Vas Dias <jason.vas.dias at gmail dot com> --- In reply to Comment #9 : Thanks Andy - I think it is because when the retpoline flags are enabled , the 'static inline' function calls in vclock_gettime.c have default function attributes which differ from those that __vdso_clock_gettime ( the function containing the switch ) gets, so GCC finds it must instantiate a callable version of the normally static inline function calls this function makes, and generates relocations for them which are not getting copied into the VDSO for some reason. Rather than making more radical changes to the VDSO assembly code to handle these types of relocations, I think it is better to avoid them being generated by either: A) compiling vclock_gettime.c without '-mindirect-branch=thunk-extern -mindirect-branch-register -DRETPOLINE' (rejected by Andi Kleen) B) Specifying ALL entry points that __vdso_clock_gettime calls to have attributes that do not require relocation for GCC to handle if the above flags are in effect: #ifdef RETPOLINE +# define _NO_THUNK_RELOCS_()(indirect_branch("keep"),\ + function_return("keep")) +# define _RETPOLINE_FUNC_ATTR_ __attribute__(_NO_THUNK_RELOCS_()) +# define _RETPOLINE_INLINE_ inline +#else +# define _RETPOLINE_FUNC_ATTR_ +# define _RETPOLINE_INLINE_ __always_inline +#endif So then one declares any function called by __vdso_clock_gettime() like: notrace static _RETPOLINE_FUNC_ATTR_ _RETPOLINE_INLINE_ int do_monotonic_raw( int clock, struct timespec *ts ) { ... } and then must declare notrace int _RETPOLINE_FUNC_ATTR_ __vdso_clock_gettime(clockid_t clock, struct timespec *ts) {... do_monotonic_raw(ts); ...} to avoid the relocations being generated. I did submit a patch to vclock_gettime.c to do this - should I re-submit it? Or one could fix the code which produces the resulting vdso to include the generated (unecessary and redundant) relocations, or generate the relocation functions in assembler somehow, but I don't think this is the way the VDSO should go. There is no reason to make functions in the VDSO have function attributes indirect_branch("thunk-extern,register") - they always WILL generate relocations if more that 5 such calls are made in same switch, with all current versions of GCC, it seems. Every function that directly invokes these functions (in glibc), must also have these function attributes, which are entirely unnecessary and inefficient compared to the indirect_branch("keep") style; and those relocations then must be in the VDSO for callers to invoke.