From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3JjyYYgcKCBsD1JBI1P7FF7C5.3FD29ELK9CJJFLI35N1I5.FI7@flex--maskray.bounces.google.com> Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by sourceware.org (Postfix) with ESMTPS id 5F4D13857342 for ; Thu, 2 Jun 2022 04:27:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F4D13857342 Received: by mail-yb1-xb49.google.com with SMTP id k73-20020a25244c000000b0065ca88b381aso3174429ybk.2 for ; Wed, 01 Jun 2022 21:27:20 -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:message-id:mime-version:subject:from:to:cc; bh=mf2xduytZZmxCoo/kGOi3/w2oqX+VdUK0XmDWp4nD38=; b=bjKIai3aetmP1A9n6smTDBLYQnhBw0B3diGXX0Cs0CNIT8mTjY5POfpdb5TDUgsMG1 RbZGaOuuD2G9Fpj/A9KViD2qFt8wjWaQOqY1Kb2JtlWz4p8a6VYQWyuxOJKf4lk4CX4N /Hssck7TbRhTAsUBW5dxU1KVtNRkIs6ROvLQPPPQIk2JHhza1iFF5AUC5rLCTDFR67ZP WmZJfOtfB5S4aq5PLDo4okq0WwLEm5ZSewu5VrYLuXniLTvsrAGSX+xS2ODVeZoi4mOK mGnBbItnP9dh/Fw/hZPl1bzQdk/WeI2ZILcKHZ6ok4OeDZwjQWQMWAcmOPVQZ8Tv8gNN y/0A== X-Gm-Message-State: AOAM532ir8Mq+PZl5vPMNcDJPvc1oH2D4S4imGqs9BoucgiIBo/wke2a CuAh9yMoP2BJiVY12Qsi9mlGIoZrGs8Q21yOsNMt9Vgxehxf4dBGgyr/qRh+XK4lHC4mt5pHxNQ P484lniATY8IWT2qcnu51py8uHggD5dFv+eyZwjhh2V2RrN7lzxIycMwrZ/p9CkNc0Q== X-Google-Smtp-Source: ABdhPJxlB/PNbh8aJNiCFG1cJQtfojaE9v5M1dN6fId9GWh3qdEDiLkdlRUIvbfefx63iyo2Xxsj2f86L9Er X-Received: from maskray1.svl.corp.google.com ([2620:15c:2ce:200:54f5:789a:e4e8:6740]) (user=maskray job=sendgmr) by 2002:a81:1dd2:0:b0:30f:a4fc:315e with SMTP id d201-20020a811dd2000000b0030fa4fc315emr3492467ywd.383.1654144038774; Wed, 01 Jun 2022 21:27:18 -0700 (PDT) Date: Wed, 1 Jun 2022 21:27:15 -0700 Message-Id: <20220602042715.2999013-1-maskray@google.com> Mime-Version: 1.0 Subject: [PATCH] arm: Define elf_backend_extern_protected_data to 0 From: Fangrui Song To: binutils@sourceware.org, Szabolcs Nagy Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-19.7 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_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: Thu, 02 Jun 2022 04:27:22 -0000 From: Fangrui Song 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 b68a20d6675f1360ea4db50a9835c073675b9889 changed ld to produce R_ARM_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/elf32-arm.c | 2 +- ld/testsuite/ld-arm/protected-data.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 5b8f5e5a0e6..36f09cb3427 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -20315,7 +20315,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym) #define elf_backend_dtrel_excludes_plt 1 #define elf_backend_got_header_size 12 -#define elf_backend_extern_protected_data 1 +#define elf_backend_extern_protected_data 0 #undef elf_backend_obj_attrs_vendor #define elf_backend_obj_attrs_vendor "aeabi" diff --git a/ld/testsuite/ld-arm/protected-data.d b/ld/testsuite/ld-arm/protected-data.d index 3f266dea1b4..7dffe9ab958 100644 --- a/ld/testsuite/ld-arm/protected-data.d +++ b/ld/testsuite/ld-arm/protected-data.d @@ -2,4 +2,4 @@ #ld: -shared #readelf: -r -W #... -.* R_ARM_GLOB_DAT .* var.* +.* R_ARM_RELATIVE .* -- 2.36.1.255.ge46751e96f-goog