From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 20BA13858D1E for ; Fri, 29 Apr 2022 07:43:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 20BA13858D1E Received: by mail-pf1-x430.google.com with SMTP id g8so3863977pfh.5 for ; Fri, 29 Apr 2022 00:43:55 -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=uV/4bnxqggGRvIZAg8HosYqueu1wFBlmLatZ3qTZTJ4=; b=xW9EJ2rHWt/P7m6D44SDBiT3+Jd+d7lRYLMBxr5pKwx1i6VleZMSHfPAKqkmzaIVfX YVpZvV0Cdvwn0iNn/IcZbNk5MGx4+n5LxbajWOnj9+RJDcl+fSIDwiVpupeweBlULP0u IsyOymuqT/YlvD2RdkRTV8YQOGP0KwL2bq1Es7drfYgkVRaLGI7ii1ESdn2fVCDgLE3/ 8FrofulbsWb0qpk0Gn6La6+WOlmreo4+0cZ5vtW+inIUTj4XWW+CSpfmxGkflpWqgqbA gEnjmQpFRitZzpIF6Q2AY1EuZoDcjGyVHZo5dCSVqfkpBAjKXA9qLWufxnT4qxNDEIEv Wm/w== X-Gm-Message-State: AOAM530W7Tf0FEsZ8x57lreoCnmiqmT8hdQNLi0ymil6V2ysMoriltlG hFm78L6y4rOK4sTqykKn+nEIxyJdU7aCPg== X-Google-Smtp-Source: ABdhPJw7AM0ghTHLtYFEHq+EKeGHJklnOz6oin2wTw+33krevQU6QHLNjcR7GCeki1Gg4omsO+TrXQ== X-Received: by 2002:a63:5b0c:0:b0:3ab:358a:3b16 with SMTP id p12-20020a635b0c000000b003ab358a3b16mr20660154pgb.306.1651218233108; Fri, 29 Apr 2022 00:43:53 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:fb4f:b611:3fdd:bd70]) by smtp.gmail.com with ESMTPSA id z21-20020a62d115000000b0050d3c39e5a1sm2027367pfg.2.2022.04.29.00.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 00:43:52 -0700 (PDT) Date: Fri, 29 Apr 2022 00:43:49 -0700 From: Fangrui Song To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3 2/2] Default to --with-default-link=no (bug 25812) Message-ID: <20220429074349.gna53j7ujgqql4ux@google.com> References: <15c7f6e9afe2c2b9c51ebc6372682a39b0932712.1649691083.git.fweimer@redhat.com> <20220428072502.4rpxnlreq72sgv5x@google.com> <87zgk5bnxo.fsf@oldenburg.str.redhat.com> <20220429060041.n24pkmlujglkumer@google.com> <87h76c74cb.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <87h76c74cb.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, 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.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: Fri, 29 Apr 2022 07:43:56 -0000 On 2022-04-29, Florian Weimer wrote: >* Fangrui Song: > >>>How does lld place sections without a linker script? Purely based on >>>names? >> >> It entirely uses code to describe the built-in rules like gold, while >> GNU ld uses an internal linker script plus built-in code. >> (some rules cannot be described by the linker script language and needs >> code anyway). > >How can we make sure that certain sections are covered by RELRO, and >still get start/stop symbols for them? About __start_/__stop_: __start_/__stop_ symbols are special. They don't need to be mentioned in a linker script to take effects for lld and modern GNU ld. I haven't checked whether there is an ancient GNU ld which requires symbol assignments when the output section description is specified. About RELRO: It seems that there is no section name convention to make a section RELRO. Having a SECTIONS command with DATA_SEGMENT_ALIGN / DATA_SEGMENT_RELRO_END can specify all RELRO sections. I do not know a simpler approach than postprocessing ld.bfd --verbose output. To make GNU ld work, the following linker script is sufficient: SECTIONS { __libc_subfreeres : { *(__libc_subfreeres) } __libc_atexit : { *(__libc_atexit) } __libc_IO_vtables : { *(__libc_IO_vtables) } } INSERT BEFORE .data.rel.ro; This script does not work with ld.lld right now because there is an `error: section ... is not contiguous with other relro sections` from https://reviews.llvm.org/D40359 . I need to think whether the diagnostic can be suppressed in some cases. >>>> Besides, the position of .hash in --with-default-link=no seems weird. >>>> 71213dc2589554dc8f8061e9b04e80c55d098b6a (2006-09) moved it to the end >>>> of the RO segment. >>> >>>I think it's odd that we have an old-style hash table at all. Do we >>>really need it? All tools should have migrated by now. >> >> We can remove .hash for non-mips architectures. > >We need the support in glibc for most architectures in the dynamic >linker, but we don't have to build glibc with the legacy hash tables. Agree >> (I am a bit sad .MIPS.xhash support went in, but thankfully it doesn't take >> too much code. The translation table could be solved in a better way. I >> suspect the whole thing is unnecessary with RELR.) > >Huh? Aren't they unrelated? > `DT_MIPS_LOCAL_GOTNO` and `DT_MIPS_SYMTABNO-DT_MIPS_GOTSYM` can be defined in a way that there is no special handling. Then there will be no requirement on the .dynsym ordering. Then the regular DT_GNU_HASH can be used, and DT_MIPS_XHASH will be unneeded. `DT_MIPS_LOCAL_GOTNO` optimizes on top of relative relocations but with RELR the additional benefit is very low. >Thanks, >Florian >