From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 5B1643858D3C for ; Thu, 14 Apr 2022 05:19:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B1643858D3C Received: by mail-pg1-x532.google.com with SMTP id t13so3833403pgn.8 for ; Wed, 13 Apr 2022 22:19:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2IJoT0arKp1OWaocNKxNloc2O0pFDn8hq7IJuZoCi2k=; b=8RZFlPwywpfZ2002e2P1SW02dNkDfkM9z7eXG8oRXDp9YwVUVZ/Lss8ao//Z1BIxZz WhqhCFLLs2jc8wumEdBBXOGX6JJLMmfFDEIyPqmwkQHjrMXxBB3KIOBgK4k5QFoeJLxf meRFobCzgsMx3pzQliMr1WJ/i9897PyumjUl5fIeR5uCv5zej3y5D9dQZvhkTmWwBqkr 2r1Vcvr8Kbcs67QFM4mzFHhJagW0hS9I9w66YB71QfpHHDHFVMf11ZGgdsVf+c4+gHoT 1uw1roOeSaBazsXLJJxzgz8HJl7pq4zUhj0uf9uMT768YPDDHdgaPWvLWHq1nyfhkhQo je8A== X-Gm-Message-State: AOAM530jLj+58fh0LRNGzuSokyXRwwKZERCIlGEJJCZwnW9gNkiq9u1R Y5HePZm2EvgskwM4RkNkxPc= X-Google-Smtp-Source: ABdhPJza746TAfvulc8QWjkPnFPzFO7nL3VbGZ8MOGuKwE/4969gL4dwnAnW4iu3zx0a5JMPEjApqQ== X-Received: by 2002:a65:5acd:0:b0:399:24bc:bbfd with SMTP id d13-20020a655acd000000b0039924bcbbfdmr933178pgt.323.1649913542314; Wed, 13 Apr 2022 22:19:02 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:a6d4:68dc:d4c1:1be6]) by smtp.gmail.com with ESMTPSA id x5-20020aa79a45000000b00504a1c8b75asm789648pfj.165.2022.04.13.22.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 22:19:01 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id A9CA31140F2B; Thu, 14 Apr 2022 14:48:57 +0930 (ACST) Date: Thu, 14 Apr 2022 14:48:57 +0930 From: Alan Modra To: "H.J. Lu" Cc: Fangrui Song , GNU C Library , Tulio Magno Quites Machado Filho Subject: Re: DT_RELR without libc.so dependency Message-ID: References: <20220228064052.3413334-1-amodra@gmail.com> <20220409001412.ezhmy7i2sqq7t256@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3028.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=no 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-List-Received-Date: Thu, 14 Apr 2022 05:19:05 -0000 On Wed, Apr 13, 2022 at 06:54:17PM -0700, H.J. Lu wrote: > On Wed, Apr 13, 2022 at 5:34 PM Alan Modra wrote: > > > > On Fri, Apr 08, 2022 at 05:14:12PM -0700, Fangrui Song wrote: > > > HJ's DT_RELR patch series has been upgraded to v7 > > > (https://patchwork.sourceware.org/project/glibc/list/?series=8295) > > > > > > git-pw series apply 8295 > > > # `Add --disable-default-dt-relr` does not apply cleanly > > > > > > If no regressions with default DT_RELR, that will be cool! > > > > I did find one error when testing a build of glibc using Ubuntu gcc-8. > > elf/filter fails with "error while loading shared libraries: > > .../elf/filtmod1.so: DT_RELR without GLIBC_ABI_DT_RELR dependency". > > > > A little analysis shows the problem occurs when filtmod1.so is linked > > with --as-needed and libc.so is not needed. filtmod1.so ends up with > > no .gnu.version or .gnu.version_r sections, and of course no > > GLIBC_ABI_DT_RELR version. > > > > The error check is not one that belongs in ld.so. If you have the > > error checking code, then you have DT_RELR support in ld.so and there > > is no reason at all to refuse to run the program! The check should be > > in the linker, if anywhere. > > > > The GLIBC_ABI_DT_RELR dependency is added to avoid the random > crush at run-time with older glibc binaries. Since it is possible to create > a DSO with DT_RELR, but without the libc.so dependency. Should ld.so > skip the GLIBC_ABI_DT_RELR check if the DSO doesn't depend on > libc.so? I understand why you want a dependency, but I do not see a hard requirement for l_abi_version or any code using it. If you try to run a new binary with DT_RELR using an old glibc or even current glibc without relr support, you'll get "version `GLIBC_ABI_DT_RELR' not found". That is sufficient, presuming there is a GLIBC_ABI_DT_RELR version in the binary. If there *isn't* a GLIBC_ABI_DT_RELR version then running that binary on an older glibc probably will crash. Putting a check in a newer ld.so doesn't help much with that, except show up this case where the dependency isn't there. I guess the check is justifiable under some DL_DEBUG flag. Lack of a dependency is either a linker bug or a relr design bug. Nitpick: isn't the actual dependency on ld.so rather than libc.so? -- Alan Modra Australia Development Lab, IBM