From f13d260190d47bd38c0ae939080001e7bb58bd04 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 24 Apr 2020 21:25:31 -0300 Subject: signal: Move sys_errlist to a compat symbol The symbol is deprecated by strerror since its usage imposes some issues such as copy relocations. Its internal name is also changed to _sys_errlist_internal to avoid static linking usage. The compat code is also refactored by removing the over enginered errlist-compat.c generation from manual entried and extra comment token in linker script file. It disantangle the code generation from manual and simplify both Linux and Hurd compat code. The definitions from errlist.c are moved to errlist.h and a new test is added to avoid a new errno entry without an associated one in manual. Checked on x86_64-linux-gnu and i686-linux-gnu. I also run a check-abi on all affected platforms. Tested-by: Carlos O'Donell Reviewed-by: Carlos O'Donell --- sysdeps/unix/sysv/linux/Versions | 10 ------ sysdeps/unix/sysv/linux/alpha/Versions | 12 ------- sysdeps/unix/sysv/linux/alpha/errlist-compat.c | 43 ++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/bits/sys_errlist.h | 32 ------------------- sysdeps/unix/sysv/linux/errlist-compat.c | 39 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/errlist-compat.h | 43 ++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/hppa/Versions | 10 ------ sysdeps/unix/sysv/linux/hppa/errlist-compat.c | 39 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/mips/Versions | 7 ----- sysdeps/unix/sysv/linux/mips/errlist-compat.c | 27 ++++++++++++++++ sysdeps/unix/sysv/linux/sparc/Versions | 10 ------ sysdeps/unix/sysv/linux/sparc/errlist-compat.c | 43 ++++++++++++++++++++++++++ 12 files changed, 234 insertions(+), 81 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/alpha/errlist-compat.c delete mode 100644 sysdeps/unix/sysv/linux/bits/sys_errlist.h create mode 100644 sysdeps/unix/sysv/linux/errlist-compat.c create mode 100644 sysdeps/unix/sysv/linux/errlist-compat.h create mode 100644 sysdeps/unix/sysv/linux/hppa/errlist-compat.c create mode 100644 sysdeps/unix/sysv/linux/mips/errlist-compat.c create mode 100644 sysdeps/unix/sysv/linux/sparc/errlist-compat.c (limited to 'sysdeps/unix/sysv/linux') diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 52ca223ab2..f72741b7e5 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -1,9 +1,4 @@ libc { - # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk. - # When you get an error from errlist-compat.awk, you need to add a new - # version here. Don't do this blindly, since this means changing the ABI - # for all GNU/Linux configurations. - GLIBC_2.0 { # functions used in inline functions or macros __cmsg_nxthdr; @@ -56,7 +51,6 @@ libc { # u* umount; uselib; - #errlist-compat 123 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.1 { @@ -84,7 +78,6 @@ libc { # u* umount2; - #errlist-compat 125 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.2 { @@ -102,7 +95,6 @@ libc { # r* readahead; - #errlist-compat 126 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.3.2 { @@ -120,7 +112,6 @@ libc { unshare; - #errlist-compat 132 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.5 { @@ -142,7 +133,6 @@ libc { fallocate; } GLIBC_2.12 { - #errlist-compat 135 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; ntp_gettimex; diff --git a/sysdeps/unix/sysv/linux/alpha/Versions b/sysdeps/unix/sysv/linux/alpha/Versions index 3b7971c2a3..b90d5f2e5a 100644 --- a/sysdeps/unix/sysv/linux/alpha/Versions +++ b/sysdeps/unix/sysv/linux/alpha/Versions @@ -1,12 +1,5 @@ libc { - # The comment lines with "#errlist-compat" are magic; see - # sysdeps/gnu/errlist-compat.awk. - # When you get an error from errlist-compat.awk, you need to add a new - # version here. Don't do this blindly, since this means changing the ABI - # for all GNU/Linux configurations. - GLIBC_2.0 { - #errlist-compat 131 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; # Unfortunately in wider use. @@ -33,7 +26,6 @@ libc { pciconfig_read; pciconfig_write; sethae; } GLIBC_2.1 { - #errlist-compat 131 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; # Linux/Alpha 64-bit timeval functions. @@ -70,19 +62,15 @@ libc { wordexp; } GLIBC_2.3 { - #errlist-compat 132 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.4 { - #errlist-compat 138 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.12 { - #errlist-compat 139 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.16 { - #errlist-compat 140 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.27 { diff --git a/sysdeps/unix/sysv/linux/alpha/errlist-compat.c b/sysdeps/unix/sysv/linux/alpha/errlist-compat.c new file mode 100644 index 0000000000..709807aa6b --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/errlist-compat.c @@ -0,0 +1,43 @@ +/* Linux sys_errlist compat symbol definitions. Alpha version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +DEFINE_COMPAT_ERRLIST (131, GLIBC_2_0) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3) +DEFINE_COMPAT_ERRLIST (131, GLIBC_2_1) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_4) +DEFINE_COMPAT_ERRLIST (132, GLIBC_2_3) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_4, GLIBC_2_12) +DEFINE_COMPAT_ERRLIST (138, GLIBC_2_4) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_16) +DEFINE_COMPAT_ERRLIST (139, GLIBC_2_12) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_16, GLIBC_2_32) +DEFINE_COMPAT_ERRLIST (140, GLIBC_2_16) +#endif diff --git a/sysdeps/unix/sysv/linux/bits/sys_errlist.h b/sysdeps/unix/sysv/linux/bits/sys_errlist.h deleted file mode 100644 index d6f5fa0a5e..0000000000 --- a/sysdeps/unix/sysv/linux/bits/sys_errlist.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Declare sys_errlist and sys_nerr, or don't. Compatibility (do) version. - Copyright (C) 2002-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _STDIO_H -# error "Never include directly; use instead." -#endif - -/* sys_errlist and sys_nerr are deprecated. Use strerror instead. */ - -#ifdef __USE_MISC -extern int sys_nerr; -extern const char *const sys_errlist[]; -#endif -#ifdef __USE_GNU -extern int _sys_nerr; -extern const char *const _sys_errlist[]; -#endif diff --git a/sysdeps/unix/sysv/linux/errlist-compat.c b/sysdeps/unix/sysv/linux/errlist-compat.c new file mode 100644 index 0000000000..c4d79b70aa --- /dev/null +++ b/sysdeps/unix/sysv/linux/errlist-compat.c @@ -0,0 +1,39 @@ +/* Linux sys_errlist compat symbol definitions. Generic version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +DEFINE_COMPAT_ERRLIST (123, GLIBC_2_0) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3) +DEFINE_COMPAT_ERRLIST (125, GLIBC_2_1) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_4) +DEFINE_COMPAT_ERRLIST (126, GLIBC_2_3) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_4, GLIBC_2_12) +DEFINE_COMPAT_ERRLIST (132, GLIBC_2_4) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_32) +DEFINE_COMPAT_ERRLIST (135, GLIBC_2_12) +#endif diff --git a/sysdeps/unix/sysv/linux/errlist-compat.h b/sysdeps/unix/sysv/linux/errlist-compat.h new file mode 100644 index 0000000000..edd35fd4ed --- /dev/null +++ b/sysdeps/unix/sysv/linux/errlist-compat.h @@ -0,0 +1,43 @@ +/* Linux sys_errlist compatibility macro definitions. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ERRLIST_COMPAT_H +#define _ERRLIST_COMPAT_H + +#include + +/* Define new compat symbols for symbols _sys_errlist, sys_errlist, + _sys_nerr, and sys_nerr for version VERSION with NUMBERERR times number of + bytes per long int size. + Both _sys_errlist and sys_errlist alias to _sys_errlist_internal symbol + (defined on errlist.c) while _sys_nerr and sys_nerr created new variable + with the expected size. */ +#define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \ + const int __##VERSION##_sys_nerr = NUMBERERR; \ + strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \ + declare_symbol_alias (__ ## VERSION ## _sys_errlist, _sys_errlist_internal,\ + object, NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \ + declare_symbol_alias (__ ## VERSION ## __sys_errlist, \ + _sys_errlist_internal, object, \ + NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \ + compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \ + compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION); \ + compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION); \ + compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION);\ + +#endif diff --git a/sysdeps/unix/sysv/linux/hppa/Versions b/sysdeps/unix/sysv/linux/hppa/Versions index b5098b2171..9532d207fc 100644 --- a/sysdeps/unix/sysv/linux/hppa/Versions +++ b/sysdeps/unix/sysv/linux/hppa/Versions @@ -1,11 +1,5 @@ libc { - # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk. - # When you get an error from errlist-compat.awk, you need to add a new - # version here. Don't do this blindly, since this means changing the ABI - # for all GNU/Linux configurations. - GLIBC_2.1 { - #errlist-compat 253 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.2 { @@ -13,22 +7,18 @@ libc { getrlimit; setrlimit; getrlimit64; setrlimit64; } GLIBC_2.3 { - #errlist-compat 254 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.4 { - #errlist-compat 256 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.11 { fallocate64; } GLIBC_2.12 { - #errlist-compat 257 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.17 { - #errlist-compat 260 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; prlimit64; } diff --git a/sysdeps/unix/sysv/linux/hppa/errlist-compat.c b/sysdeps/unix/sysv/linux/hppa/errlist-compat.c new file mode 100644 index 0000000000..65860d884c --- /dev/null +++ b/sysdeps/unix/sysv/linux/hppa/errlist-compat.c @@ -0,0 +1,39 @@ +/* Linux sys_errlist compat symbol definitions. HPPA version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3) +DEFINE_COMPAT_ERRLIST (253, GLIBC_2_1) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_4) +DEFINE_COMPAT_ERRLIST (254, GLIBC_2_3) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_4, GLIBC_2_12) +DEFINE_COMPAT_ERRLIST (256, GLIBC_2_4) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_17) +DEFINE_COMPAT_ERRLIST (257, GLIBC_2_12) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_17, GLIBC_2_32) +DEFINE_COMPAT_ERRLIST (260, GLIBC_2_17) +#endif diff --git a/sysdeps/unix/sysv/linux/mips/Versions b/sysdeps/unix/sysv/linux/mips/Versions index 453f276aad..0ec82dc480 100644 --- a/sysdeps/unix/sysv/linux/mips/Versions +++ b/sysdeps/unix/sysv/linux/mips/Versions @@ -5,13 +5,7 @@ ld { } } libc { - # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk. - # When you get an error from errlist-compat.awk, you need to add a new - # version here. Don't do this blindly, since this means changing the ABI - # for all GNU/Linux configurations. - GLIBC_2.0 { - #errlist-compat 123 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; # Exception handling support functions from libgcc @@ -28,7 +22,6 @@ libc { sysmips; } GLIBC_2.2 { - #errlist-compat 1134 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; # _* diff --git a/sysdeps/unix/sysv/linux/mips/errlist-compat.c b/sysdeps/unix/sysv/linux/mips/errlist-compat.c new file mode 100644 index 0000000000..b720db9244 --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/errlist-compat.c @@ -0,0 +1,27 @@ +/* Linux sys_errlist compat symbol definitions. MIPS version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) +DEFINE_COMPAT_ERRLIST (123, GLIBC_2_0) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_32) +DEFINE_COMPAT_ERRLIST (1134, GLIBC_2_1) +#endif diff --git a/sysdeps/unix/sysv/linux/sparc/Versions b/sysdeps/unix/sysv/linux/sparc/Versions index f056addee6..61e57fae99 100644 --- a/sysdeps/unix/sysv/linux/sparc/Versions +++ b/sysdeps/unix/sysv/linux/sparc/Versions @@ -1,30 +1,20 @@ libc { - # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk. - # When you get an error from errlist-compat.awk, you need to add a new - # version here. - GLIBC_2.0 { - #errlist-compat 127 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.1 { - #errlist-compat 127 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.3 { - #errlist-compat 128 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.4 { - #errlist-compat 134 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.12 { - #errlist-compat 135 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; } GLIBC_2.16 { - #errlist-compat 136 _sys_errlist; sys_errlist; _sys_nerr; sys_nerr; __getshmlba; diff --git a/sysdeps/unix/sysv/linux/sparc/errlist-compat.c b/sysdeps/unix/sysv/linux/sparc/errlist-compat.c new file mode 100644 index 0000000000..43fc364add --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/errlist-compat.c @@ -0,0 +1,43 @@ +/* Linux sys_errlist compat symbol definitions. Sparc version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +DEFINE_COMPAT_ERRLIST (127, GLIBC_2_0) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3) +DEFINE_COMPAT_ERRLIST (127, GLIBC_2_1) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_4) +DEFINE_COMPAT_ERRLIST (128, GLIBC_2_3) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_4, GLIBC_2_12) +DEFINE_COMPAT_ERRLIST (134, GLIBC_2_4) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_16) +DEFINE_COMPAT_ERRLIST (135, GLIBC_2_12) +#endif + +#if SHLIB_COMPAT (libc, GLIBC_2_16, GLIBC_2_32) +DEFINE_COMPAT_ERRLIST (136, GLIBC_2_16) +#endif -- cgit 1.4.1