From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id A4DF63858004 for ; Fri, 28 Oct 2022 23:57:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A4DF63858004 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-x62d.google.com with SMTP id l2so6126138pld.13 for ; Fri, 28 Oct 2022 16:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=y/4RpM2uhmQv5iA63GI3kzybhrObmOVzRD5G480vTpo=; b=MWNFysDKv2CrLzzD0kH2DdQhkMiPVnbS66JnoJ6DLeRIAA9uTpOmq6lwmMh90ZIVeH NwcmzWmERY5SjWEt/D385vekT2IGCJqyFYCH7dYaAIgcE9ZcVuL+CfdmnnvwSAmIQWLx chJFm6fTJ6z/JzU0SOxid/Q8ceznRNr/gGe02iZuZpt73C1DeAFG3vDbrqgNmkl52CC4 /77oQI+WsvDYHd6MjNsvU3mYmbUzcaHH5mGnCfKxJocrIOdoUJUzm8wBHPq+1ColRUH+ Un40aimLv4I2LLomcgMXYf/EKeU3ip0sKeQNpgz32EnoFABfLgWUakGuRCguoPiAhU3h 04dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y/4RpM2uhmQv5iA63GI3kzybhrObmOVzRD5G480vTpo=; b=qE9RcNylPeqfzdS4aaTQKtLmxeFb2hPhe6gaWSzMqtXj3dxSThRX1T72/CIkOTTFV3 1wdDN1eBkwqCuONboUEEIxGC+OS+eJNaVZbqOPOhGT9DXyQiXAahyvLC5B1ad/WkhgEz PXXeuTn0I3xjXvioXTgnbtnXhiyDXnDiaBF6mxzz92DmfMfx5scGB9SQp2jdCSv2c7mJ R1epa0jLa77z2x2nJ7y6smLME1HziqS5v30gL8kvYLk7aVILQMHfPt7hB5Z7E3ju9SFJ ZdPDYdsQyv1D52xOTH605Ozmj7EUiTWwriT1yhLEcLespXUsCBIVkFWLD6WbSdZG4q8C Rm2A== X-Gm-Message-State: ACrzQf1MesPGGJIRLfpYZEKE/9UKePJyaBezr4jivoRsDKWaEFPNxNt9 fuo0pNFdacToF/LXgEJO22ecunBtlw+eSw== X-Google-Smtp-Source: AMsMyM7V41UExmpJGaMQfYCZHSSr5hfI6f8SC08/IHSQxOkyO5BS5jZXypzRnTpX0JqwNM1leMg3sg== X-Received: by 2002:a17:902:8542:b0:179:eb8d:f41d with SMTP id d2-20020a170902854200b00179eb8df41dmr1617563plo.62.1667001468605; Fri, 28 Oct 2022 16:57:48 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:8981:f21e:b257:256]) by smtp.gmail.com with ESMTPSA id l13-20020a17090a384d00b00208c58d5a0esm8775pjf.40.2022.10.28.16.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 16:57:47 -0700 (PDT) Date: Fri, 28 Oct 2022 16:57:44 -0700 From: Fangrui Song To: "H.J. Lu" Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] elf: Build tst-relr-mod[34]a.so with $(LDFLAGS-rpath-ORIGIN) Message-ID: <20221028235744.jl4gqkhox42dyihi@google.com> References: <20221028221632.500817-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221028221632.500817-1-hjl.tools@gmail.com> X-Spam-Status: No, score=-26.4 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-10-28, H.J. Lu via Libc-alpha wrote: >When --enable-hardcoded-path-in-tests is used only with DT_RUNPATH, >elf/tst-relr3 and elf/tst-relr4 failed to run. Their dependency >libraries, tst-relr-mod3a.so and tst-relr-mod4a.so, are failed to >load since DT_RUNPATH on executable doesn't apply to them. Build >tst-relr-mod3a.so and tst-relr-mod4a.so with $(LDFLAGS-rpath-ORIGIN) >to add DT_RUNPATH for their dependency libraries. >--- > elf/Makefile | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/elf/Makefile b/elf/Makefile >index 86c960cf8a..5f7d222bb1 100644 >--- a/elf/Makefile >+++ b/elf/Makefile >@@ -2872,7 +2872,7 @@ $(objpfx)tst-relr-mod3b.so: $(objpfx)tst-relr-mod3b.os > $(objpfx)tst-relr-mod3a.so: $(objpfx)tst-relr-mod3a.os \ > $(objpfx)tst-relr-mod3b.so > $(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \ >- $(LDFLAGS-soname-fname) \ >+ $(LDFLAGS-soname-fname) $(LDFLAGS-rpath-ORIGIN) \ > -shared -o $@.new $(filter-out $(map-file),$^) > $(call after-link,$@.new) > mv -f $@.new $@ >@@ -2891,7 +2891,7 @@ $(objpfx)tst-relr-mod4b.so: $(objpfx)tst-relr-mod4b.os > $(objpfx)tst-relr-mod4a.so: $(objpfx)tst-relr-mod4a.os \ > $(objpfx)tst-relr-mod4b.so > $(LINK.o) -nostdlib -nostartfiles -Wl,-z,pack-relative-relocs \ >- $(LDFLAGS-soname-fname) \ >+ $(LDFLAGS-soname-fname) $(LDFLAGS-rpath-ORIGIN) \ > -shared -o $@.new $(filter-out $(map-file),$^) > $(call after-link,$@.new) > mv -f $@.new $@ >-- >2.37.3 When --enable-hardcoded-path-in-tests is specified, the test is not run with `ld.so --library-path`. elf/tst-relr-mod3a.so's DT_NEEDED elf/tst-relr-mod3b.so fails to load. This patch makes elf/tst-relr-mod3a.so have `Library runpath: [$ORIGIN]` and allows elf/tst-relr-mod3b.so to be loaded. Tested that the tests pass with or without --enable-hardcoded-path-in-tests. Reviewed-by: Fangrui Song