Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mV61C-0002Dz-Tj for mharc-grub-devel@gnu.org; Tue, 28 Sep 2021 01:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV618-0002B6-My for grub-devel@gnu.org; Tue, 28 Sep 2021 01:51:02 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.109.102]:49866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV613-0003Qn-Jt for grub-devel@gnu.org; Tue, 28 Sep 2021 01:51:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632808255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DLV4Osa8yFvuGYOMBSuas3WKF+pkGaXo60PPKn/VeHg=; b=GlZddByvBFaMM9y1gxhbxq4G8ShP3g2p15SqEZf52fCNF7cO0F+FUS606qXjf2EcZSKMr6 4qXvfVwO7l0hVHpDDOd3AiIgwjnBMzT+MywVhyoMiwWt/zRBW/aVf3PbGreyfBbmIZf2wq K/g80NjzvDQRIOxNkwps/4s1KjaDYXA= Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-27-Pap_BTsQOq-zoM0eB6LCSQ-1; Tue, 28 Sep 2021 07:50:54 +0200 X-MC-Unique: Pap_BTsQOq-zoM0eB6LCSQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OCKKJB3OTUN8zZHgXj1um01dJ7x+DS2lsV6PUuVkESAst8oUs/WOI+jjaWzSrQmyIEX8LDZ8T//xDu6OTj23deDPp0QoZ+sntFc2NnskE61U4gavFjJrmpgYb/kx6jspTwOJxbkI5kiuvoZNS2sXW7gHSHKbQ8e8g4nhEnQd1uVwLBJtg+q0Jjg1bCxJmfaVejpi/XdL6axWH98NATC/24LQBRX9Ht1Mfq7MlPW1s5/jxfmU+ofdjstMZMivtDO5gcfo3OfcHEvox0ysWw2nOpZAACHhvztoJjSjXuRjs57AKM1h8ULa5tTAifAIdCwvj19ev63R2u7l3ZslFC3JEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TAG6anz2LRBUCWCwielAz1uMjMhVwITFETEjuBFMh34=; b=QK4nWQ6wmheU8TqqJOPTu8TvQIir5KbbSD+F5b+7Sx6T/tXa0lB9a1aNP6D3+CTyppsoqBCMFhYKKuaFuzQVAAtXg8bekrYEEakUg57oksQEqx6TbT911JHTj6f+svA8W6hnSgYrty+vna7NKIGAbX4E0A2tIzC0YdxR30fAG0X2q9Ui1UlPaHUYLvlcWu/z+XlKi1qD1xgCgmOsnT53PjoT7D33aHsFRYzYBN2wAt917J1eC8acZmI8/Sd4wS5anAF0CkSyyXovclN+7CprnBPt9swyi/gZly8Kg07fnESrAf4k2b7jwmVCgYTkQw0uNouk1u4KAvYkk/I/FShvnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: gnu.org; dkim=none (message not signed) header.d=none;gnu.org; dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB8648.eurprd04.prod.outlook.com (2603:10a6:10:2df::21) by DU2PR04MB8856.eurprd04.prod.outlook.com (2603:10a6:10:2e3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Tue, 28 Sep 2021 05:50:52 +0000 Received: from DU2PR04MB8648.eurprd04.prod.outlook.com ([fe80::7c78:3729:f82b:6802]) by DU2PR04MB8648.eurprd04.prod.outlook.com ([fe80::7c78:3729:f82b:6802%8]) with mapi id 15.20.4544.022; Tue, 28 Sep 2021 05:50:52 +0000 From: Michael Chang To: The development of GNU GRUB Subject: [PATCH v3] Fix build error in binutils 2.36 Date: Tue, 28 Sep 2021 13:50:47 +0800 Message-ID: <20210928055047.27144-1-mchang@suse.com> X-Mailer: git-send-email 2.31.1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-ClientProxiedBy: HKAPR03CA0026.apcprd03.prod.outlook.com (2603:1096:203:c9::13) To DU2PR04MB8648.eurprd04.prod.outlook.com (2603:10a6:10:2df::21) MIME-Version: 1.0 Received: from localhost (2001:b011:30d0:199c:6600:6aff:fe77:a7be) by HKAPR03CA0026.apcprd03.prod.outlook.com (2603:1096:203:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.9 via Frontend Transport; Tue, 28 Sep 2021 05:50:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ac84405-8c52-4b6c-5f23-08d98243ee7a X-MS-TrafficTypeDiagnostic: DU2PR04MB8856: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dpTL+z832goCGY7AmgcFLYdFjVdzPwm8C54+O0OGReOPvhS4eJLJBSXP4uRf3N88wAkuwAqWEPRa+aCSWFYSKDVA+Qsod1xqFgUC/Nx0aU1eJ7tDSrCln9GMLlIItKI+VvSI/DwZ508EFQu7Dv//cKDduwjWb40ZGDsIoeeY32dzJtGx3ioE7kZEp7mhIhlodummZX+tc0Wy1QjjTxgkdUVCNVB/8n6fW78VyDmQ8VhDwQ1SDEfxed5WDGbQXqmBKt3PfaPSRKGPl4pwxYCUvSpTnxBa8KyVfFv0panjMVA26mKg3/snDrNumw3fl+m9nekTnxrmUExuABeL50ueeGIgqFZGl/vpAtrPMgt6Q94AFcmFDIVuJV6GDPN+RHvJbSJ3V/6rH5mB5w71za7GlNZOyLUqnGQeTfj/qtLhttQMtjgKtwGUf/00GHe7YU+XL+jm2lInZMX9X4YDvRY+qwMJyslx0QGXyH13U+KPtExvpPSlr9x6cUuh8xVHIxf7K3Oy4udGx0qCvEqI0fORcRRRSLmES0MDWe6Xn1UwndryEVfM918gipVY2Jtzn8aRgCgJ/E7cGb2WrjXJq8BLuRyUt4HA2UuXcwsZKj/l5kP9dwELMXPUfO/5dKs5FkTWF40vxlzv7YP+ZXJVBDaNyxQXhaq9rHovnojiHL13Htwq3z82TRuE0QJwJHmsO0cXSql4pVTsaXgE4uFQlgsSY1cB00QdKCVT6m7SYDJvC5WbNVUa724Wda225Lq/Awv3/hBuBqPK13G+qOuHhICR+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8648.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(2616005)(36756003)(8936002)(6916009)(966005)(6666004)(83380400001)(2906002)(316002)(66946007)(86362001)(6496006)(8676002)(66556008)(5660300002)(186003)(508600001)(66476007)(38100700002)(6486002)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rJQAzKGdVrm3SLJ34JgnZ8pXatHO8vOA0hLa1euZpbrpCxYkS9cN0bDC9S/R?= =?us-ascii?Q?/lz5S8byTHksBdMxBbgzdgnzuh97AE7rSyqbNNRrky6uP69hy1UrbsFL17h2?= =?us-ascii?Q?0SyjOfLqw3LqR/GebrUmbHptaOj6qXs397rrLazpvKFzy/oIzKrojOS2WC9P?= =?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zAM56yogZcVT9dsDCW2C1gV/v64X?= =?us-ascii?Q?37OT5I21tJq+YezZh0loI3SBsS7O6QfMOk9QbuCJbTp8L/yt8s2xgQb28Jm/?= =?us-ascii?Q?7Izn7zUa39y/uqEDX1YVQUgbF9xL1HRdHXn1rz4HkGRfmh9WlrNLN3P6LH8R?= =?us-ascii?Q?28BGCWNnDLQ5QBPgzKnfCRI+B6SrF/zDNaT+zSTXBXcXjPaK8aTGxXI9CzMw?= =?us-ascii?Q?HcOt3ePQsxsDhTuZqCmh+5c+Fa3OZ76XkzqrLf7PQ2kZFMWCGH3MEwEvn7JJ?= =?us-ascii?Q?PjNV8ZyJCjzmm+ow9omlrKTnc/RCEBqQDbwmWEQ14+yT5LHucJ0BwFwGilHm?= =?us-ascii?Q?I2D+trWtE/4qmRgEAhnVyHvRLqhh?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ac84405-8c52-4b6c-5f23-08d98243ee7a X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8648.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2021 05:50:52.5948 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qfRZIMifSg8m7lg6ZF+DW+0zHUoqzrQ0UPXAmqDgqmPFUZVaYx3K2zGSGei+SAZx X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8856 Received-SPF: pass client-ip=194.104.109.102; envelope-from=mchang@suse.com; helo=de-smtp-delivery-102.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2021 05:51:02 -0000 The following procedure to build xen/pvgrub is broken. git clone https://git.savannah.gnu.org/git/grub.git cd grub ./bootstrap mkdir build-xen cd build-xen ../configure --with-platform=3Dxen make It fails with the message: /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: section .note.gnu.property VMA [0000000000400158,0000000000400187] overlaps section .bss VMA [000000000000f000,000000000041e1af] The most significant factor is that new assembler (gnu as) generates the .note.gnu.property section as default. This note section overlaps with .bss because it doesn't reposition with -Wl,-Ttext,0 with which the base address of .text section is set, rather the address of .note.gnu.property is calculated for some reason from 0x400000 where the elf executable defaults to start. Using -Ttext-segment doesn't help either, though it is said to set the address of the first byte of the text segment according to "man ld". What it actually does is to override the default 0x400000, aka the image base address, to something else. The entire process can be observed in the default linker script used by gcc [1]. Therefore we can't expect it to achieve the same thing as -Ttext given that the first segment where .text resides is offset by SIZEOF_HEADERS plus some sections may be preceding it within the first segment. The end result is .text always has to start with non-zero address with -Wl,-Ttext-segment,0 if using default linker script. It is also worth mentioning that binutils upstream apparently doesn't seem to consider this as a bug [2] and proposed to use -Wl,-Ttext-segment,0 which's not fruitful as what has been tested by gentoo [3]. As long as grub didn't use ISA information encoded in .note.gnu.property, we can safely drop it via -Wa,-mx86-used-note=3Dno assembler option to fix the linker error above. This is considered a better approach than using custom linker script to drop the .note.gnu.property section because object file manipulation can also be hampered one way or the other in that linker script may not be helpful. See also this commit removing the section in the process of objcopy. 6643507ce build: Fix GRUB i386-pc build with Ubuntu gcc [1] In /usr/lib64/ldscripts/elf_x86_64.x or use 'gcc -Wl,--verbose ...' PROVIDE (__executable_start =3D SEGMENT_START("text-segment", 0x400000)); . =3D SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS; [2] Ref: https://sourceware.org/bugzilla/show_bug.cgi?id=3D27377 [3] Ref: https://bugs.gentoo.org/787221 Signed-off-by: Michael Chang --- configure.ac | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configure.ac b/configure.ac index eeb5d2211..8d1c81a73 100644 --- a/configure.ac +++ b/configure.ac @@ -840,6 +840,20 @@ if ( test "x$target_cpu" =3D xi386 || test "x$target_c= pu" =3D xx86_64 ) && test "x$p TARGET_CFLAGS=3D"$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -m= no-3dnow" fi =20 +if ( test "x$target_cpu" =3D xi386 || test "x$target_cpu" =3D xx86_64 ); t= hen + AC_CACHE_CHECK([whether -Wa,-mx86-used-note works], [grub_cv_cc_mx86_use= d_note], [ + CFLAGS=3D"$TARGET_CFLAGS -Wa,-mx86-used-note=3Dno -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_mx86_used_note=3Dyes], + [grub_cv_cc_mx86_used_note=3Dno]) + ]) + + if test "x$grub_cv_cc_mx86_used_note" =3D xyes; then + TARGET_CFLAGS=3D"$TARGET_CFLAGS -Wa,-mx86-used-note=3Dno" + TARGET_CCASFLAGS=3D"$TARGET_CCASFLAGS -Wa,-mx86-used-note=3Dno" + fi +fi + # GRUB doesn't use float or doubles at all. Yet some toolchains may decide # that floats are a good fit to run instead of what's written in the code. # Given that floating point unit is disabled (if present to begin with) --=20 2.31.1