From patchwork Tue Nov 15 19:31:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 55299 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5184038AA27A for ; Tue, 15 Nov 2022 19:32:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5184038AA27A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668540750; bh=u96bsgQ8o8upLYJm2Q247Y8HSf+VaPkWgdQTRraMrD0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iODfKZ1oNY4zwLo/ec38+VRJ8qsUeqgAhz+Q+HQl5Al3uIfZOkLvIXSstHxZwJTaK CT5bQ4cVrVrupBEc4AK0zmOVZqvbP7VdcEX2U9A44AtXHPhFPTw/++aNaoWbSRreso Vm0oa9nTVQ8djSbFHBlG/B173hLquX680ZVDdaL4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 74C6538A90B7 for ; Tue, 15 Nov 2022 19:32:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 74C6538A90B7 Received: by mail-ot1-x334.google.com with SMTP id p27-20020a056830319b00b0066d7a348e20so5124742ots.8 for ; Tue, 15 Nov 2022 11:32:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u96bsgQ8o8upLYJm2Q247Y8HSf+VaPkWgdQTRraMrD0=; b=p/zeKLU2EFGyepdf4ORcvytD4cKdEZsl89dnRsnmHk9XnilGk4EFzyyrkYDo5rbW3R NrecY1ilPOyCUB4NO75DJBqiQYdwYZwQQStYn7P4WyudIUJaF9+S5zRmzSEpzy+KkIaO wax3StnOZPX5vxoHTg5iQZxnfWjWxEPFb82koWOxV+tsvVurGJFdSzx4SxkNkpbMAds0 T8lWanBG/VOGY0D6GUu7H9tQzw3Vy3TF0eNpRslKoII/KFolsgNxfFlZl8xhd3uwiyQr epWlQxcepFOToQpX6CFfAo9OmDrvMGkkfyrHKzjcE247qkNYWhthrlGNDfetxpCTGn8j XRbQ== X-Gm-Message-State: ANoB5pkvpP+4lozKbh2rodorQ7xOOKTp1YbiQC/+L6x40Of/Tty95s+m qLgbfuGHs1X2kfixnzVNmjjwVUf29dBK4fQZ X-Google-Smtp-Source: AA0mqf4O+V9ir9MGzgjccel3rf5DrbAmFiNtO8jqP+uvE9kho5H1kGw+bh6wgdfbOX30MMjfmmFcUQ== X-Received: by 2002:a9d:66cf:0:b0:66c:7def:36e8 with SMTP id t15-20020a9d66cf000000b0066c7def36e8mr9316336otm.35.1668540723495; Tue, 15 Nov 2022 11:32:03 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1164:573d:c7d8:ae8e:e2eb]) by smtp.gmail.com with ESMTPSA id f7-20020a9d2c07000000b00660e833baddsm5705231otb.29.2022.11.15.11.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 11:32:03 -0800 (PST) To: libc-alpha@sourceware.org, Fangrui Song Subject: [PATCH 0/7] Fixing remaining lld issues Date: Tue, 15 Nov 2022 16:31:52 -0300 Message-Id: <20221115193159.173838-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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