From c8272cfe989ac7ae7cdd1708d65f0af603ff2f8c Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sun, 13 Sep 2015 08:31:48 +0000 Subject: [PATCH] Wrap so that calls go direct and the symbols not in the C standard are all weak. Apply __{BEGIN,END}_HIDDEN_DECLS to gdtoa{,imp}.h, hiding the arch-specific __strtorx, __ULtox_D2A, __strtorQ, __ULtoQ_D2A symbols. --- src/lib/libc/crypt/arc4random.c | 4 +++- src/lib/libc/crypt/arc4random_uniform.c | 3 ++- src/lib/libc/stdlib/abort.c | 3 ++- src/lib/libc/stdlib/abs.c | 3 ++- src/lib/libc/stdlib/atoi.c | 3 ++- src/lib/libc/stdlib/div.c | 3 ++- src/lib/libc/stdlib/erand48.c | 3 ++- src/lib/libc/stdlib/exit.c | 3 ++- src/lib/libc/stdlib/getenv.c | 4 ++-- src/lib/libc/stdlib/lcong48.c | 3 ++- src/lib/libc/stdlib/malloc.c | 9 ++++++++- src/lib/libc/stdlib/qsort.c | 3 ++- src/lib/libc/stdlib/rand.c | 1 + src/lib/libc/stdlib/reallocarray.c | 3 ++- src/lib/libc/stdlib/setenv.c | 7 ++++--- src/lib/libc/stdlib/srand48.c | 3 ++- src/lib/libc/stdlib/strtol.c | 3 ++- src/lib/libc/stdlib/strtoll.c | 5 +++-- src/lib/libc/stdlib/strtonum.c | 3 ++- src/lib/libc/stdlib/strtoul.c | 3 ++- src/lib/libc/stdlib/strtoull.c | 5 +++-- src/lib/libc/stdlib/system.c | 3 ++- 22 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c index 5afc6a15..8a4ecc9e 100644 --- a/src/lib/libc/crypt/arc4random.c +++ b/src/lib/libc/crypt/arc4random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random.c,v 1.53 2015/09/10 18:53:50 bcook Exp $ */ +/* $OpenBSD: arc4random.c,v 1.54 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1996, David Mazieres @@ -186,6 +186,7 @@ arc4random(void) _ARC4_UNLOCK(); return val; } +DEF_WEAK(arc4random); void arc4random_buf(void *buf, size_t n) @@ -194,3 +195,4 @@ arc4random_buf(void *buf, size_t n) _rs_random_buf(buf, n); _ARC4_UNLOCK(); } +DEF_WEAK(arc4random_buf); diff --git a/src/lib/libc/crypt/arc4random_uniform.c b/src/lib/libc/crypt/arc4random_uniform.c index 1aa9a622..23a15e34 100644 --- a/src/lib/libc/crypt/arc4random_uniform.c +++ b/src/lib/libc/crypt/arc4random_uniform.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random_uniform.c,v 1.1 2014/07/12 13:24:54 deraadt Exp $ */ +/* $OpenBSD: arc4random_uniform.c,v 1.2 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 2008, Damien Miller @@ -54,3 +54,4 @@ arc4random_uniform(uint32_t upper_bound) return r % upper_bound; } +DEF_WEAK(arc4random_uniform); diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c index dd057710..903bfa78 100644 --- a/src/lib/libc/stdlib/abort.c +++ b/src/lib/libc/stdlib/abort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abort.c,v 1.17 2014/05/14 21:54:20 tedu Exp $ */ +/* $OpenBSD: abort.c,v 1.18 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. @@ -61,3 +61,4 @@ abort(void) (void)raise(SIGABRT); _exit(1); } +DEF_STRONG(abort); diff --git a/src/lib/libc/stdlib/abs.c b/src/lib/libc/stdlib/abs.c index 5d2fbae6..0e39cc55 100644 --- a/src/lib/libc/stdlib/abs.c +++ b/src/lib/libc/stdlib/abs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abs.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: abs.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -35,3 +35,4 @@ abs(int j) { return(j < 0 ? -j : j); } +DEF_STRONG(abs); diff --git a/src/lib/libc/stdlib/atoi.c b/src/lib/libc/stdlib/atoi.c index b0842678..7c9eb133 100644 --- a/src/lib/libc/stdlib/atoi.c +++ b/src/lib/libc/stdlib/atoi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atoi.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: atoi.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -35,3 +35,4 @@ atoi(const char *str) { return((int)strtol(str, (char **)NULL, 10)); } +DEF_STRONG(atoi); diff --git a/src/lib/libc/stdlib/div.c b/src/lib/libc/stdlib/div.c index f7ac2db4..beaa428c 100644 --- a/src/lib/libc/stdlib/div.c +++ b/src/lib/libc/stdlib/div.c @@ -1,4 +1,4 @@ -/* $OpenBSD: div.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: div.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. @@ -69,3 +69,4 @@ div(int num, int denom) } return (r); } +DEF_STRONG(div); diff --git a/src/lib/libc/stdlib/erand48.c b/src/lib/libc/stdlib/erand48.c index 2ffeaa6e..20d6a2dd 100644 --- a/src/lib/libc/stdlib/erand48.c +++ b/src/lib/libc/stdlib/erand48.c @@ -1,4 +1,4 @@ -/* $OpenBSD: erand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: erand48.c,v 1.4 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier * All rights reserved. @@ -22,3 +22,4 @@ erand48(unsigned short xseed[3]) ldexp((double) xseed[1], -32) + ldexp((double) xseed[2], -16); } +DEF_WEAK(erand48); diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c index 83fe3d2d..d30b91ed 100644 --- a/src/lib/libc/stdlib/exit.c +++ b/src/lib/libc/stdlib/exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exit.c,v 1.12 2007/09/03 14:40:16 millert Exp $ */ +/* $OpenBSD: exit.c,v 1.13 2015/09/13 08:31:47 guenther Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -57,3 +57,4 @@ exit(int status) __cxa_finalize(NULL); _exit(status); } +DEF_STRONG(exit); diff --git a/src/lib/libc/stdlib/getenv.c b/src/lib/libc/stdlib/getenv.c index fd8482e9..6ddad922 100644 --- a/src/lib/libc/stdlib/getenv.c +++ b/src/lib/libc/stdlib/getenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getenv.c,v 1.10 2010/08/23 22:31:50 millert Exp $ */ +/* $OpenBSD: getenv.c,v 1.11 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1987, 1993 * The Regents of the University of California. All rights reserved. @@ -31,7 +31,6 @@ #include #include -char *__findenv(const char *name, int len, int *offset); /* * __findenv -- @@ -79,3 +78,4 @@ getenv(const char *name) ; return (__findenv(name, (int)(np - name), &offset)); } +DEF_STRONG(getenv); diff --git a/src/lib/libc/stdlib/lcong48.c b/src/lib/libc/stdlib/lcong48.c index 5b297ddb..f03083e3 100644 --- a/src/lib/libc/stdlib/lcong48.c +++ b/src/lib/libc/stdlib/lcong48.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcong48.c,v 1.5 2015/08/27 04:33:31 guenther Exp $ */ +/* $OpenBSD: lcong48.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier * All rights reserved. @@ -33,3 +33,4 @@ lcong48_deterministic(unsigned short p[7]) __rand48_mult[2] = p[5]; __rand48_add = p[6]; } +DEF_WEAK(lcong48_deterministic); diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 5e5dafbd..0967fe3a 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.174 2015/04/06 09:18:51 tedu Exp $ */ +/* $OpenBSD: malloc.c,v 1.175 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 2008, 2010, 2011 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -211,6 +211,7 @@ extern char *__progname; #ifdef MALLOC_STATS void malloc_dump(int); +PROTO_NORMAL(malloc_dump); static void malloc_exit(void); #define CALLER __builtin_return_address(0) #else @@ -1186,6 +1187,7 @@ malloc(size_t size) errno = saved_errno; return r; } +DEF_STRONG(malloc); static void ofree(void *p) @@ -1289,6 +1291,7 @@ free(void *ptr) _MALLOC_UNLOCK(); errno = saved_errno; } +DEF_STRONG(free); static void * @@ -1429,6 +1432,7 @@ realloc(void *ptr, size_t size) errno = saved_errno; return r; } +DEF_STRONG(realloc); /* @@ -1476,6 +1480,7 @@ calloc(size_t nmemb, size_t size) errno = saved_errno; return r; } +DEF_STRONG(calloc); static void * mapalign(struct dir_info *d, size_t alignment, size_t sz, int zero_fill) @@ -1609,6 +1614,7 @@ err: errno = saved_errno; return res; } +DEF_STRONG(posix_memalign); #ifdef MALLOC_STATS @@ -1853,6 +1859,7 @@ malloc_dump(int fd) malloc_dump1(fd, pool); errno = saved_errno; } +DEF_WEAK(malloc_dump); static void malloc_exit(void) diff --git a/src/lib/libc/stdlib/qsort.c b/src/lib/libc/stdlib/qsort.c index 2a51c776..1d9b1e91 100644 --- a/src/lib/libc/stdlib/qsort.c +++ b/src/lib/libc/stdlib/qsort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qsort.c,v 1.12 2014/06/12 14:54:25 millert Exp $ */ +/* $OpenBSD: qsort.c,v 1.13 2015/09/13 08:31:47 guenther Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -149,3 +149,4 @@ loop: SWAPINIT(a, es); } /* qsort(pn - r, r / es, es, cmp);*/ } +DEF_STRONG(qsort); diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c index f163581e..7054b81c 100644 --- a/src/lib/libc/stdlib/rand.c +++ b/src/lib/libc/stdlib/rand.c @@ -39,6 +39,7 @@ rand_r(u_int *seed) *seed = *seed * 1103515245 + 12345; return (*seed % ((u_int)RAND_MAX + 1)); } +DEF_WEAK(rand_r); #if defined(APIWARN) __warn_references(rand_r, diff --git a/src/lib/libc/stdlib/reallocarray.c b/src/lib/libc/stdlib/reallocarray.c index ed3244e2..baea252a 100644 --- a/src/lib/libc/stdlib/reallocarray.c +++ b/src/lib/libc/stdlib/reallocarray.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */ +/* $OpenBSD: reallocarray.c,v 1.3 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 2008 Otto Moerbeek * @@ -36,3 +36,4 @@ reallocarray(void *optr, size_t nmemb, size_t size) } return realloc(optr, size * nmemb); } +DEF_WEAK(reallocarray); diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c index 10b55445..e55a1feb 100644 --- a/src/lib/libc/stdlib/setenv.c +++ b/src/lib/libc/stdlib/setenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setenv.c,v 1.15 2014/10/08 05:33:31 deraadt Exp $ */ +/* $OpenBSD: setenv.c,v 1.16 2015/09/13 08:31:47 guenther Exp $ */ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. @@ -32,8 +32,6 @@ #include #include -char *__findenv(const char *name, int len, int *offset); - extern char **environ; static char **lastenv; /* last value of environ */ @@ -81,6 +79,7 @@ putenv(char *str) environ[cnt + 1] = NULL; return (0); } +DEF_WEAK(putenv); /* * setenv -- @@ -147,6 +146,7 @@ setenv(const char *name, const char *value, int rewrite) ; return (0); } +DEF_WEAK(setenv); /* * unsetenv(name) -- @@ -178,3 +178,4 @@ unsetenv(const char *name) } return (0); } +DEF_WEAK(unsetenv); diff --git a/src/lib/libc/stdlib/srand48.c b/src/lib/libc/stdlib/srand48.c index ce4b4522..d41391d4 100644 --- a/src/lib/libc/stdlib/srand48.c +++ b/src/lib/libc/stdlib/srand48.c @@ -1,4 +1,4 @@ -/* $OpenBSD: srand48.c,v 1.5 2015/08/27 04:33:31 guenther Exp $ */ +/* $OpenBSD: srand48.c,v 1.6 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier * All rights reserved. @@ -35,3 +35,4 @@ srand48_deterministic(long seed) __rand48_mult[2] = RAND48_MULT_2; __rand48_add = RAND48_ADD; } +DEF_WEAK(srand48_deterministic); diff --git a/src/lib/libc/stdlib/strtol.c b/src/lib/libc/stdlib/strtol.c index 86cec350..49465e28 100644 --- a/src/lib/libc/stdlib/strtol.c +++ b/src/lib/libc/stdlib/strtol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtol.c,v 1.10 2014/09/13 20:10:12 schwarze Exp $ */ +/* $OpenBSD: strtol.c,v 1.11 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -148,3 +148,4 @@ strtol(const char *nptr, char **endptr, int base) *endptr = (char *) (any ? s - 1 : nptr); return (acc); } +DEF_STRONG(strtol); diff --git a/src/lib/libc/stdlib/strtoll.c b/src/lib/libc/stdlib/strtoll.c index cf82c8e1..0ba51da7 100644 --- a/src/lib/libc/stdlib/strtoll.c +++ b/src/lib/libc/stdlib/strtoll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoll.c,v 1.8 2014/09/13 20:10:12 schwarze Exp $ */ +/* $OpenBSD: strtoll.c,v 1.9 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. @@ -151,5 +151,6 @@ strtoll(const char *nptr, char **endptr, int base) *endptr = (char *) (any ? s - 1 : nptr); return (acc); } +DEF_STRONG(strtoll); -__strong_alias(strtoq, strtoll); +__weak_alias(strtoq, strtoll); diff --git a/src/lib/libc/stdlib/strtonum.c b/src/lib/libc/stdlib/strtonum.c index 1aeee346..ad22d1c3 100644 --- a/src/lib/libc/stdlib/strtonum.c +++ b/src/lib/libc/stdlib/strtonum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */ +/* $OpenBSD: strtonum.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 2004 Ted Unangst and Todd Miller @@ -63,3 +63,4 @@ strtonum(const char *numstr, long long minval, long long maxval, return (ll); } +DEF_WEAK(strtonum); diff --git a/src/lib/libc/stdlib/strtoul.c b/src/lib/libc/stdlib/strtoul.c index 2aa41b76..98e8abcb 100644 --- a/src/lib/libc/stdlib/strtoul.c +++ b/src/lib/libc/stdlib/strtoul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoul.c,v 1.9 2014/09/13 20:10:12 schwarze Exp $ */ +/* $OpenBSD: strtoul.c,v 1.10 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -107,3 +107,4 @@ strtoul(const char *nptr, char **endptr, int base) *endptr = (char *) (any ? s - 1 : nptr); return (acc); } +DEF_STRONG(strtoul); diff --git a/src/lib/libc/stdlib/strtoull.c b/src/lib/libc/stdlib/strtoull.c index 84641763..a5d07de6 100644 --- a/src/lib/libc/stdlib/strtoull.c +++ b/src/lib/libc/stdlib/strtoull.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoull.c,v 1.7 2014/09/13 20:10:12 schwarze Exp $ */ +/* $OpenBSD: strtoull.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. @@ -109,5 +109,6 @@ strtoull(const char *nptr, char **endptr, int base) *endptr = (char *) (any ? s - 1 : nptr); return (acc); } +DEF_STRONG(strtoull); -__strong_alias(strtouq, strtoull); +__weak_alias(strtouq, strtoull); diff --git a/src/lib/libc/stdlib/system.c b/src/lib/libc/stdlib/system.c index 14ddcae8..2a50ec74 100644 --- a/src/lib/libc/stdlib/system.c +++ b/src/lib/libc/stdlib/system.c @@ -1,4 +1,4 @@ -/* $OpenBSD: system.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */ +/* $OpenBSD: system.c,v 1.9 2015/09/13 08:31:48 guenther Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. @@ -72,3 +72,4 @@ system(const char *command) (void)signal(SIGQUIT, quitsave); return (pid == -1 ? -1 : pstat); } +DEF_STRONG(system);