This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2.25] powerpc: Avoid calling strncmp via PLT on GCC 7


* Joseph Myers:

> On Mon, 16 Jan 2017, Aaron Sawdey wrote:
>
>> Tulio,
>>   I'll be posting an updated version of that patch shortly that
>> addresses the issues you were seeing. However it adds builtin expansion
>> of both strncmp and strcmp so I think your patch needs to add both to
>> powerpc/symbol-hacks.h. Here is what I get from check-localplt with
>> gcc7 plus this patch:
>> 
>> cat /home/sawdey/src/glibc/build/elf/check-localplt.out
>> Extra PLT reference: libc.so: strcmp
>> Extra PLT reference: libc.so: strncmp
>
> On further consideration: I don't think addressing this in GCC should be 
> hard, can't you just look up something like DECL_ASSEMBLER_NAME 
> (builtin_decl_explicit (BUILT_IN_STRNCMP)) or similar and use that instead 
> of hardcoded strncmp when generating code?

Right.  I forgot that GCC does exactly this for other builtins.  We
even have a configure check:

AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
cat > conftest.c <<\EOF
extern char *strstr (const char *, const char *) __asm ("my_strstr");
char *foo (const char *a, const char *b)
{
  return __builtin_strstr (a, b);
}
EOF
dnl
if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "my_strstr" > /dev/null]);
then
  libc_cv_gcc_builtin_redirection=yes
else
  libc_cv_gcc_builtin_redirection=no
fi
rm -f conftest* ])
if test "$libc_cv_gcc_builtin_redirection" = no; then
  AC_MSG_ERROR([support for the symbol redirection needed])
fi

So you are right that this should be fixed in GCC.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]