From patchwork Mon Aug 2 04:29:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 44550 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 88CB3383A828 for ; Mon, 2 Aug 2021 13:08:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88CB3383A828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1627909737; bh=VmJ3cOAm8eDUNRy0kNeCaWNJoXNErRBc+P3VjDmK3KM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=v0ZfRxi1HyVqxHZ7u/B2wcanx1Qn901GV5IHaobyg+JOfkcikfjKkZoM1Bcc9j9I7 k4HQsBOhT7D/3gIS83R9sUxpoOYhv22/+UN1Z1fXvQ2sRk4n/2rM9XBOLAFHihGaBo RIM6UWvio0Xr8zIebFUlQLjZVQrhkTMH6vschZkI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 830CA3836001 for ; Mon, 2 Aug 2021 13:08:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 830CA3836001 Received: by mail-pj1-x102e.google.com with SMTP id k4-20020a17090a5144b02901731c776526so31589895pjm.4 for ; Mon, 02 Aug 2021 06:08:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VmJ3cOAm8eDUNRy0kNeCaWNJoXNErRBc+P3VjDmK3KM=; b=n8zzRRELli2nZdQqmaE9I6cs00zkv02c+ohnZZfeKFGxENK8Nl3FkqQ8tlMn9fHMaP nfDr0Im2IGLDR2QH2erxQZFJwq2U58B+HxovF0wjIwHh9MdOB/IGmgeIgcS9zNOul5un Sr72IJ37wVkoQdTpIHW3Apfgj+RbXqDQZcN9+1u8OgVsjKRUzmSwGJoL8ArXye99zlP2 BGSd6d4/bn0fvFy8hFK0sfg0b/yQbVIVFXIycsbHUtOCMNK/oSZsV5iGEdRCg5WbC2LZ NtbfOu6uee5R73lRWTZUxLghvD5ox6cFqflSlslQD9KFLdGPh8rERJVNQSW6EYgthkuC 23hQ== X-Gm-Message-State: AOAM531K1cq6pw2zyibHgnGID69evHCEPLD2wmjZDRIT3BbSqWLL6Dga S/2GSDkwpm1pjDyzufs3q0Dbx9fSvQM= X-Google-Smtp-Source: ABdhPJxYWKDuKULpkwbQarTMelXMjA9KMsCDYy6kUs3DjGSSJt2Qm1zpoQUaFeJbJTNPT+bNQvMrHw== X-Received: by 2002:a17:90b:1647:: with SMTP id il7mr14494478pjb.43.1627909713546; Mon, 02 Aug 2021 06:08:33 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id dw15sm10679769pjb.42.2021.08.02.06.08.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 06:08:33 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 97C8EC0133 for ; Sun, 1 Aug 2021 21:29:40 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] Date: Sun, 1 Aug 2021 21:29:39 -0700 Message-Id: <20210802042940.932692-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3033.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Since the module name of ld is rtld, map ABI/VERSION of rtld to ABI/VERSION of ld. This fixes BZ #28132. --- scripts/abi-versions.awk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk index c369793459..09c9432f5c 100644 --- a/scripts/abi-versions.awk +++ b/scripts/abi-versions.awk @@ -27,6 +27,11 @@ $2 == "=" { printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid; printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new; + if (libid == "ld") { + # The module name of ld is rtld. + printf "#define ABI_rtld_%s\tABI_ld_%s\n", oldid, oldid + printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", oldid, oldid + } next; } @@ -38,6 +43,11 @@ $2 == "=" { printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers; printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers; + if (libid == "ld") { + # The module name of ld is rtld. + printf "#define ABI_rtld_%s\tABI_ld_%s\n", versid, versid + printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", versid, versid + } next; } From patchwork Mon Aug 2 04:29:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 44551 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 CDE82383A82C for ; Mon, 2 Aug 2021 13:09:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDE82383A82C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1627909782; bh=TfrhB7E2+Cdvmzx5ov4fVl3G+KaiGjchtcnkeBGhAVU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=p72Guye+vU4wt+tcX6/V7cM/Az5m5PrlrNZo+uOPgu+VQSNloaFKrwXu6ztFsngVR iyU1XY2Hbw3UhNs/4J9DWM4moViW+NXd/hoWPLP3yCDOAL9m6f3VCFxn9zFdH8phPS +26PJGx3pHhGj7boOQF/0Hn7Evw9rFmrGCAhwLW8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id E6E08383D80A for ; Mon, 2 Aug 2021 13:08:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E6E08383D80A Received: by mail-pj1-x1033.google.com with SMTP id g23-20020a17090a5797b02901765d605e14so24581937pji.5 for ; Mon, 02 Aug 2021 06:08:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TfrhB7E2+Cdvmzx5ov4fVl3G+KaiGjchtcnkeBGhAVU=; b=GPicEPtl3yunKOr7CcEayXJEevo2EuLvY9SrS5LWBJOTwt1JAH387SoramVBhoUXHA A4OwF3QG1+fp4KXj1ISXmr28bDsQCZ/FTeqGnP15Sn5FfNm2YE4/KHgYka1cvg0oeX6x PA1U6r9FMl2d8CttXKiRxYalj6y/TfbogxJxFDIRD8/U6ZQF1VZTFtbRscEcOlZtMjIX WT2gfD9RPmXm7RrVlfa87zobPv6tqXmo3HyDx34dp7/NMcIr/EhOhZSB6WDzoUC0OM/N b8F4U/cgFy9MF9H3m+xts0dFgI0lV7CL1g/1W0m0pTvUR+6RBSm9PBBPrpHkRa2JF50t P1Aw== X-Gm-Message-State: AOAM530+4ur+zrdkpgnHh4rUmTfEG8m2iJ80XJRSfsRMKwB+eLmuo9JW F78+AB3bBqlG9RD1hsmbIge9pqAqock= X-Google-Smtp-Source: ABdhPJy6yUiSLpw/xeNCYQ3evpE4FZbwoyiw1SOec5IA2Q8KGbmjWHeQQIn7et3IPv45EaVfTz4rPQ== X-Received: by 2002:a17:902:b493:b029:12b:aed5:ce06 with SMTP id y19-20020a170902b493b029012baed5ce06mr14244736plr.18.1627909713751; Mon, 02 Aug 2021 06:08:33 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id 20sm14260271pgg.36.2021.08.02.06.08.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 06:08:33 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 99815C02FD for ; Sun, 1 Aug 2021 21:29:40 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130] Date: Sun, 1 Aug 2021 21:29:40 -0700 Message-Id: <20210802042940.932692-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802042940.932692-1-hjl.tools@gmail.com> References: <20210802042940.932692-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3031.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" has extern struct r_debug _r_debug; which is exported from ld.so. rtld.c has /* Initialize _r_debug. */ struct r_debug *r = _dl_debug_initialize (GL(dl_rtld_map).l_addr, LM_ID_BASE); ... if (main_map->l_info[DT_DEBUG] != NULL) /* There is a DT_DEBUG entry in the dynamic section. Fill it in with the run-time address of the r_debug structure */ main_map->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r; With COPY relocation, the address of _r_debug at run-time may be in the executable if it references _r_debug. Since debugger uses DT_DEBUG, it will reference the staled original definition of _r_debug in ld.so. 1. Add a function, __r_debug_location, which returns the address of _r_debug: /* Return the address of that structure used by the dynamic linker. */ extern struct r_debug * __r_debug_location (void) __attribute_const__; It has a special glibc version, GLIBC_DEBUG. 2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location: #define _r_debug (*__r_debug_location ()) The existing dynamic executables with _r_debug reference will get a copy of _r_debug which won't be updated by ld.so. But DT_DEBUG will work with debuggers. 3. The static executables linked against glibc 2.35 will get the _r_debug symbol from __r_debug_location definition in libc.a. This fixes BZ #28130. --- elf/Makefile | 14 +++- elf/Versions | 4 ++ elf/dl-debug.c | 23 ++++-- elf/link.h | 5 +- elf/tst-dlopen-static.c | 71 +++++++++++++++++++ sysdeps/mach/hurd/i386/ld.abilist | 1 + sysdeps/unix/sysv/linux/aarch64/ld.abilist | 1 + sysdeps/unix/sysv/linux/alpha/ld.abilist | 1 + sysdeps/unix/sysv/linux/arc/ld.abilist | 1 + sysdeps/unix/sysv/linux/arm/be/ld.abilist | 1 + sysdeps/unix/sysv/linux/arm/le/ld.abilist | 1 + sysdeps/unix/sysv/linux/csky/ld.abilist | 1 + sysdeps/unix/sysv/linux/hppa/ld.abilist | 1 + sysdeps/unix/sysv/linux/i386/ld.abilist | 1 + sysdeps/unix/sysv/linux/ia64/ld.abilist | 1 + .../unix/sysv/linux/m68k/coldfire/ld.abilist | 1 + .../unix/sysv/linux/m68k/m680x0/ld.abilist | 1 + sysdeps/unix/sysv/linux/microblaze/ld.abilist | 1 + .../unix/sysv/linux/mips/mips32/ld.abilist | 1 + .../sysv/linux/mips/mips64/n32/ld.abilist | 1 + .../sysv/linux/mips/mips64/n64/ld.abilist | 1 + sysdeps/unix/sysv/linux/nios2/ld.abilist | 1 + .../sysv/linux/powerpc/powerpc32/ld.abilist | 1 + .../linux/powerpc/powerpc64/be/ld.abilist | 1 + .../linux/powerpc/powerpc64/le/ld.abilist | 1 + sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist | 1 + sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist | 1 + .../unix/sysv/linux/s390/s390-32/ld.abilist | 1 + .../unix/sysv/linux/s390/s390-64/ld.abilist | 1 + sysdeps/unix/sysv/linux/sh/be/ld.abilist | 1 + sysdeps/unix/sysv/linux/sh/le/ld.abilist | 1 + .../unix/sysv/linux/sparc/sparc32/ld.abilist | 1 + .../unix/sysv/linux/sparc/sparc64/ld.abilist | 1 + sysdeps/unix/sysv/linux/x86_64/64/ld.abilist | 1 + sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist | 1 + 35 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 elf/tst-dlopen-static.c diff --git a/elf/Makefile b/elf/Makefile index d05f410592..8fad633d2c 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -187,11 +187,14 @@ tests-internal := tst-tls1 tst-tls2 $(tests-static-internal) tests-static := $(tests-static-normal) $(tests-static-internal) ifeq (yes,$(build-shared)) -tests-static += tst-tls9-static tst-single_threaded-static-dlopen +tests-static += tst-tls9-static tst-single_threaded-static-dlopen \ + tst-dlopen-static +tests-special += $(objpfx)tst-dlopen-static-_r_debug.out static-dlopen-environment = \ LD_LIBRARY_PATH=$(ld-library-path):$(common-objpfx)dlfcn tst-tls9-static-ENV = $(static-dlopen-environment) tst-single_threaded-static-dlopen-ENV = $(static-dlopen-environment) +tst-dlopen-static-ENV = $(static-dlopen-environment) tests += restest1 preloadtest loadfail multiload origtest resolvfail \ constload1 order noload filter \ @@ -609,6 +612,8 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map) $(call after-link,$@.new) $(READELF) -s $@.new \ | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }' + $(READELF) -rW $@.new \ + | $(AWK) '($$5 ~/_r_debug/) { print; p=1 } END { exit p != 0 }' mv -f $@.new $@ ifeq (yes,$(build-shared)) @@ -1710,6 +1715,13 @@ $(objpfx)tst-single_threaded-pthread.out: \ $(objpfx)tst-single_threaded-mod4.so $(objpfx)tst-single_threaded-pthread-static: $(static-thread-library) +$(objpfx)tst-dlopen-static: $(objpfx)tst-single_threaded-mod1.o +$(objpfx)tst-dlopen-static.out: $(objpfx)tst-single_threaded-mod2.so +$(objpfx)tst-dlopen-static-_r_debug.out: $(objpfx)tst-dlopen-static + $(READELF) -sW $< \ + | $(AWK) '($$8 ~ /_r_debug$$/) { print; p=1 } END { exit p == 0 }' > $@ + $(evaluate-test) + $(objpfx)tst-tls-ie: $(shared-thread-library) $(objpfx)tst-tls-ie.out: \ $(objpfx)tst-tls-ie-mod0.so \ diff --git a/elf/Versions b/elf/Versions index 775aab62af..75170f2ebc 100644 --- a/elf/Versions +++ b/elf/Versions @@ -48,6 +48,10 @@ ld { # stack canary __stack_chk_guard; } + GLIBC_DEBUG { + # Adddess of _r_debug + __r_debug_location; + } GLIBC_PRIVATE { # Those are in the dynamic linker, but used by libc.so. __libc_enable_secure; diff --git a/elf/dl-debug.c b/elf/dl-debug.c index 2cd5f09753..6ae9d7839f 100644 --- a/elf/dl-debug.c +++ b/elf/dl-debug.c @@ -17,7 +17,7 @@ . */ #include - +#include /* These are the members in the public `struct link_map' type. Sanity check that the internal type and the public type match. */ @@ -34,11 +34,19 @@ extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr) normally finds it via the DT_DEBUG entry in the dynamic section, but in a statically-linked program there is no dynamic section for the debugger to examine and it looks for this particular symbol name. */ +#undef _r_debug struct r_debug _r_debug; +extern struct r_debug _r_debug_internal attribute_hidden; +strong_alias (_r_debug, _r_debug_internal) + +#if SHLIB_COMPAT (rtld, GLIBC_2_0, GLIBC_2_34) +strong_alias (_r_debug, _r_debug_compat) +compat_symbol (rtld, _r_debug_compat, _r_debug, GLIBC_2_0); +#endif -/* Initialize _r_debug if it has not already been done. The argument is - the run-time load address of the dynamic linker, to be put in +/* Initialize _r_debug if it has not already been done. The argument + is the run-time load address of the dynamic linker, to be put in _r_debug.r_ldbase. Returns the address of _r_debug. */ struct r_debug * @@ -47,7 +55,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) struct r_debug *r; if (ns == LM_ID_BASE) - r = &_r_debug; + r = &_r_debug_internal; else r = &GL(dl_ns)[ns]._ns_debug; @@ -55,7 +63,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) { /* Tell the debugger where to find the map of loaded objects. */ r->r_version = 1 /* R_DEBUG_VERSION XXX */; - r->r_ldbase = ldbase ?: _r_debug.r_ldbase; + r->r_ldbase = ldbase ?: _r_debug_internal.r_ldbase; r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded; r->r_brk = (ElfW(Addr)) &_dl_debug_state; } @@ -63,6 +71,11 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) return r; } +struct r_debug * +__r_debug_location (void) +{ + return &_r_debug_internal; +} /* This function exists solely to have a breakpoint set on it by the debugger. The debugger is supposed to find this function's address by diff --git a/elf/link.h b/elf/link.h index ff3a85c847..17477a2409 100644 --- a/elf/link.h +++ b/elf/link.h @@ -63,8 +63,9 @@ struct r_debug ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */ }; -/* This is the instance of that structure used by the dynamic linker. */ -extern struct r_debug _r_debug; +/* Return the address of that structure used by the dynamic linker. */ +extern struct r_debug * __r_debug_location (void) __attribute_const__; +#define _r_debug (*__r_debug_location ()) /* This symbol refers to the "dynamic structure" in the `.dynamic' section of whatever module refers to `_DYNAMIC'. So, to find its own diff --git a/elf/tst-dlopen-static.c b/elf/tst-dlopen-static.c new file mode 100644 index 0000000000..e9e06c0873 --- /dev/null +++ b/elf/tst-dlopen-static.c @@ -0,0 +1,71 @@ +/* Test static dlopen with _r_debug. + Copyright (C) 2021 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 +#include +#include +#include +#include +#include +#include + +static int +do_test (void) +{ + TEST_VERIFY (__libc_single_threaded); + + /* Defined in tst-single-threaded-mod1.o. */ + extern _Bool single_threaded_1 (void); + TEST_VERIFY (single_threaded_1 ()); + + /* A failed dlopen does not change the multi-threaded status. */ + TEST_VERIFY (dlopen ("tst-single_threaded-does-not-exist.so", RTLD_LAZY) + == NULL); + TEST_VERIFY (__libc_single_threaded); + TEST_VERIFY (single_threaded_1 ()); + + /* And neither does a successful dlopen for outer (static) libc. */ + const char *mod2 = "tst-single_threaded-mod2.so"; + void *handle_mod2 = xdlopen (mod2, RTLD_LAZY); + _Bool (*single_threaded_2) (void) + = xdlsym (handle_mod2, "single_threaded_2"); + TEST_VERIFY (__libc_single_threaded); + TEST_VERIFY (single_threaded_1 ()); + /* The inner libc always assumes multi-threaded use. */ + TEST_VERIFY (!single_threaded_2 ()); + + /* Check the working _r_debug. */ + struct link_map *map; + int missing_mod2 = 1; + for (map = _r_debug.r_map; map != NULL; map = map->l_next) + { + const char *name = basename (map->l_name); + printf ("module name = '%s'\n", name); + if (strcmp (mod2, name) == 0) + missing_mod2 = 0; + } + + if (missing_mod2) + FAIL_EXIT1 ("'%s' is missing in _r_debug\n", mod2); + + xdlclose (handle_mod2); + + return 0; +} + +#include diff --git a/sysdeps/mach/hurd/i386/ld.abilist b/sysdeps/mach/hurd/i386/ld.abilist index 7e20c5e7ce..787f3823d2 100644 --- a/sysdeps/mach/hurd/i386/ld.abilist +++ b/sysdeps/mach/hurd/i386/ld.abilist @@ -16,3 +16,4 @@ GLIBC_2.2.6 _r_debug D 0x14 GLIBC_2.2.6 abort F GLIBC_2.3 ___tls_get_addr F GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/aarch64/ld.abilist b/sysdeps/unix/sysv/linux/aarch64/ld.abilist index 80b2fe6725..7f9f98d82b 100644 --- a/sysdeps/unix/sysv/linux/aarch64/ld.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.17 __stack_chk_guard D 0x8 GLIBC_2.17 __tls_get_addr F GLIBC_2.17 _dl_mcount F GLIBC_2.17 _r_debug D 0x28 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/alpha/ld.abilist b/sysdeps/unix/sysv/linux/alpha/ld.abilist index 98a03f611f..df2c12874b 100644 --- a/sysdeps/unix/sysv/linux/alpha/ld.abilist +++ b/sysdeps/unix/sysv/linux/alpha/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.1 __libc_stack_end D 0x8 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x8 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/arc/ld.abilist b/sysdeps/unix/sysv/linux/arc/ld.abilist index 048f17c848..2ef94c4b0c 100644 --- a/sysdeps/unix/sysv/linux/arc/ld.abilist +++ b/sysdeps/unix/sysv/linux/arc/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.32 __stack_chk_guard D 0x4 GLIBC_2.32 __tls_get_addr F GLIBC_2.32 _dl_mcount F GLIBC_2.32 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/arm/be/ld.abilist b/sysdeps/unix/sysv/linux/arm/be/ld.abilist index cc8825c3bc..20fe887a08 100644 --- a/sysdeps/unix/sysv/linux/arm/be/ld.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.4 __stack_chk_guard D 0x4 GLIBC_2.4 __tls_get_addr F GLIBC_2.4 _dl_mcount F GLIBC_2.4 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/arm/le/ld.abilist b/sysdeps/unix/sysv/linux/arm/le/ld.abilist index cc8825c3bc..20fe887a08 100644 --- a/sysdeps/unix/sysv/linux/arm/le/ld.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.4 __stack_chk_guard D 0x4 GLIBC_2.4 __tls_get_addr F GLIBC_2.4 _dl_mcount F GLIBC_2.4 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/csky/ld.abilist b/sysdeps/unix/sysv/linux/csky/ld.abilist index 564ac09737..f81f677ac2 100644 --- a/sysdeps/unix/sysv/linux/csky/ld.abilist +++ b/sysdeps/unix/sysv/linux/csky/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.29 __stack_chk_guard D 0x4 GLIBC_2.29 __tls_get_addr F GLIBC_2.29 _dl_mcount F GLIBC_2.29 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/hppa/ld.abilist b/sysdeps/unix/sysv/linux/hppa/ld.abilist index d155a59843..04eddb99b4 100644 --- a/sysdeps/unix/sysv/linux/hppa/ld.abilist +++ b/sysdeps/unix/sysv/linux/hppa/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x14 GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x4 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/i386/ld.abilist b/sysdeps/unix/sysv/linux/i386/ld.abilist index 0478e22071..7e5e14aaa9 100644 --- a/sysdeps/unix/sysv/linux/i386/ld.abilist +++ b/sysdeps/unix/sysv/linux/i386/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 ___tls_get_addr F GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/ia64/ld.abilist b/sysdeps/unix/sysv/linux/ia64/ld.abilist index 33f91199bf..60753bba7b 100644 --- a/sysdeps/unix/sysv/linux/ia64/ld.abilist +++ b/sysdeps/unix/sysv/linux/ia64/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x28 GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist index cc8825c3bc..20fe887a08 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.4 __stack_chk_guard D 0x4 GLIBC_2.4 __tls_get_addr F GLIBC_2.4 _dl_mcount F GLIBC_2.4 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist index 3ba474c27f..0120721413 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x4 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/microblaze/ld.abilist b/sysdeps/unix/sysv/linux/microblaze/ld.abilist index a4933c3541..7ca079e207 100644 --- a/sysdeps/unix/sysv/linux/microblaze/ld.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.18 __stack_chk_guard D 0x4 GLIBC_2.18 __tls_get_addr F GLIBC_2.18 _dl_mcount F GLIBC_2.18 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist index be09641a48..a25c73d95d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x4 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist index be09641a48..a25c73d95d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x4 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist index 1ea36e13f2..0c93ebf0ca 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x8 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/nios2/ld.abilist b/sysdeps/unix/sysv/linux/nios2/ld.abilist index 52178802dd..63bef92e76 100644 --- a/sysdeps/unix/sysv/linux/nios2/ld.abilist +++ b/sysdeps/unix/sysv/linux/nios2/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.21 __stack_chk_guard D 0x4 GLIBC_2.21 __tls_get_addr F GLIBC_2.21 _dl_mcount F GLIBC_2.21 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist index 4bbfba7a61..9ddccbe46e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist @@ -4,3 +4,4 @@ GLIBC_2.1 _dl_mcount F GLIBC_2.22 __tls_get_addr_opt F GLIBC_2.23 __parse_hwcap_and_convert_at_platform F GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist index 283fb4510b..cf503ddbbf 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist @@ -4,3 +4,4 @@ GLIBC_2.3 __libc_stack_end D 0x8 GLIBC_2.3 __tls_get_addr F GLIBC_2.3 _dl_mcount F GLIBC_2.3 _r_debug D 0x28 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist index b1f313c7cd..80c12fbf9d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist @@ -4,3 +4,4 @@ GLIBC_2.17 _dl_mcount F GLIBC_2.17 _r_debug D 0x28 GLIBC_2.22 __tls_get_addr_opt F GLIBC_2.23 __parse_hwcap_and_convert_at_platform F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist index 94ca64c43d..8758f252b1 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.33 __stack_chk_guard D 0x4 GLIBC_2.33 __tls_get_addr F GLIBC_2.33 _dl_mcount F GLIBC_2.33 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist index 845f356c3c..57c5fab0e1 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.27 __stack_chk_guard D 0x8 GLIBC_2.27 __tls_get_addr F GLIBC_2.27 _dl_mcount F GLIBC_2.27 _r_debug D 0x28 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist index b56f005beb..71f9172261 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_offset F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist index 6f788a086d..cc7fd7acf7 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x28 GLIBC_2.3 __tls_get_offset F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/sh/be/ld.abilist b/sysdeps/unix/sysv/linux/sh/be/ld.abilist index d155a59843..04eddb99b4 100644 --- a/sysdeps/unix/sysv/linux/sh/be/ld.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x14 GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x4 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/sh/le/ld.abilist b/sysdeps/unix/sysv/linux/sh/le/ld.abilist index d155a59843..04eddb99b4 100644 --- a/sysdeps/unix/sysv/linux/sh/le/ld.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/ld.abilist @@ -3,3 +3,4 @@ GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x14 GLIBC_2.3 __tls_get_addr F GLIBC_2.4 __stack_chk_guard D 0x4 +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist index 0c6610e3c2..7e4b112260 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist index 33f91199bf..60753bba7b 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x28 GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist index d3cdf7611e..dd92378ae1 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.2.5 __libc_stack_end D 0x8 GLIBC_2.2.5 _dl_mcount F GLIBC_2.2.5 _r_debug D 0x28 GLIBC_2.3 __tls_get_addr F +GLIBC_DEBUG __r_debug_location F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist index c70bccf782..14d41ebcd9 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist @@ -2,3 +2,4 @@ GLIBC_2.16 __libc_stack_end D 0x4 GLIBC_2.16 __tls_get_addr F GLIBC_2.16 _dl_mcount F GLIBC_2.16 _r_debug D 0x14 +GLIBC_DEBUG __r_debug_location F