[0/7] Fixing remaining lld issues

Message ID 20221115193159.173838-1-adhemerval.zanella@linaro.org
Headers
Series Fixing remaining lld issues |

Message

Adhemerval Zanella Nov. 15, 2022, 7:31 p.m. UTC
  There are still some issue while trying to build and check glibc
with lld:

  - The vtables hardening are not enabled with --with-default-link=no
    (tst-relro-libc fails [1]) and with --with-default-link=yes also
    requires ld.bfd to be available [2].  Furthermore, only lld 15
    supports custom RELRO sections in linker script.  

  - elf/tst-audit25 assumes a specific symbol order, where lld and bfd
    differs slight.

First patch fixes an issue with --with-binutils, where the specified
linker is not used for some early checks.  It trigger additional
test failures with lld if --with-binutils is used to override the
default linker.

Second patch fixes tst-audit25 symbol order.

Third, forth, and fifth removes the --with-default-link by moving the
_IO_cleanup (used on exit) to call_function_static_weak, by replacing
libc_freeres_ptrs and libc_subfreeres with weak function calls, and by
refactoring the vtables hardening with a array placed directly on
RELRO segment.

Finally --with-default-link is removed and set-hooks.h mechanism
(which is a clunky interface) is moved to be Hurd-only.

I checked on all affected ABIs and did a full test on both x86_64
and aarch64.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=25812
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=2ae7990542e1955097aa21943e416dec70f867fa

Adhemerval Zanella (7):
  configure: Move locale tools early
  elf: Do not assume symbol order on tst-audit25{a,b}
  stdlib: Move _IO_cleanup to call_function_static_weak
  Move libc_freeres_ptrs and libc_subfreeres to weak functions
  libio: Remove the usage of __libc_IO_vtables
  Remove --with-default-link configure option
  Remove set-hooks.h from generic includes

 INSTALL                                       |    6 -
 Makerules                                     |   55 +-
 config.make.in                                |    1 -
 configure                                     | 2169 ++++++++---------
 configure.ac                                  |  245 +-
 crypt/md5-crypt.c                             |   10 +-
 crypt/sha256-crypt.c                          |   10 +-
 crypt/sha512-crypt.c                          |   10 +-
 elf/Makefile                                  |   23 +-
 elf/dl-libc.c                                 |    4 +-
 elf/tst-audit25.h                             |   46 +
 elf/tst-audit25a.c                            |   38 +-
 elf/tst-audit25b.c                            |   39 +-
 grp/fgetgrent.c                               |    8 +-
 gshadow/fgetsgent.c                           |    2 +-
 {include => hurd}/set-hooks.h                 |    0
 iconv/gconv_cache.c                           |    3 +-
 iconv/gconv_conf.c                            |    3 +-
 iconv/gconv_db.c                              |    6 +-
 iconv/gconv_dl.c                              |    5 +-
 iconvdata/extra-module.mk                     |    2 +-
 include/libc-symbols.h                        |   91 +-
 inet/getnameinfo.c                            |    8 +-
 inet/getnetgrent.c                            |    8 +-
 inet/rcmd.c                                   |    8 +-
 inet/rexec.c                                  |    8 +-
 intl/dcigettext.c                             |    3 +-
 intl/finddomain.c                             |    2 +-
 intl/loadmsgcat.c                             |    1 -
 intl/localealias.c                            |   15 +-
 libio/Makefile                                |    2 +
 libio/fileops.c                               |   81 +-
 libio/genops.c                                |   10 +-
 libio/iofopncook.c                            |   60 +-
 libio/iopopen.c                               |   25 -
 libio/iovsprintf.c                            |   26 +-
 libio/libio-macros.sym                        |    7 +
 libio/libioP.h                                |  312 ++-
 libio/memstream.c                             |   32 +-
 libio/obprintf.c                              |   34 +-
 libio/oldfileops.c                            |   23 -
 libio/oldiopopen.c                            |   23 -
 libio/stdio.c                                 |    3 +
 libio/strfile.h                               |    5 -
 libio/strops.c                                |   24 -
 libio/tst-vtables-interposed.c                |    5 +
 libio/vsnprintf.c                             |   29 +-
 libio/vswprintf.c                             |   30 +-
 libio/vtables.c                               |  502 ++++
 libio/wfileops.c                              |   79 +-
 libio/wmemstream.c                            |   32 +-
 libio/wstrops.c                               |   24 -
 locale/loadarchive.c                          |    2 +-
 locale/localeinfo.h                           |    4 +-
 locale/setlocale.c                            |    4 +-
 login/getutent.c                              |    8 +-
 login/getutid.c                               |    8 +-
 login/getutline.c                             |    8 +-
 malloc/set-freeres.c                          |  222 +-
 malloc/thread-freeres.c                       |    2 +-
 manual/install.texi                           |    6 -
 misc/efgcvt-template.c                        |    8 +-
 misc/efgcvt.c                                 |    1 +
 misc/fstab.c                                  |    3 +-
 misc/hsearch.c                                |    4 -
 misc/mntent.c                                 |    8 +-
 misc/qefgcvt.c                                |    1 +
 misc/unwind-link.c                            |    2 +-
 nptl/nptlfreeres.c                            |    1 -
 nscd/nscd_getgr_r.c                           |    3 +-
 nscd/nscd_gethst_r.c                          |    3 +-
 nscd/nscd_getpw_r.c                           |    3 +-
 nscd/nscd_getserv_r.c                         |    3 +-
 nscd/nscd_netgroup.c                          |    3 +-
 nss/getXXbyYY.c                               |   10 +-
 nss/getXXent.c                                |   10 +-
 nss/nss_action.c                              |    2 +-
 nss/nss_database.c                            |    2 +-
 nss/nss_module.c                              |    2 +-
 posix/regcomp.c                               |    3 +-
 posix/register-atfork.c                       |    3 +-
 pwd/fgetpwent.c                               |    8 +-
 resolv/gai_misc.c                             |    3 +-
 resolv/res-close.c                            |    2 -
 resolv/res_hconf.c                            |    9 +-
 resolv/resolv_conf.c                          |    3 +-
 resolv/tst-leaks2.c                           |    2 +
 rt/aio_misc.c                                 |    3 +-
 shadow/fgetspent.c                            |    8 +-
 stdio-common/reg-modifier.c                   |    3 +-
 stdio-common/reg-printf.c                     |    9 +-
 stdio-common/reg-type.c                       |    9 +-
 stdio-common/vfprintf-internal.c              |   60 +-
 stdlib/exit.c                                 |    6 +-
 stdlib/fmtmsg.c                               |    3 +-
 stdlib/setenv.c                               |    3 +-
 sunrpc/clnt_perr.c                            |    4 +-
 sunrpc/rpc_thread.c                           |    1 -
 sunrpc/tst-svc_register.c                     |    6 +-
 sysdeps/generic/set-freeres-fp.h              |   19 +
 sysdeps/generic/set-freeres-os.h              |   19 +
 sysdeps/generic/set-freeres-system.h          |   27 +
 .../ldbl-128ibm-compat/ieee128-qefgcvt.c      |    1 +
 .../ldbl-128ibm-compat/set-freeres-fp.h       |   22 +
 sysdeps/mach/hurd/bits/errno.h                |    1 -
 sysdeps/posix/getaddrinfo.c                   |    5 +-
 sysdeps/posix/ttyname.c                       |    8 +-
 sysdeps/unix/sysv/linux/check_pf.c            |    3 +-
 sysdeps/unix/sysv/linux/set-freeres-os.h      |   24 +
 sysdeps/unix/sysv/linux/ttyname.c             |    3 +-
 time/tzfile.c                                 |    8 +-
 time/tzset.c                                  |    3 +-
 112 files changed, 2618 insertions(+), 2203 deletions(-)
 create mode 100644 elf/tst-audit25.h
 rename {include => hurd}/set-hooks.h (100%)
 create mode 100644 libio/libio-macros.sym
 create mode 100644 sysdeps/generic/set-freeres-fp.h
 create mode 100644 sysdeps/generic/set-freeres-os.h
 create mode 100644 sysdeps/generic/set-freeres-system.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/set-freeres-fp.h
 create mode 100644 sysdeps/unix/sysv/linux/set-freeres-os.h