From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by sourceware.org (Postfix) with ESMTPS id DD6A8386C5A0 for ; Wed, 22 Jun 2022 17:58:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DD6A8386C5A0 Received: by mail-yb1-xb31.google.com with SMTP id x38so31508344ybd.9 for ; Wed, 22 Jun 2022 10:58: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:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=I+Z32KNWQEO32afjvbdrklPyRocmUA7d2fzxjO/SFno=; b=0bGX7HJrWUk8t1VxG46lUKHCyaNs1ZxDlfdyVq7BSB6XX51SsgP8bpAroTIUfIQ/MW yKqeYvLN+B5wlYudPTUvnW8Rmv0Ts+zGIm5i0FpcQHEdd5D6I9z3h9UvrrkkwktgbikG OY4uVDjTYjdeEuuA/cMfoIVT8nDWkJdCWXM31UTXB6MfcDYfCOZr1ZaGrUZcmEoCBRNw mHhOIAja3iJGPDCOVHjV9f5dl8alj4SdmGxPlFZGU6Ats8rQjyrbJbv+A0q3mVwVBSTI 4IlLiEFiWafxQvEBEseRP9xFm2AutaZev5SP9oQIx7omRpYp4keC9wMzTjyWbnhjrM25 oEPw== X-Gm-Message-State: AJIora8h3uo+QYBrYr78X8+bta2EJ0hLzA0s3Hd6tWPkybfag5Uj+BRy SIFhgPtw/J50SDJyJyJ1dgDfKhJ1brJJpYVmiAVknP4bZe0= X-Google-Smtp-Source: AGRyM1v6F9Hkb+gURcbPbRKExT3jsPq8Psa59ClbIv7ETu9OEBlGUnvdck6LVGJrOZdrmCRcIyVtmeM7N4Zy8mNTIk8= X-Received: by 2002:a25:928e:0:b0:669:11d3:f9c2 with SMTP id y14-20020a25928e000000b0066911d3f9c2mr5176877ybl.250.1655920734966; Wed, 22 Jun 2022 10:58:54 -0700 (PDT) MIME-Version: 1.0 References: <20220602042059.2898835-1-maskray@google.com> In-Reply-To: <20220602042059.2898835-1-maskray@google.com> From: Fangrui Song Date: Wed, 22 Jun 2022 10:58:44 -0700 Message-ID: Subject: Re: [PATCH] aarch64: Define elf_backend_extern_protected_data to 0 [PR 18705] To: binutils@sourceware.org, Szabolcs Nagy , Nick Clifton Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-23.9 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, T_SCC_BODY_TEXT_LINE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2022 17:58:59 -0000 On Wed, Jun 1, 2022 at 9:21 PM Fangrui Song wrote: > > If an executable has copy relocations for extern protected data, that > can only work if the library containing the definition is built with > assumptions (a) the compiler emits GOT-generating relocations (b) the > linker produces R_*_GLOB_DAT instead of R_*_RELATIVE. Otherwise the > library uses its own definition directly and the executable accesses a > stale copy. > > Commit 32f573bcb3aaa1c9defcad79dbb5851fcc02ae2d changed ld to produce > R_AARCH64_GLOB_DAT but that defeated the purpose of protected visibility > as an optimization. Restore the previous behavior (which matches > ld.lld) by defining elf_backend_extern_protected_data to 0. > --- > bfd/elfnn-aarch64.c | 2 +- > ld/testsuite/ld-aarch64/protected-data.d | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c > index 4926bab9cf2..cb316a928ef 100644 > --- a/bfd/elfnn-aarch64.c > +++ b/bfd/elfnn-aarch64.c > @@ -10090,7 +10090,7 @@ const struct elf_size_info elfNN_aarch64_size_info = > #define elf_backend_dtrel_excludes_plt 1 > #define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3) > #define elf_backend_default_execstack 0 > -#define elf_backend_extern_protected_data 1 > +#define elf_backend_extern_protected_data 0 > #define elf_backend_hash_symbol elf_aarch64_hash_symbol > > #undef elf_backend_obj_attrs_section > diff --git a/ld/testsuite/ld-aarch64/protected-data.d b/ld/testsuite/ld-aarch64/protected-data.d > index 5dabf04748c..ee9b4cfc6b5 100644 > --- a/ld/testsuite/ld-aarch64/protected-data.d > +++ b/ld/testsuite/ld-aarch64/protected-data.d > @@ -2,4 +2,4 @@ > #ld: -shared > #readelf: -r -W > #... > -.* R_AARCH64_GLOB_DAT .* var.* > +.* R_AARCH64_RELATIVE .* > -- > 2.36.1.255.ge46751e96f-goog > :)