From patchwork Thu Dec 5 21:47:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 1204842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515304-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WxRnZLtL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47TTpw72hGz9sP3 for ; Fri, 6 Dec 2019 08:47:50 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=cpV6hMUSli+AUqEv4JXXPNZTx4xHkx6OQXhHWl3geJ71NAZoHE hI5J93eVVQev6HMRzylmjtiV9dcIOb/KZIWaccr7Z4ahTZGNhi016CZKOOJRA7sF VmwWvWlNh8CB72MaBi/JwlRRV8Tg+F90TUzGbePwBhLyZ7QMqsbq8o0oQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=iMZye2tUYriDxra90NKxluBWqS8=; b=WxRnZLtLKo/UcyKdpPzZ hHp4qOdy577Z1bq/LcAWUdSH6DTpzPpQqy5EPKc/1IvWHfyPQXwapjDg40OCJVjQ JYgMfh56ndKDY9f1dw/jKpJhyJdi2kZ0DR9cgHFcXJrg6rsxztvraj1jU8wrHkaB 42ryhYVvLXPf3yVzr6cEf8o= Received: (qmail 102224 invoked by alias); 5 Dec 2019 21:47:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 102133 invoked by uid 89); 5 Dec 2019 21:47:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT autolearn=ham version=3.3.1 spammy=Systems, Processor, nios X-HELO: esa1.mentor.iphmx.com Received: from esa1.mentor.iphmx.com (HELO esa1.mentor.iphmx.com) (68.232.129.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Dec 2019 21:47:38 +0000 IronPort-SDR: J1EWbVIVy7M4xHxOz/ahZW1Ke3PPephU4QrygbQpR1Q5RA/g4VDuIR274QljHxC4bMNQf0fv1l 2ibjRQEhcCKB+lJFqrJF+Xo7vulL0SUUzk1Y5rrWnsRAfelOeIB0tWQ+aCyDKRvpfSCzZwvicn GC3LIHy3QuGHngDHCnQxblhoaVERlXeD93kbbfUhfFGJ4/YLTxtL8cJ/R01kmrofJNJbec3mN3 p02jCuydWfEaB6ot4E7eUk2E9wkTamld5oyE1RLbl5x2Y/CzfDJwF7AwSH0Ui+PPWm2+W+Glxt j70= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 05 Dec 2019 13:47:36 -0800 IronPort-SDR: N4R58dE57WeCu7zH3NWEw0a24nRivH1DjOl7asZxVcCfHR8flLaB3UzKuFj2RJn8DArGoxZLYe a8omcdgztDRV8ShgpI3wl6oMztv/YTIkjCvzOCfeTyadXJrJ7BOpud5UyVUi7HeV0VmoxwjNpo 7gvLRMUyEU1LbTvd4eD6sYmTiZ3fd9F9VX4HEyFx8TyEFRV7BaM8+d2D2aPXcyY5dIuHnuF3Ba 7kX0m/eqvBvgfc4JHkrwFnUT/liaLCeNrpMz9tgZPnPNTNUTIOoVdi9MfyeLwx4F87w32qp4KK 8zw= To: "gcc-patches@gcc.gnu.org" From: Sandra Loosemore Subject: [nios2, committed] Disable --eh-frame-hdr with -pie or -shared on nios2-linux-gnu Message-ID: Date: Thu, 5 Dec 2019 14:47:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 I've checked in this patch to fix a long-standing bug on nios2-linux-gnu that resulted in linker errors like ../nios2-linux-gnu/bin/ld: FDE encoding in /tmp/cccfpQ2l.o(.eh_frame) prevents .eh_frame_hdr table being created when linking with -pie or -shared. The nios2 ABI doesn't provide the relocations needed for those situations, so we shouldn't be passing --eh-frame-hdr to the linker. I've also checked in a related patch to the linker: it was emitting these diagnostics unconditionally, even when --eh-frame-hdr was not enabled. See https://sourceware.org/ml/binutils/2019-12/msg00013.html -Sandra Index: gcc/config/nios2/linux.h =================================================================== --- gcc/config/nios2/linux.h (revision 279021) +++ gcc/config/nios2/linux.h (working copy) @@ -40,6 +40,12 @@ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \ %{static:-static}}" +/* The nios2 ABI does not have appropriate relocations to support + --eh-frame-hdr with PIE, or in shared libraries. */ +#undef LINK_EH_SPEC +#define LINK_EH_SPEC \ + "%{!pie: %{!shared: %{!static:--eh-frame-hdr}}} " + /* This toolchain implements the ABI for Linux Systems documented in the Nios II Processor Reference Handbook. */ #define TARGET_LINUX_ABI 1 Index: gcc/testsuite/g++.target/nios2/hello-pie.C =================================================================== --- gcc/testsuite/g++.target/nios2/hello-pie.C (nonexistent) +++ gcc/testsuite/g++.target/nios2/hello-pie.C (working copy) @@ -0,0 +1,14 @@ +// { dg-do run { target *-*-linux* } } +// { dg-options "-pie -fpie" } +// { dg-output "Hello, pie World" } + +// This test used to give an "FDE encoding" error from the linker due to +// the ABI not having appropriate relocations for PIE. + +#include + +int +main () +{ + std::cout << "Hello, pie World" << std::endl; +} Index: gcc/testsuite/g++.target/nios2/nios2.exp =================================================================== --- gcc/testsuite/g++.target/nios2/nios2.exp (nonexistent) +++ gcc/testsuite/g++.target/nios2/nios2.exp (working copy) @@ -0,0 +1,34 @@ +# Copyright (C) 2019 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't a nios2 target. +if ![istarget nios2*-*-*] then { + return +} + +# Load support procs. +load_lib g++-dg.exp + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" "" + +# All done. +dg-finish