On Wed, 19 Jul 2017, Jeff Law wrote: > > Glibc people were worried that attribute would be lost when taking a > > pointer to function > > (https://sourceware.org/ml/libc-alpha/2017-01/msg00482.html). I think > > their reasoning was that return address is a shadow argument for > > dlsym-like functions so this would cause a (most likely inadvertent) > > ABI error. > Fair enough, but does the right thing happen if the function's > definition is decorated? Can you add a test for that in the testsuite?
How would passing pointers to dlsym via a 'void *' work after this patch? Honestly, if the goal is to assist users of GCC (and not only Glibc users, but also people compiling against Bionic/musl/BSD libcs, which probably wouldn't adopt this attribute), may I suggest that a clearer course of action would be to: 1) recognize dlsym by name and suppress tailcalls to it this would solve >99% cases because calling dlsym by pointer would be rare, and has the benefit of not requiring libc header changes; and 2) if we really want to offer some generic solution, can we give the users a way to suppress tailcalls via a builtin? That is, introduce foo = __builtin_notailcall (func (args)) I think this would allow libc headers to do #define dlsym(sym, mod) __builtin_notailcall (dlsym (sym, mod)) I'm sorry for bringing up objections late, but I really ask for alternatives to be considered, and I can take a stab at implementing either of the above if the general course is agreed upon. Alexander