Message ID | 20221128135914.4068410-1-joakim@nohlgard.se |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5685684wrr; Mon, 28 Nov 2022 06:00:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6WSYsWJ1IXCWUGSgHqOMAhEUgyzN97vqWATJjLDwNmkcuoW4rpypmASl98oKjWp3T0ow6C X-Received: by 2002:a05:6402:509:b0:466:7500:b5df with SMTP id m9-20020a056402050900b004667500b5dfmr47433512edv.48.1669644043364; Mon, 28 Nov 2022 06:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669644043; cv=none; d=google.com; s=arc-20160816; b=0H/bhnYolrtwLMVj7inYBLYemtObwJIs7uYv8WgIwlUjm1CdjNv0a5PCz0pbO9qTrZ mLa0lUZZLgceJBYs9HVH0nKf7d5V1G9SPJr+0CCeTDKmPozKT2Zk8BNOMBZSrvjD0vJi zIucv0ygJV0hbuleC0DoW9O/BliszmKtF2Mm1Ox5Un+Pobjtpwc+rjPd2SlHibUrkjLZ 2m4OYjmEcEfsfRgMtjozNzFbSiOJGP+7X5C625kI9XHgpe4Nx0szPhljuSZmAvyeZlJP 1YA6eILSt2Fzd8VpGviNfOIYdfHasunAsD7xNGgJP8GtFNAdzV/+Q9pL1VnauCMij1xs y/AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=N5c56scJyivTWZQioTGYd9lus2mTM+CQcu0BfBaeLfg=; b=rwLO4OZIhJBiXWuHQ+sc8+bIRXHH5k9OeyXvGv8BOAlnmxPdbMexYqwIVdKNpKWJ1A hVFTGuMC1EF7aZm4kLxmmMsCt6oA1TPFhuIdyGI4u2yABYITmj9frTJAbYszunxBZDgk c9z6zzoarsahwdFxd1x18w6TcmjBi0/RRWRhhbsVBl12OmyaTj8J4bj2OsvaBeNt69mK yqh7gXGd3sj7UN5h2lJ0PQglOpPqWHdNecaY33e3sg0vYTlRbm7R160VpHMKecUm899k hA8F+qW0S/mdEDIdOFoLwPfJmbHv4IcZtH5fErCLYqXyeQx4nUsmu9b7tEGdi7pR5HCh jkgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nohlgard.se header.s=google header.b=c+DAbcLS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hg4-20020a1709072cc400b007b790c183c1si10620437ejc.455.2022.11.28.06.00.43 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 06:00:43 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@nohlgard.se header.s=google header.b=c+DAbcLS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 727DD384EF64 for <ouuuleilei@gmail.com>; Mon, 28 Nov 2022 14:00:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 6D8F3385B519 for <gcc-patches@gcc.gnu.org>; Mon, 28 Nov 2022 14:00:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D8F3385B519 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nohlgard.se Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nohlgard.se Received: by mail-lj1-x234.google.com with SMTP id j2so10709960ljg.10 for <gcc-patches@gcc.gnu.org>; Mon, 28 Nov 2022 06:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nohlgard.se; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=N5c56scJyivTWZQioTGYd9lus2mTM+CQcu0BfBaeLfg=; b=c+DAbcLS1p4vbAVOw1tR3xejJa9wALU6FE4WepY/0FT0g4CSjWm80Rdd7syN/y+UEm l2gRMS4I2e4d09YjWwD8gSaa9FJTBRXiDrL8djWZVAeMgeFEl+t8HnqkKuMRnSnVEICa PzD0o7FQHHD6VW+C01ojxCBpmKuHnpvFWEGHB5lJ5kqdjhw1ntEJnywBOb4Uch9WRqqt BHjxADyoVEi/ImfmvcR0hqDoTEptKhxLqLWQFdr0rJh6lH9opiEd6rGE5E4VxihG2jLc F2YQNZTt0tjWsPUZ1GcQ0dUxLfLgC6+1O0My+kYdmFCGv4AaHFPt1N9/dqDVhK9EVDxq el5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=N5c56scJyivTWZQioTGYd9lus2mTM+CQcu0BfBaeLfg=; b=koRI4NW6SX8gbdv+1zqBzdB2AayB0w0v3zb9HJ1h66I3gNp5PMB5ZgEZKZviaS1v52 xNJo1evHAblGGWhYjU2JnzTPgyFmv4huBiiYrKJLjd+3AlUgHjGi1Ny7hy95tTqdh43S q32ctOa6Uo9SjR8MEnE5urGRkaGooABK0CCgjSBSL96Yn/EWk+znBdY48ttvIPG+GhUM CK6L5VHNPW8rNJji2sKFoF4gVSTzALvypz4vFR++sTR0bVtoK5CyyAAlrfu61B8b0DuT BEwuKqRTaKV1s+hQy8ogJc59layTX4YuIUHvOP+fQcnjFNHB9eLdCykpM/N82NlAjPmI zOiQ== X-Gm-Message-State: ANoB5pkK5wAe+O3Tz7yXZUUWr2gqgKNPDDXHGPqMvrCKtREI0iJCJ4eZ J5MwTJG2GuYYWhz1KxABiz/FRqcIRezL6w== X-Received: by 2002:a05:651c:2391:b0:277:3b2:864b with SMTP id bk17-20020a05651c239100b0027703b2864bmr16864347ljb.298.1669644008530; Mon, 28 Nov 2022 06:00:08 -0800 (PST) Received: from cppdev.jnohlgard-laptop (81-26-241-118.customers.ownit.se. [81.26.241.118]) by smtp.gmail.com with ESMTPSA id r7-20020ac24d07000000b0049aa20af00fsm1731339lfi.21.2022.11.28.06.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 06:00:08 -0800 (PST) From: =?utf-8?q?Joakim_Nohlg=C3=A5rd?= <joakim@nohlgard.se> To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Joakim_Nohlg=C3=A5rd?= <joakim@nohlgard.se> Subject: [PATCH] gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING Date: Mon, 28 Nov 2022 14:59:14 +0100 Message-Id: <20221128135914.4068410-1-joakim@nohlgard.se> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750748672460672240?= X-GMAIL-MSGID: =?utf-8?q?1750748672460672240?= |
Series |
gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Joakim Nohlgård
Nov. 28, 2022, 1:59 p.m. UTC
The check for HAVE_LD_RO_RW_SECTION_MIXING fails on targets where ld
does not support shared objects, even though the answer to the test
should be 'read-write'. One such target is riscv64-unknown-elf. Failing
this test results in a libgcc crtbegin.o which has a writable .eh_frame
section leading to the default linker scripts placing the .eh_frame
section in a writable memory segment, or a linker warning about writable
sections in a read-only segment when using ld scripts that place
.eh_frame unconditionally in ROM.
gcc/ChangeLog:
* configure: Regenerate.
* configure.ac: Use ld -r in the check for HAVE_LD_RO_RW_SECTION_MIXING
Signed-off-by: Joakim Nohlgård <joakim@nohlgard.se>
---
gcc/configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 11/28/22 06:59, Joakim Nohlgård wrote: > The check for HAVE_LD_RO_RW_SECTION_MIXING fails on targets where ld > does not support shared objects, even though the answer to the test > should be 'read-write'. One such target is riscv64-unknown-elf. Failing > this test results in a libgcc crtbegin.o which has a writable .eh_frame > section leading to the default linker scripts placing the .eh_frame > section in a writable memory segment, or a linker warning about writable > sections in a read-only segment when using ld scripts that place > .eh_frame unconditionally in ROM. > > gcc/ChangeLog: > > * configure: Regenerate. > * configure.ac: Use ld -r in the check for HAVE_LD_RO_RW_SECTION_MIXING I'm not sure that simply replacing -shared with -r is the right fix here. ISTM that if the -shared tests fails, then we can/should try the -r variant. Am I missing something here? jeff
On Mon, Nov 28, 2022 at 5:53 PM Jeff Law <jeffreyalaw@gmail.com> wrote: > > > On 11/28/22 06:59, Joakim Nohlgård wrote: > > The check for HAVE_LD_RO_RW_SECTION_MIXING fails on targets where ld > > does not support shared objects, even though the answer to the test > > should be 'read-write'. One such target is riscv64-unknown-elf. Failing > > this test results in a libgcc crtbegin.o which has a writable .eh_frame > > section leading to the default linker scripts placing the .eh_frame > > section in a writable memory segment, or a linker warning about writable > > sections in a read-only segment when using ld scripts that place > > .eh_frame unconditionally in ROM. > > > > gcc/ChangeLog: > > > > * configure: Regenerate. > > * configure.ac: Use ld -r in the check for HAVE_LD_RO_RW_SECTION_MIXING > > I'm not sure that simply replacing -shared with -r is the right fix > here. ISTM that if the -shared tests fails, then we can/should try the > -r variant. Am I missing something here? > I have posted a v2 patch. The new patch tries ld -shared first and falling back to ld -r if that fails. I believe the original reason for using ld -shared in the first place was that it was a convenient way to let the conftest1,2,3 code be as simple as possible. Using ld without any flags would require a program entry point (_start) at the very minimum. Using ld -r has the same effect as the ld -shared link in this case, where we just want to merge sections with the same name from different input files and check what section flags were propagated to the output file.
diff --git a/gcc/configure.ac b/gcc/configure.ac index 7c55bff6cb0..4f36ed4aff3 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3153,9 +3153,9 @@ elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \ && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \ && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1 \ - && $gcc_cv_ld -shared -o conftest1.so conftest1.o \ + && $gcc_cv_ld -r -o conftest.o conftest1.o \ conftest2.o conftest3.o > /dev/null 2>&1; then - gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \ + gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest.o \ | sed -e '/myfoosect/!d' -e N` if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then