diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-07-16 14:06:51 +0000 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-10-09 17:02:06 -0300 |
commit | 8ed005daf0ab03e142500324a34087ce179ae78e (patch) | |
tree | 2541dfc11ce5fe84696c84266a1b2eb22fe2f571 /io | |
parent | 428985c436f442e91e27173bccaf28f547233586 (diff) | |
download | glibc-8ed005daf0ab03e142500324a34087ce179ae78e.tar.gz glibc-8ed005daf0ab03e142500324a34087ce179ae78e.tar.xz glibc-8ed005daf0ab03e142500324a34087ce179ae78e.zip |
Remove stat wrapper functions, move them to exported symbols
This patch removes the stat, stat64, lstat, lstat64, fstat, fstat64, fstatat, and fstatat64 static wrapper and add the symbol on the libc with the expected names. Both the prototypes of the internal symbol linked by the static wrappers and the inline redirectors are also removed from the installed sys/stat.h header file. The wrapper implementation license LGPL exception is also removed since it is no longer statically linked to binaries. Internally the _STAT_VER* definitions are moved to a arch-specific xstatver.h file. The internal defines that redirects internals {f}stat{at} to their {f}xstat{at} counterparts are removed for Linux (!NO_RTLD_HIDDEN). Hurd still requires them since {f}stat{at} pulls extra objects that makes the loader build fail otherwise (I haven't dig into why exactly). Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'io')
-rw-r--r-- | io/Makefile | 4 | ||||
-rw-r--r-- | io/Versions | 4 | ||||
-rw-r--r-- | io/fstat.c | 30 | ||||
-rw-r--r-- | io/fstat64.c | 33 | ||||
-rw-r--r-- | io/fstatat.c | 33 | ||||
-rw-r--r-- | io/fstatat64.c | 33 | ||||
-rw-r--r-- | io/lstat.c | 30 | ||||
-rw-r--r-- | io/lstat64.c | 33 | ||||
-rw-r--r-- | io/stat.c | 31 | ||||
-rw-r--r-- | io/stat64.c | 33 | ||||
-rw-r--r-- | io/sys/stat.h | 129 |
11 files changed, 30 insertions, 363 deletions
diff --git a/io/Makefile b/io/Makefile index 36ac06070a..69b2468d64 100644 --- a/io/Makefile +++ b/io/Makefile @@ -60,8 +60,7 @@ routines := \ # These routines will be omitted from the libc shared object. # Instead the static object files will be included in a special archive # linked against when the shared library will be used. -static-only-routines = stat fstat lstat stat64 fstat64 lstat64 \ - fstatat fstatat64 mknod mknodat +static-only-routines = mknod mknodat others := pwd test-srcs := ftwtest @@ -78,6 +77,7 @@ tests := test-utime test-stat test-stat2 test-lfs tst-getcwd \ # Likewise for statx, but we do not need static linking here. tests-internal += tst-statx +tests-static += tst-statx ifeq ($(run-built-tests),yes) tests-special += $(objpfx)ftwtest.out diff --git a/io/Versions b/io/Versions index ee468055ff..f6db0e84ad 100644 --- a/io/Versions +++ b/io/Versions @@ -132,6 +132,9 @@ libc { fcntl64; statx; } + GLIBC_2.33 { + stat; stat64; fstat; fstat64; lstat; lstat64; fstatat; fstatat64; + } GLIBC_PRIVATE { __libc_fcntl64; __fcntl_nocancel; @@ -141,5 +144,6 @@ libc { __file_change_detection_for_stat; __file_change_detection_for_path; __file_change_detection_for_fp; + __fstat64; } } diff --git a/io/fstat.c b/io/fstat.c index 6ce077dc4a..c392ebe35b 100644 --- a/io/fstat.c +++ b/io/fstat.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,22 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef fstat #undef __fstat int -attribute_hidden __fstat (int fd, struct stat *buf) { return __fxstat (_STAT_VER, fd, buf); } -weak_hidden_alias (__fstat, fstat) +weak_alias (__fstat, fstat) diff --git a/io/fstat64.c b/io/fstat64.c index c4dd3acd60..8f9a6a4ad0 100644 --- a/io/fstat64.c +++ b/io/fstat64.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,19 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef fstat64 +#undef __fstat64 int -attribute_hidden -fstat64 (int fd, struct stat64 *buf) +__fstat64 (int fd, struct stat64 *buf) { return __fxstat64 (_STAT_VER, fd, buf); } +hidden_def (__fstat64) +weak_alias (__fstat64, fstat64) diff --git a/io/fstatat.c b/io/fstatat.c index edc773487a..19242b7d5d 100644 --- a/io/fstatat.c +++ b/io/fstatat.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,19 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef fstatat +#undef __fstatat int -attribute_hidden -fstatat (int fd, const char *file, struct stat *buf, int flag) +__fstatat (int fd, const char *file, struct stat *buf, int flag) { return __fxstatat (_STAT_VER, fd, file, buf, flag); } + +weak_alias (__fstatat, fstatat) diff --git a/io/fstatat64.c b/io/fstatat64.c index b57133bd90..0e0312fd19 100644 --- a/io/fstatat64.c +++ b/io/fstatat64.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,19 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef fstatat64 +#undef __fstatat64 int -attribute_hidden -fstatat64 (int fd, const char *file, struct stat64 *buf, int flag) +__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag) { return __fxstatat64 (_STAT_VER, fd, file, buf, flag); } +hidden_def (__fstatat64) +weak_alias (__fstatat64, fstatat64) diff --git a/io/lstat.c b/io/lstat.c index 7134741106..bdd60bedb6 100644 --- a/io/lstat.c +++ b/io/lstat.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,22 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef lstat #undef __lstat int -attribute_hidden __lstat (const char *file, struct stat *buf) { return __lxstat (_STAT_VER, file, buf); } -weak_hidden_alias (__lstat, lstat) +weak_alias (__lstat, lstat) diff --git a/io/lstat64.c b/io/lstat64.c index a890da71a8..0e571f6075 100644 --- a/io/lstat64.c +++ b/io/lstat64.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,19 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef lstat64 +#undef __lstat64 int -attribute_hidden -lstat64 (const char *file, struct stat64 *buf) +__lstat64 (const char *file, struct stat64 *buf) { return __lxstat64 (_STAT_VER, file, buf); } +hidden_def (__lstat64) +weak_alias (__lstat64, lstat64) diff --git a/io/stat.c b/io/stat.c index 8c3cd877c8..78dbfb3b8f 100644 --- a/io/stat.c +++ b/io/stat.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,21 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef stat +#undef __stat int -attribute_hidden __stat (const char *file, struct stat *buf) { return __xstat (_STAT_VER, file, buf); } -weak_hidden_alias (__stat, stat) +weak_alias (__stat, stat) diff --git a/io/stat64.c b/io/stat64.c index 8b6b662f3a..102dcc5d5a 100644 --- a/io/stat64.c +++ b/io/stat64.c @@ -6,23 +6,6 @@ License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file with other - programs, and to distribute those programs without any restriction - coming from the use of this file. (The GNU Lesser General Public - License restrictions do apply in other respects; for example, they - cover modification of the file, and distribution when not linked - into another program.) - - Note that people who make modified versions of this file are not - obligated to grant this special exception for their modified - versions; it is their choice whether to do so. The GNU Lesser - General Public License gives permission to release a modified - version without this exception; this exception also makes it - possible to release a modified version which carries forward this - exception. - The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -34,19 +17,11 @@ #include <sys/stat.h> -/* This definition is only used if inlining fails for this function; see - the last page of <sys/stat.h>. The real work is done by the `x' - function which is passed a version number argument. We arrange in the - makefile that when not inlined this function is always statically - linked; that way a dynamically-linked executable always encodes the - version number corresponding to the data structures it uses, so the `x' - functions in the shared library can adapt without needing to recompile - all callers. */ - -#undef stat64 +#undef __stat64 int -attribute_hidden -stat64 (const char *file, struct stat64 *buf) +__stat64 (const char *file, struct stat64 *buf) { return __xstat64 (_STAT_VER, file, buf); } +hidden_def (__stat64) +weak_alias (__stat64, stat64) diff --git a/io/sys/stat.h b/io/sys/stat.h index 69e333656a..eb9cf5d5af 100644 --- a/io/sys/stat.h +++ b/io/sys/stat.h @@ -368,73 +368,10 @@ extern int utimensat (int __fd, const char *__path, extern int futimens (int __fd, const struct timespec __times[2]) __THROW; #endif -/* To allow the `struct stat' structure and the file type `mode_t' - bits to vary without changing shared library major version number, - the `stat' family of functions and `mknod' are in fact inline - wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod', - which all take a leading version-number argument designating the - data structure and bits used. <bits/stat.h> defines _STAT_VER with - the version number corresponding to `struct stat' as defined in - that file; and _MKNOD_VER with the version number corresponding to - the S_IF* macros defined therein. It is arranged that when not - inlined these function are always statically linked; that way a - dynamically-linked executable always encodes the version number - corresponding to the data structures it uses, so the `x' functions - in the shared library can adapt without needing to recompile all - callers. */ - -#ifndef _STAT_VER -# define _STAT_VER 0 -#endif #ifndef _MKNOD_VER # define _MKNOD_VER 0 #endif -/* Wrappers for stat and mknod system calls. */ -#ifndef __USE_FILE_OFFSET64 -extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf) - __THROW __nonnull ((3)); -extern int __xstat (int __ver, const char *__filename, - struct stat *__stat_buf) __THROW __nonnull ((2, 3)); -extern int __lxstat (int __ver, const char *__filename, - struct stat *__stat_buf) __THROW __nonnull ((2, 3)); -extern int __fxstatat (int __ver, int __fildes, const char *__filename, - struct stat *__stat_buf, int __flag) - __THROW __nonnull ((3, 4)); -#else -# ifdef __REDIRECT_NTH -extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes, - struct stat *__stat_buf), __fxstat64) - __nonnull ((3)); -extern int __REDIRECT_NTH (__xstat, (int __ver, const char *__filename, - struct stat *__stat_buf), __xstat64) - __nonnull ((2, 3)); -extern int __REDIRECT_NTH (__lxstat, (int __ver, const char *__filename, - struct stat *__stat_buf), __lxstat64) - __nonnull ((2, 3)); -extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes, - const char *__filename, - struct stat *__stat_buf, int __flag), - __fxstatat64) __nonnull ((3, 4)); - -# else -# define __fxstat __fxstat64 -# define __xstat __xstat64 -# define __lxstat __lxstat64 -# endif -#endif - -#ifdef __USE_LARGEFILE64 -extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf) - __THROW __nonnull ((3)); -extern int __xstat64 (int __ver, const char *__filename, - struct stat64 *__stat_buf) __THROW __nonnull ((2, 3)); -extern int __lxstat64 (int __ver, const char *__filename, - struct stat64 *__stat_buf) __THROW __nonnull ((2, 3)); -extern int __fxstatat64 (int __ver, int __fildes, const char *__filename, - struct stat64 *__stat_buf, int __flag) - __THROW __nonnull ((3, 4)); -#endif extern int __xmknod (int __ver, const char *__path, __mode_t __mode, __dev_t *__dev) __THROW __nonnull ((2, 4)); @@ -447,37 +384,6 @@ extern int __xmknodat (int __ver, int __fd, const char *__path, #endif #ifdef __USE_EXTERN_INLINES -/* Inlined versions of the real stat and mknod functions. */ - -__extern_inline int -__NTH (stat (const char *__path, struct stat *__statbuf)) -{ - return __xstat (_STAT_VER, __path, __statbuf); -} - -# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED -__extern_inline int -__NTH (lstat (const char *__path, struct stat *__statbuf)) -{ - return __lxstat (_STAT_VER, __path, __statbuf); -} -# endif - -__extern_inline int -__NTH (fstat (int __fd, struct stat *__statbuf)) -{ - return __fxstat (_STAT_VER, __fd, __statbuf); -} - -# ifdef __USE_ATFILE -__extern_inline int -__NTH (fstatat (int __fd, const char *__filename, struct stat *__statbuf, - int __flag)) -{ - return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag); -} -# endif - # ifdef __USE_MISC __extern_inline int __NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev)) @@ -496,41 +402,6 @@ __NTH (mknodat (int __fd, const char *__path, __mode_t __mode, } # endif # endif - -# if defined __USE_LARGEFILE64 \ - && (! defined __USE_FILE_OFFSET64 \ - || (defined __REDIRECT_NTH && defined __OPTIMIZE__)) -__extern_inline int -__NTH (stat64 (const char *__path, struct stat64 *__statbuf)) -{ - return __xstat64 (_STAT_VER, __path, __statbuf); -} - -# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED -__extern_inline int -__NTH (lstat64 (const char *__path, struct stat64 *__statbuf)) -{ - return __lxstat64 (_STAT_VER, __path, __statbuf); -} -# endif - -__extern_inline int -__NTH (fstat64 (int __fd, struct stat64 *__statbuf)) -{ - return __fxstat64 (_STAT_VER, __fd, __statbuf); -} - -# ifdef __USE_ATFILE -__extern_inline int -__NTH (fstatat64 (int __fd, const char *__filename, struct stat64 *__statbuf, - int __flag)) -{ - return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf, __flag); -} -# endif - -# endif - #endif __END_DECLS |