From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id 1A30F3AAA0BE for ; Thu, 4 Feb 2021 08:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1A30F3AAA0BE IronPort-SDR: HXfT6zHbsw/YtV24gF4EPOkXmZD1xyiyz6YyprJc0gbRXFqrxUAD61eFZt8DF55e4PdWuKa3AA jANI6Kx5L6ng== X-IronPort-AV: E=McAfee;i="6000,8403,9884"; a="177688491" X-IronPort-AV: E=Sophos;i="5.79,400,1602572400"; d="scan'208";a="177688491" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2021 00:11:02 -0800 IronPort-SDR: wQKC7btZC+vh55NTCsJumqZiQVEyvA5KhOPXPP1cvkfejmYZIWAT0aPG5YUAj4MZ7+y4lADuKA FWiqDnHHcqjA== X-IronPort-AV: E=Sophos;i="5.79,400,1602572400"; d="scan'208";a="433825478" Received: from labpc2407.iul.intel.com (HELO localhost) ([172.28.50.61]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2021 00:11:01 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 1/8] testsuite: extend nopie handling to add -fno-pie to compiler flags Date: Thu, 4 Feb 2021 09:10:28 +0100 Message-Id: <20210204081037.3712162-3-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210204081037.3712162-1-markus.t.metzger@intel.com> References: <20210204081037.3712162-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Feb 2021 08:11:05 -0000 Some older GCC, e.g. 7.5.0 on Ubuntu 18.04 need -fno-pie to be passed to the compiler in addition to -no-pie to be passed to the linker for non-pie code generation. The gdb,nopie_flag is already documented as getting passed to the compiler, not the linker. Use that for the new -fno-pie compiler flag and add a new gdb,nopie_ldflag for the existing -no-pie linker flag. gdb/testsuite/ChangeLog: 2020-12-21 Markus Metzger * README: Add nopie_ldflag * lib/gdb.exp: Extend nopie handling. --- gdb/testsuite/README | 5 +++++ gdb/testsuite/lib/gdb.exp | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/README b/gdb/testsuite/README index f3c2642db37..0036753eff0 100644 --- a/gdb/testsuite/README +++ b/gdb/testsuite/README @@ -528,6 +528,11 @@ gdb,nopie_flag The flag required to force the compiler to produce non-position-independent executables. +gdb,nopie_ldflag + + The flag required to force the linker to produce non-position-independent + executables. + gdb,debug When set gdb debug is sent to the file gdb.debug in the test output diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c38c7c37e98..62d85b44c29 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4221,16 +4221,23 @@ proc gdb_compile {source dest type options} { lappend options "$flag" } - # Replace the "nopie" option with the appropriate linker flag to disable - # PIE executables. There are no compiler flags for this option. + # Replace the "nopie" option with the appropriate compiler and linker + # flags to disable PIE executables. set nopie [lsearch -exact $options nopie] if {$nopie != -1} { if [target_info exists gdb,nopie_flag] { - set flag "ldflags=[target_info gdb,nopie_flag]" + set flag "additional_flags=[target_info gdb,nopie_flag]" } else { - set flag "ldflags=-no-pie" + set flag "additional_flags=-fno-pie" } set options [lreplace $options $nopie $nopie $flag] + + if [target_info exists gdb,nopie_ldflag] { + set flag "ldflags=[target_info gdb,nopie_ldflag]" + } else { + set flag "ldflags=-no-pie" + } + lappend options "$flag" } if { $type == "executable" } { -- 2.26.2 Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928