@@ -302,7 +302,7 @@ _dl_load_cache_lookup (const char *name)
char *temp;
temp = alloca (strlen (best) + 1);
strcpy (temp, best);
- return strdup (temp);
+ return __strdup (temp);
}
#ifndef MAP_COPY
@@ -149,7 +149,7 @@ rcmd_af (char **ahost, u_short rport, const char *locuser, const char *remuser,
if (res->ai_canonname){
free (ahostbuf);
- ahostbuf = strdup (res->ai_canonname);
+ ahostbuf = __strdup (res->ai_canonname);
if (ahostbuf == NULL) {
__fxprintf(NULL, "%s",
_("rcmd: Cannot allocate memory\n"));
@@ -73,7 +73,7 @@ rexec_af (char **ahost, int rport, const char *name, const char *pass,
if (res0->ai_canonname){
free (ahostbuf);
- ahostbuf = strdup (res0->ai_canonname);
+ ahostbuf = __strdup (res0->ai_canonname);
if (ahostbuf == NULL) {
perror ("rexec: strdup");
return (-1);
@@ -131,6 +131,7 @@ extern int errno;
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
+# define strdup __strdup
# define getcwd __getcwd
# ifndef stpcpy
# define stpcpy __stpcpy
@@ -124,18 +124,12 @@ _nl_find_domain (const char *dirname, char *locale,
alias_value = _nl_expand_alias (locale);
if (alias_value != NULL)
{
-#if defined _LIBC || defined HAVE_STRDUP
- locale = strdup (alias_value);
- if (locale == NULL)
- return NULL;
-#else
size_t len = strlen (alias_value) + 1;
locale = (char *) malloc (len);
if (locale == NULL)
return NULL;
memcpy (locale, alias_value, len);
-#endif
}
/* Now we determine the single parts of the locale name. First
@@ -462,7 +462,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (__glibc_unlikely (lia == NULL))
return NULL;
- lia->name = strdup (*namep);
+ lia->name = __strdup (*namep);
if (__glibc_unlikely (lia->name == NULL))
{
free (lia);
@@ -283,7 +283,7 @@ setlocale (int category, const char *locale)
if (__glibc_unlikely (strchr (locale, ';') != NULL))
{
/* This is a composite name. Make a copy and split it up. */
- locale_copy = strdup (locale);
+ locale_copy = __strdup (locale);
if (__glibc_unlikely (locale_copy == NULL))
{
__libc_rwlock_unlock (__libc_setlocale_lock);
@@ -34,7 +34,7 @@ posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *file_actions,
if (!__spawn_valid_fd (fd))
return EBADF;
- char *path_copy = strdup (path);
+ char *path_copy = __strdup (path);
if (path_copy == NULL)
return ENOMEM;
@@ -60,7 +60,7 @@ putenv (char *string)
int use_malloc = !__libc_use_alloca (name_end - string + 1);
if (__builtin_expect (use_malloc, 0))
{
- name = strndup (string, name_end - string);
+ name = __strndup (string, name_end - string);
if (name == NULL)
return -1;
}
@@ -87,7 +87,7 @@ __registerrpc (u_long prognum, u_long versnum, u_long procnum,
transp = svcudp_create (RPC_ANYSOCK);
if (transp == NULL)
{
- buf = strdup (_("couldn't create an rpc server\n"));
+ buf = __strdup (_("couldn't create an rpc server\n"));
goto err_out;
}
}
@@ -103,7 +103,7 @@ __registerrpc (u_long prognum, u_long versnum, u_long procnum,
pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
if (pl == NULL)
{
- buf = strdup (_("registerrpc: out of memory\n"));
+ buf = __strdup (_("registerrpc: out of memory\n"));
goto err_out;
}
pl->p_progname = progname;
@@ -536,7 +536,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
}
else
{
- namebuf = strndup (name, scope_delim - name);
+ namebuf = __strndup (name, scope_delim - name);
if (namebuf == NULL)
{
assert (!malloc_name);
@@ -1139,7 +1139,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
malloc_canonbuf = false;
else
{
- canon = strdup (canon);
+ canon = __strdup (canon);
if (canon == NULL)
{
result = -EAI_MEMORY;
ping (added mention of BZ tickets) From: Wilco Dijkstra Sent: 11 January 2017 16:02 To: libc-alpha@sourceware.org Cc: nd Subject: [PATCH] Rename strdup uses Rename existing uses of str(n)dup to __str(n)dup so it no longer needs to be redirected to a builtin. Also building GLIBC with -Os now no longer shows localplt or linkname space failures (partial fix for BZ #15105 and BZ #19463). Although this means a loss of inlining (based on current committed headers) in 2 cases, these are both error messages so not performance critical. ChangeLog: 2017-01-11 Wilco Dijkstra <wdijkstr@arm.com> [BZ #15105] [BZ #19463] * elf/dl-cache.c (_dl_load_cache_lookup): Use __strdup. * inet/rcmd.c (rcmd_af): Likewise. * inet/rexec.c (rexec_af): Likewise. * intl/dcigettext.c (_LIBC): Likewise. * intl/finddomain.c (_nl_find_domain): Use strdup expansion. * locale/loadarchive.c (_nl_load_locale_from_archive): Use __strdup. * locale/setlocale.c (setlocale): Likewise. * posix/spawn_faction_addopen.c (posix_spawn_file_actions_addopen): Likewise. * stdlib/putenv.c (putenv): Use __strndup. * sunrpc/svc_simple.c (__registerrpc): Use __strdup. * sysdeps/posix/getaddrinfo.c (gaih_inet): Use __strdup/__strndup. --