https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113082
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #4 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
re. comment #3, you'd need to be careful to avoid miscompiling
#include <stdlib.h>
int f(size_t sz, void **out, int *eptr)
{
int e = *eptr;
*out = malloc(sz);
return *eptr - e;
}
to asm that unconditionally returns 0, because that changes the outcome for
errno = 0;
f(SIZE_MAX, &ptr, &errno);
IOW, I'm not sure how you can go beyond TBAA since user code can pass around
the address of errno in a plain 'int *' anyway.
re. comment #2, Glibc has
* lazy PLT resolver calling back into the dynamic linker
* LD_AUDIT callbacks
* LD_PROFILE hooks
* IFUNC resolvers
and you'd have to guarantee they won't clobber errno either. For lazy PLT and
LD_PROFILE it is necessary anyway (otherwise it's a Glibc bug), but audit and
ifunc callbacks are provided by the user, not Glibc, and might accidentally
clobber errno.