From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fuchsia.ash.relay.mailchannels.net (fuchsia.ash.relay.mailchannels.net [23.83.222.64]) by sourceware.org (Postfix) with ESMTPS id 9F9683858D1E for ; Thu, 10 Feb 2022 06:12:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F9683858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 2EFD58821F8; Thu, 10 Feb 2022 06:12:21 +0000 (UTC) Received: from pdx1-sub0-mail-a306.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id A9F1B88209F; Thu, 10 Feb 2022 06:12:20 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a306.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.113.27 (trex/6.4.3); Thu, 10 Feb 2022 06:12:21 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Thread-Thoughtful: 4772494206e17c6c_1644473540972_3984843690 X-MC-Loop-Signature: 1644473540971:1897591081 X-MC-Ingress-Time: 1644473540971 Received: from [192.168.196.116] (unknown [106.220.173.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a306.dreamhost.com (Postfix) with ESMTPSA id 4JvRH71RfXz1NC; Wed, 9 Feb 2022 22:12:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1644473540; bh=r7i9atf2VfvxWu+tYryKUdlwkfk=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=L+MoT4/8sTy+CTfw0i5BEW+pFwxT9FIaP6az0havwnD4q+5alBHk/rOQGxxcpG9qs xmn1t5b7YNZPajhsoOR/Pj/KFTkEIxevNCLGeRVw8uJxnawOebDkklxU2MEvMRFe/T 879l6aj59XFP8de7ZPH10MtMUrPBX8fe+qI8UuPg= Message-ID: Date: Thu, 10 Feb 2022 11:42:14 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v2 3/3] elf: Remove LD_USE_LOAD_BIAS Content-Language: en-US To: Adhemerval Zanella , libc-alpha@sourceware.org Cc: Richard Purdie References: <20220203185732.1842679-1-adhemerval.zanella@linaro.org> <20220203185732.1842679-4-adhemerval.zanella@linaro.org> From: Siddhesh Poyarekar In-Reply-To: <20220203185732.1842679-4-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3036.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Thu, 10 Feb 2022 06:12:28 -0000 On 04/02/2022 00:27, Adhemerval Zanella via Libc-alpha wrote: > It is solely for prelink with PIE exectuables [1]. > > [1] https://sourceware.org/legacy-ml/libc-hacker/2003-11/msg00127.html LGTM. Reviewed-by: Siddhesh Poyarekar > --- > NEWS | 3 +++ > elf/dl-map-segments.h | 3 +-- > elf/dl-support.c | 1 - > elf/rtld.c | 13 ------------- > sysdeps/generic/ldsodefs.h | 5 ----- > sysdeps/generic/unsecvars.h | 1 - > 6 files changed, 4 insertions(+), 22 deletions(-) > > diff --git a/NEWS b/NEWS > index f9c4589037..b1540ba583 100644 > --- a/NEWS > +++ b/NEWS > @@ -196,6 +196,9 @@ Deprecated and removed features, and other changes affecting compatibility: > functionality to obtain the program mapping address can be achieved by > using LD_TRACE_LOADED_OBJECTS to value of 2. > > +* The LD_USE_LOAD_BIAS has been removed. The variable was mainly used to > + support prelink PIE binaries. > + > Changes to build and runtime requirements: > > * The audit module interface version LAV_CURRENT is increased to enable > diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h > index 172692b120..b3513e7909 100644 > --- a/elf/dl-map-segments.h > +++ b/elf/dl-map-segments.h > @@ -94,8 +94,7 @@ _dl_map_segments (struct link_map *l, int fd, > prefer to map such objects at; but this is only a preference, > the OS can do whatever it likes. */ > ElfW(Addr) mappref > - = (ELF_PREFERRED_ADDRESS (loader, maplength, > - c->mapstart & GLRO(dl_use_load_bias)) > + = (ELF_PREFERRED_ADDRESS (loader, maplength, c->mapstart) > - MAP_BASE_ADDR (l)); > > /* Remember which part of the address space this object uses. */ > diff --git a/elf/dl-support.c b/elf/dl-support.c > index fb64765537..6d2c4baf81 100644 > --- a/elf/dl-support.c > +++ b/elf/dl-support.c > @@ -54,7 +54,6 @@ size_t _dl_platformlen; > > int _dl_debug_mask; > int _dl_lazy; > -ElfW(Addr) _dl_use_load_bias = -2; > int _dl_dynamic_weak; > > /* If nonzero print warnings about problematic situations. */ > diff --git a/elf/rtld.c b/elf/rtld.c > index aa18256d86..19e328f89e 100644 > --- a/elf/rtld.c > +++ b/elf/rtld.c > @@ -365,7 +365,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro = > ._dl_sysinfo = DL_SYSINFO_DEFAULT, > #endif > ._dl_debug_fd = STDERR_FILENO, > - ._dl_use_load_bias = -2, > ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID, > #if !HAVE_TUNABLES > ._dl_hwcap_mask = HWCAP_IMPORTANT, > @@ -1742,12 +1741,6 @@ dl_main (const ElfW(Phdr) *phdr, > ++GL(dl_ns)[LM_ID_BASE]._ns_nloaded; > ++GL(dl_load_adds); > > - /* If LD_USE_LOAD_BIAS env variable has not been seen, default > - to not using bias for non-prelinked PIEs and libraries > - and using it for executables or prelinked PIEs or libraries. */ > - if (GLRO(dl_use_load_bias) == (ElfW(Addr)) -2) > - GLRO(dl_use_load_bias) = main_map->l_addr == 0 ? -1 : 0; > - > /* Starting from binutils-2.23, the linker will define the magic symbol > __ehdr_start to point to our own ELF header if it is visible in a > segment that also includes the phdrs. If that's not available, we use > @@ -2657,12 +2650,6 @@ process_envvars (struct dl_main_state *state) > #ifdef EXTRA_LD_ENVVARS_13 > EXTRA_LD_ENVVARS_13 > #endif > - if (!__libc_enable_secure > - && memcmp (envline, "USE_LOAD_BIAS", 13) == 0) > - { > - GLRO(dl_use_load_bias) = envline[14] == '1' ? -1 : 0; > - break; > - } > break; > > case 14: > diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h > index d1c6cd902b..9878e7e87e 100644 > --- a/sysdeps/generic/ldsodefs.h > +++ b/sysdeps/generic/ldsodefs.h > @@ -628,11 +628,6 @@ struct rtld_global_ro > /* Location of the binary. */ > EXTERN const char *_dl_origin_path; > > - /* -1 if the dynamic linker should honor library load bias, > - 0 if not, -2 use the default (honor biases for normal > - binaries, don't honor for PIEs). */ > - EXTERN ElfW(Addr) _dl_use_load_bias; > - > /* Size of the static TLS block. */ > EXTERN size_t _dl_tls_static_size; > > diff --git a/sysdeps/generic/unsecvars.h b/sysdeps/generic/unsecvars.h > index 5ea8a4a259..b50331b50f 100644 > --- a/sysdeps/generic/unsecvars.h > +++ b/sysdeps/generic/unsecvars.h > @@ -22,7 +22,6 @@ > "LD_PRELOAD\0" \ > "LD_PROFILE\0" \ > "LD_SHOW_AUXV\0" \ > - "LD_USE_LOAD_BIAS\0" \ > "LOCALDOMAIN\0" \ > "LOCPATH\0" \ > "MALLOC_TRACE\0" \