glibc/include
Joseph Myers 939da41143 Fix stpcpy / mempcpy namespace (bug 17573).
Various glibc functions call __stpcpy and __mempcpy for namespace
reasons instead of plain stpcpy and mempcpy.  But __stpcpy and
__mempcpy are macros that call __builtin_stpcpy and __builtin_mempcpy,
and unless GCC optimizes the calls, they end up calling the C
functions stpcpy and mempcpy.

For calls from within shared libc, libc_hidden_builtin_proto ensures
that calls to those C functions are in turn mapped to call __GI_stpcpy
and __GI_mempcpy.  However, for static libc, and for calls from shared
libraries other than libc, the ELF symbols stpcpy and mempcpy end up
getting called, breaking the ISO C namespace (in the case of stpcpy)
or glibc conventions about not relying on the "future library
directions" reservations (in the case of mempcpy).

This patch fixes this by adding declarations of these functions to
include/string.h, under an appropriate condition, with __asm__ used to
change the assembler name used for calls (the mempcpy case was
previously discussed, and the approach for the fix is as I suggested
in <https://sourceware.org/ml/libc-alpha/2013-02/msg00063.html>).

Tested for x86_64 with the testsuite; also checked that dcigettext.o
(an example previously noted of undesired calls to stpcpy and mempcpy)
now calls __stpcpy and __mempcpy instead, as do non-libc shared
libraries (__stpcpy and __mempcpy were already exported from shared
libc).  Disassembly of installed shared libraries isn't easy to
compare because of reordered PLT entries resulting from the change in
functions called (libnsl, libnss_compat, libnss_dns, libnss_files,
libnss_hesiod, libnss_nis, libnss_nisplus, libpthread, librt all have
such changes).

	[BZ #17573]
	* include/string.h [NOT_IN_libc || !SHARED] (mempcpy): Declare
	with asm name __mempcpy.
	[NOT_IN_libc || !SHARED] (stpcpy): Declare with asm name __stpcpy.
2014-11-12 22:36:34 +00:00
..
arpa Add first fixes for conformtest for POSIX2008 2012-02-26 21:32:56 -05:00
bits Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
gnu Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
net First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
netinet First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
programs Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
protocols
rpc Avoid use of "register" as optimization hint. 2013-06-07 22:24:35 +00:00
rpcsvc
sys Remove __libc_waitpid function name. 2014-11-07 01:27:16 +00:00
aio.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
aliases.h Remove pre-ISO C support 2012-01-07 23:57:22 -05:00
alloca.h Account for alloca size rounding in extend_alloca 2011-11-01 18:29:34 +01:00
argp.h
argz.h Remove use of INTDEF/INTUSE in intl 2012-05-24 23:08:18 +02:00
assert.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
atomic.h Use glibc_likely instead __builtin_expect. 2014-02-10 15:07:12 +01:00
byteswap.h
caller.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
complex.h conformtest: Fix namespace testing. 2013-09-04 20:47:21 +00:00
ctype.h Clean up internal ctype.h header. 2014-10-30 14:00:26 -07:00
des.h
dirent.h Fix __getcwd rewinddir namespace (bug 17584). 2014-11-12 16:24:16 +00:00
dlfcn.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
elf.h Check supported DF_1_XXX bits 2012-11-21 06:33:19 -08:00
endian.h
envz.h
err.h
errno.h Compile with -Wundef. 2014-03-14 11:32:51 -07:00
error.h
execinfo.h Remove pre-ISO C support 2012-01-07 23:57:22 -05:00
fcntl.h Remove __libc_creat function name. 2014-10-30 19:44:31 +00:00
features.h Update version.h and include/features.h for 2.20 release 2014-09-07 18:09:09 +10:00
fenv.h Fix dbl-64 e_sqrt.c for non-default rounding modes (bug 16271). 2013-11-28 16:50:38 +00:00
fnmatch.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
fpu_control.h
ftw.h
gconv.h
getopt.h
getopt_int.h
glob.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
gmp.h
gnu-versions.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
grp.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
gshadow.h
iconv.h
ifaddrs.h Cache network interface information 2011-10-31 01:51:16 -04:00
ifunc-impl-list.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
inline-hashtab.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
langinfo.h Add first fixes for conformtest for POSIX2008 2012-02-26 21:32:56 -05:00
libc-internal.h libc-internal.h: add ALIGN helper macros 2013-06-24 20:25:15 -04:00
libc-symbols.h Remove INTDEF / INTUSE / INTVARDEF (bug 14132). 2014-11-05 23:35:36 +00:00
libgen.h
libintl.h Remove use of INTDEF/INTUSE in intl 2012-05-24 23:08:18 +02:00
libio.h Remove use of INTDEF/INTUSE in libio 2012-05-24 23:06:20 +02:00
limits.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
link.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
list.h Get rid of nptl/sysdeps/pthread/ subdirectory 2014-06-12 13:48:47 -07:00
locale.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
malloc.h
math.h New <math.h> macro named issignaling to check for a signaling NaN (sNaN). 2013-04-02 13:51:02 +02:00
mcheck.h
memory.h
mntent.h Remove use of INTUSE/INTDEF in misc. 2012-05-31 13:10:02 +02:00
monetary.h Add first fixes for conformtest for POSIX2008 2012-02-26 21:32:56 -05:00
mqueue.h
netdb.h Clean up h_errno declaration to use __thread unconditionally. 2013-08-27 11:09:33 -07:00
netgroup.h
nl_types.h
nss.h
nsswitch.h
obstack.h
poll.h
printf.h
pthread.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
pty.h
pwd.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
regex.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
resolv.h Properly fix memory leak in _nss_dns_gethostbyname4_r with big DNS answer 2014-02-19 14:39:21 +01:00
rounding-mode.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
sched.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
search.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
set-hooks.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
setjmp.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
sgtty.h
shadow.h Remove pre-ISO C support 2012-01-07 23:57:22 -05:00
shlib-compat.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
signal.h Avoid comma operator warnings. 2014-02-07 15:26:28 -08:00
spawn.h
stab.h
stackinfo.h Compile with -Wundef. 2014-03-14 11:32:51 -07:00
stap-probe.h include/stap-probe.h: Add comment about SystemTap argument format 2014-02-11 10:17:11 +00:00
stdc-predef.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
stdio.h Fix tzfile.c namespace (bug 17583). 2014-11-12 16:22:51 +00:00
stdio_ext.h Remove use of INTDEF/INTUSE in libio 2012-05-24 23:06:20 +02:00
stdlib.h Fix qsort_r namespace (bug 17571). 2014-11-12 22:33:41 +00:00
string.h Fix stpcpy / mempcpy namespace (bug 17573). 2014-11-12 22:36:34 +00:00
strings.h
stropts.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
stubs-prologue.h
syscall.h
sysexits.h
syslog.h
tar.h
termios.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
tgmath.h
time.h Fix symbol definitions for __clock_* functions 2013-06-11 11:11:11 +05:30
ttyent.h
uchar.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
ucontext.h
ulimit.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
unistd.h Don't use INTVARDEF/INTUSE with __libc_enable_secure (bug 14132). 2014-10-10 11:13:11 +00:00
utime.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
utmp.h Remove pre-ISO C support 2012-01-07 23:57:22 -05:00
values.h Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
wchar.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
wctype.h Remove stray *_internal aliases (bug 14132). 2014-10-09 01:11:14 +00:00
wordexp.h First steps to get conformtest fully working 2012-02-25 23:18:39 -05:00
xlocale.h