[PATCH v8 2/3] String: Add hidden defs for __memcmpeq() to enable internal usage
Joseph Myers
joseph@codesourcery.com
Mon Oct 25 16:41:17 GMT 2021
On Thu, 21 Oct 2021, H.J. Lu via Libc-alpha wrote:
> On Thu, Oct 21, 2021 at 5:19 PM Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Thu, 21 Oct 2021, Noah Goldstein via Libc-alpha wrote:
> >
> > > > > The compiler knows other semantics of memcmp (it might sometimes expand a
> > > > > memcmp with a small fixed size inline, for example). So changing to a
> > > > > direct call to __memcmpeq by hand isn't even always an optimization;
> > > Will compilers not implement the same optimization for __memcmpeq?
> >
> > Why should they? It's intended as an ABI, not an API - that is, an
> > alternative assembler name the compiler name generate calls to, not a
> > function for which it should find calls in its input.
> >
>
> Compiler builtin optimization doesn't work well for glibc:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67220
1. So let's fix that in the compiler. This doesn't seem like something so
hard to fix that it should justify obfuscating the source code in glibc by
putting in unnecessary direct calls to an internal name.
2. If we need a single redirection of __memcmpeq to the hidden alias
__GI___memcmpeq, we could certainly put that in
sysdeps/generic/symbol-hacks.h as we do for a few other functions. A
redirection like that in one place isn't problematic the same way putting
in lots of direct calls to an internal name in the source code (for
something better optimized in the compiler) is.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list