[RFC] Prevent tailcall optimizations of libdl functions

Rich Felker bugdal@aerifal.cx
Wed Jan 25 16:58:00 GMT 2017


On Wed, Jan 25, 2017 at 04:59:29PM +0100, Florian Weimer wrote:
> On 01/25/2017 04:57 PM, Szabolcs Nagy wrote:
> 
> >it's not p=dlsym(); but p=dlsym;
> 
> Yeah, right.  That's what I was missing.
> 
> I think the best we can do in this case is to preserve the attribute
> in the function pointer (if __typeof__ is used).

Obviously portable code declaring a pointer to dlsym is going to use
the documented signature, not __typeof__ or a custom attribute.

Perhaps a better solution than these hacks it just to specify that
RTLD_NEXT has undefined behavior if dlsym is called via a function
pointer expression which is not a constant expression. (Technically,
under C99 and later, in normal call dlsym(...), the () operator is
applied to a function pointer -- the one dlsym decays to -- so you
can't just say using function pointers is undefined.)

Rich



More information about the Libc-alpha mailing list