From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 5C2B138A8154 for ; Mon, 5 Dec 2022 13:46:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C2B138A8154 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-wr1-x430.google.com with SMTP id h12so18603909wrv.10 for ; Mon, 05 Dec 2022 05:46:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nohlgard.se; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fSZCfH19bjRyiLRrIIuwbnIu+URTvf/FTAj4BmR/x28=; b=TlVTGu5P0yx5BSOsijYUPUzc/sIdHkJyVwVU8iIkSGDv5eSdyKb7IEAikyWLl0nuqa WIeIBmm9dWIixWi4HAOCZPD7zIHTYIDLqwLdm1mlmzQMqtckRlPM8fx5rMPmLd7jaiL+ 0BdCGHdjOW11F58SSAaOclq3+2UM314RFNe7CF4J3jBcXZ9qUJpT7dlAOQNSPBp4XIMV sta3ldRZI85ER0s+NiFgrwEq6QjWnC0KSpw326E1h9UqLkImUS2irUXofmDDgTkxVRdY ucd6l13K6KzWSnBhQJaMlREGBhqZyDUQ4+gMEp3F/ShAquP8PkHvCg4lhOP03g3FdHSM 16pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fSZCfH19bjRyiLRrIIuwbnIu+URTvf/FTAj4BmR/x28=; b=oOvlOrvKM6VmmBQxWqGPD7RL+Y4SGk02YRKush3J2/mF+BJb7CFQ8QaAveGaeaBeHe j/tuMci1r+cKOCWOK6lEOPHO0H/EsfsTMpyI4h4MHXPF6b2zvD4s/fQWimr3XkPvNIXz AJUU3Yv0pVlzzusE0j79IxGTom2D6T1aaxTIVFEP4dn6/oURZyfdbbdtIBfBP7oOZ9J/ hssvxIndtL7qiIztH60+45uDIzjHTPEMsFpmul5HxlfJ2lJKxQI9S1xSWaeSIdXKZkNm e0XenBPM/8FClFdRTyCTgab0fSqboby5SYny9ZnJszK5JgmVJwuxF298yX23PaS1pLOO EkTw== X-Gm-Message-State: ANoB5pmLnfBus2hcesRMV5kmm0GFTHQAnVk4tt9Ia8hvQ0iRTEipwg2F s/ZyoKXSiVslhr6nRBTTRUrJ7rjD7zt6D5stP482VExMm003p2eB X-Google-Smtp-Source: AA0mqf5bizlFr00UajAcUx4/EQm0UewCmnc+umbOWCiH5BurmITDgyRwXWvMKRzClhhP0rxpwfOzXdlrdArpwDiL0Mc= X-Received: by 2002:a5d:6a06:0:b0:242:140d:43d5 with SMTP id m6-20020a5d6a06000000b00242140d43d5mr23649405wru.53.1670247979038; Mon, 05 Dec 2022 05:46:19 -0800 (PST) MIME-Version: 1.0 References: <20221128135914.4068410-1-joakim@nohlgard.se> In-Reply-To: From: =?UTF-8?Q?Joakim_Nohlg=C3=A5rd?= Date: Mon, 5 Dec 2022 14:46:07 +0100 Message-ID: Subject: Re: [PATCH] gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING To: Jeff Law Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Nov 28, 2022 at 5:53 PM Jeff Law wrote: > > > On 11/28/22 06:59, Joakim Nohlg=C3=A5rd 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 writabl= e > > 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.