From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 4CDCD38582A7 for ; Fri, 24 Jun 2022 10:42:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CDCD38582A7 Received: by mail-wm1-x32a.google.com with SMTP id p6-20020a05600c1d8600b003a035657950so1280873wms.4 for ; Fri, 24 Jun 2022 03:42:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:message-id:subject:mime-version :list-id; bh=M5UVLe+/I+srYFDvDKB0UuqJA2BU+OEagSzMQdpYpis=; b=UrhhZbej+YzIy7KTN/Urglb/NJ9SSBCKKQL3PrBWB3TxZlujsdvXkomgqzGCJY1xpg bky2sl+L87NSoa0mO2XOuj+w57bbPtB5mToJBQDCulsKN5/L/VVJftV98jU5ojL6MQPK QIGiDkALyIqjAZT5v6BlYAPCjGGG3VBsnTViSDanr3IzNto5/q8ytBsJ/nmp6npJdJgI vy9KWuA+aAWv0OERNaHBp1/sW6/qDKGzqjPBZl0n3y04as9VCeAsAnzVlWEK3QAyzJ9A 6MBOwod521kbHpXEXCrzOphxGgX8zU09ads4naVPTJXD2N//S/u3nl/qGubebUjgSx8U Hi3A== X-Gm-Message-State: AJIora9A7bhEcczeQW3BNRAVOtQ195no19wj/hgmMqDAEFZjhnTVPsuh 8BSDGbv4KFIQjs1zXgPYEnLALw== X-Google-Smtp-Source: AGRyM1veUguOgNI0Tn4lnXcZy6AleCdH+6ur9PutWZfyXmkmw46UtAGzlWuH/Dg+hLWnyVl7FTvZxw== X-Received: by 2002:a7b:c389:0:b0:39c:49fe:25d3 with SMTP id s9-20020a7bc389000000b0039c49fe25d3mr3030901wmj.83.1656067333899; Fri, 24 Jun 2022 03:42:13 -0700 (PDT) Received: from jenkins.jenkins (ci.linaro.org. [88.99.136.175]) by smtp.gmail.com with ESMTPSA id s2-20020adfea82000000b0021b90d7b2c9sm1985230wrm.24.2022.06.24.03.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 03:42:13 -0700 (PDT) From: ci_notify@linaro.org X-Google-Original-From: linaro-infrastructure-errors@lists.linaro.org Date: Fri, 24 Jun 2022 10:42:11 +0000 (UTC) To: Fangrui Song Cc: gcc-regression@gcc.gnu.org Message-ID: <1362770665.5392.1656067333233@jenkins.jenkins> Subject: [TCWG CI] Regression caused by binutils: aarch64: Disallow copy relocations on protected data MIME-Version: 1.0 X-Jenkins-Job: TCWG Bisect tcwg_gcc_bootstrap/master-aarch64-bootstrap_lto X-Jenkins-Result: SUCCESS X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-regression@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-regression mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 10:42:17 -0000 [TCWG CI] Regression caused by binutils: aarch64: Disallow copy relocations on protected data: commit 90b7a5df152a64d2bea20beb438e8b81049a5c30 Author: Fangrui Song aarch64: Disallow copy relocations on protected data Results regressed to # reset_artifacts: -10 # true: 0 # build_abe binutils: 1 # First few build errors in logs: # 00:04:27 make[3]: [Makefile:1786: aarch64-unknown-linux-gnu/bits/largefile-config.h] Error 1 (ignored) # 00:04:27 make[3]: [Makefile:1787: aarch64-unknown-linux-gnu/bits/largefile-config.h] Error 1 (ignored) # 00:09:43 collect2: error: ld returned 1 exit status # 00:09:43 make[3]: *** [Makefile:3023: build/genenums] Error 1 # 00:09:44 collect2: error: ld returned 1 exit status # 00:09:44 make[3]: *** [Makefile:3023: build/genmddeps] Error 1 # 00:09:50 make[2]: *** [Makefile:5005: all-stage2-gcc] Error 2 # 00:09:50 make[1]: *** [Makefile:25739: stage2-bubble] Error 2 # 00:09:50 make: *** [Makefile:1072: all] Error 2 from # reset_artifacts: -10 # true: 0 # build_abe binutils: 1 # build_abe bootstrap_lto: 2 THIS IS THE END OF INTERESTING STUFF. BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT. This commit has regressed these CI configurations: - tcwg_gcc_bootstrap/master-aarch64-bootstrap_lto First_bad build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/build-90b7a5df152a64d2bea20beb438e8b81049a5c30/ Last_good build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/build-f18acc9c4e5d18f4783f3a7d59e3ec95d7af0199/ Baseline build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/build-baseline/ Even more details: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/ Reproduce builds: mkdir investigate-binutils-90b7a5df152a64d2bea20beb438e8b81049a5c30 cd investigate-binutils-90b7a5df152a64d2bea20beb438e8b81049a5c30 # Fetch scripts git clone https://git.linaro.org/toolchain/jenkins-scripts # Fetch manifests and test.sh script mkdir -p artifacts/manifests curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/manifests/build-baseline.sh --fail curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/manifests/build-parameters.sh --fail curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-aarch64-bootstrap_lto/7/artifact/artifacts/test.sh --fail chmod +x artifacts/test.sh # Reproduce the baseline build (build all pre-requisites) ./jenkins-scripts/tcwg_gnu-build.sh @@ artifacts/manifests/build-baseline.sh # Save baseline build state (which is then restored in artifacts/test.sh) mkdir -p ./bisect rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /binutils/ ./ ./bisect/baseline/ cd binutils # Reproduce first_bad build git checkout --detach 90b7a5df152a64d2bea20beb438e8b81049a5c30 ../artifacts/test.sh # Reproduce last_good build git checkout --detach f18acc9c4e5d18f4783f3a7d59e3ec95d7af0199 ../artifacts/test.sh cd .. Full commit (up to 1000 lines): commit 90b7a5df152a64d2bea20beb438e8b81049a5c30 Author: Fangrui Song Date: Wed Jun 22 10:55:12 2022 -0700 aarch64: Disallow copy relocations on protected data If an executable has copy relocations for extern protected data, that can only work if the shared object 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 shared object uses its own definition directly and the executable accesses a stale copy. Note: the GOT relocations defeat the purpose of protected visibility as an optimization, and it turns out this never worked perfectly. glibc 2.36 will warn on copy relocations on protected data. Let's produce a warning at link time, matching ld.lld which has been used on many aarch64 OSes. Note: x86 requires GNU_PROPERTY_NO_COPY_ON_PROTECTED to have the error. This is to largely due to GCC 5's "x86-64: Optimize access to globals in PIE with copy reloc" which started to use direct access relocations for external data symbols in -fpie mode. GCC's aarch64 port does not have the change. Nowadays with most builds switching to -fpie/-fpic, aarch64 mostly doesn't need to worry about copy relocations. So for aarch64 we simply don't check GNU_PROPERTY_NO_COPY_ON_PROTECTED. --- bfd/elfnn-aarch64.c | 28 +++++++++++++++++++++++++- ld/testsuite/ld-aarch64/aarch64-elf.exp | 9 +++++++++ ld/testsuite/ld-aarch64/copy-reloc-protected.d | 2 ++ ld/testsuite/ld-aarch64/protected.s | 8 ++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index ca24a6b5678..81311fc5a32 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -2579,6 +2579,9 @@ struct elf_aarch64_link_hash_entry this symbol. */ unsigned int got_type; + /* TRUE if symbol is defined as a protected symbol. */ + unsigned int def_protected : 1; + /* A pointer to the most recently used stub hash entry against this symbol. */ struct elf_aarch64_stub_hash_entry *stub_cache; @@ -2855,9 +2858,16 @@ elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info, static void elfNN_aarch64_merge_symbol_attribute (struct elf_link_hash_entry *h, unsigned int st_other, - bool definition ATTRIBUTE_UNUSED, + bool definition, bool dynamic ATTRIBUTE_UNUSED) { + if (definition) + { + struct elf_aarch64_link_hash_entry *eh + = (struct elf_aarch64_link_hash_entry *)h; + eh->def_protected = ELF_ST_VISIBILITY (st_other) == STV_PROTECTED; + } + unsigned int isym_sto = st_other & ~ELF_ST_VISIBILITY (-1); unsigned int h_sto = h->other & ~ELF_ST_VISIBILITY (-1); @@ -8701,6 +8711,22 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (h->dyn_relocs == NULL) return true; + for (p = h->dyn_relocs; p != NULL; p = p->next) + if (eh->def_protected) + { + /* Disallow copy relocations against protected symbol. */ + asection *s = p->sec->output_section; + if (s != NULL && (s->flags & SEC_READONLY) != 0) + { + info->callbacks->einfo + /* xgettext:c-format */ + (_ ("%F%P: %pB: copy relocation against non-copyable " + "protected symbol `%s'\n"), + p->sec->owner, h->root.root.string); + return false; + } + } + /* In the shared -Bsymbolic case, discard space allocated for dynamic pc-relative relocs against symbols which turn out to be defined in regular objects. For the normal shared case, discard diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 64476f111e0..31162277bd9 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -407,6 +407,8 @@ set aarch64elflinktests { {copy-reloc-exe-2.s} {{objdump -R copy-reloc-2.d}} "copy-reloc-2"} {"ld-aarch64/exe with copy relocation elimination" "-e0 tmpdir/copy-reloc-so.so" "" "" {copy-reloc-exe-eliminate.s} {{objdump -R copy-reloc-eliminate.d}} "copy-reloc-elimination"} + {"Build .so with protected data" "-shared" "" "" {protected.s} + {} "protected.so"} {"ld-aarch64/so with global func" "-shared" "" "" {func-in-so.s} {} "func-in-so.so"} {"ld-aarch64/func sym hash opt for exe" @@ -416,8 +418,15 @@ set aarch64elflinktests { {} "libbti-plt-so.so"} } +set aarch64elfcclinktests [list \ + [list "copy relocation on protected data" \ + "-no-pie tmpdir/copy-reloc-exe.o tmpdir/protected.so" "" \ + {} {{error_output copy-reloc-protected.d}} "copy-reloc-protected"] +] + if [check_shared_lib_support] { run_ld_link_tests $aarch64elflinktests + run_cc_link_tests $aarch64elfcclinktests } run_dump_test "bti-plt-3" diff --git a/ld/testsuite/ld-aarch64/copy-reloc-protected.d b/ld/testsuite/ld-aarch64/copy-reloc-protected.d new file mode 100644 index 00000000000..99a356a3df6 --- /dev/null +++ b/ld/testsuite/ld-aarch64/copy-reloc-protected.d @@ -0,0 +1,2 @@ +.*: tmpdir/copy-reloc-exe.o: copy relocation against non-copyable protected symbol `global_a' +#... diff --git a/ld/testsuite/ld-aarch64/protected.s b/ld/testsuite/ld-aarch64/protected.s new file mode 100644 index 00000000000..eb3fb402dc4 --- /dev/null +++ b/ld/testsuite/ld-aarch64/protected.s @@ -0,0 +1,8 @@ +.global global_a +.protected global_a +.type global_a, %object +.size global_a, 4 + +.data +global_a: +.word 0xcafedead >>From hjl@sc.intel.com Fri Jun 24 15:49:01 2022 Return-Path: X-Original-To: gcc-regression@gcc.gnu.org Delivered-To: gcc-regression@gcc.gnu.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id 5DB313870870 for ; Fri, 24 Jun 2022 15:49:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5DB313870870 X-IronPort-AV: E=McAfee;i="6400,9594,10388"; a="278573416" X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="278573416" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 08:48:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="915727316" Received: from scymds02.sc.intel.com ([10.82.73.244]) by fmsmga005.fm.intel.com with ESMTP; 24 Jun 2022 08:48:59 -0700 Received: from gnu-clx-1.sc.intel.com (gnu-clx-1.sc.intel.com [172.25.70.216]) by scymds02.sc.intel.com with ESMTP id 25OFmxrj005122; Fri, 24 Jun 2022 08:48:59 -0700 Received: by gnu-clx-1.sc.intel.com (Postfix, from userid 1000) id 381DB3E001E; Fri, 24 Jun 2022 08:48:59 -0700 (PDT) Date: Fri, 24 Jun 2022 08:48:59 -0700 To: skpgkp2@gmail.com, hjl.tools@gmail.com, gcc-regression@gcc.gnu.org Subject: Regressions on native/master at commit r13-1243 vs commit r13-1227 on Linux/x86_64 User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20220624154859.381DB3E001E@gnu-clx-1.sc.intel.com> From: "H. J. Lu" X-Spam-Status: No, score=-3460.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-regression@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-regression mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 15:49:02 -0000 New failures: FAIL: gcc.dg/torture/pr106070.c -O0 execution test FAIL: gcc.dg/torture/pr106070.c -O0 execution test FAIL: gcc.dg/torture/pr106070.c -O1 execution test FAIL: gcc.dg/torture/pr106070.c -O1 execution test FAIL: gcc.dg/torture/pr106070.c -O2 execution test FAIL: gcc.dg/torture/pr106070.c -O2 execution test FAIL: gcc.dg/torture/pr106070.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/pr106070.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/pr106070.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.dg/torture/pr106070.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.dg/torture/pr106070.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.dg/torture/pr106070.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.dg/torture/pr106070.c -O3 -g execution test FAIL: gcc.dg/torture/pr106070.c -O3 -g execution test FAIL: gcc.dg/torture/pr106070.c -Os execution test FAIL: gcc.dg/torture/pr106070.c -Os execution test New passes: