Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mUn8h-0001SJ-Sq for mharc-grub-devel@gnu.org; Mon, 27 Sep 2021 05:41:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUn8g-0001Q8-DQ for grub-devel@gnu.org; Mon, 27 Sep 2021 05:41:34 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.111.102]:58158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUn8c-000385-2n for grub-devel@gnu.org; Mon, 27 Sep 2021 05:41:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1632735688; 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=g+heA7HlZqGTVh+fNBKDaj2ri0XjweTU5aJo9XIV3Po=; b=le0a88bv0HwNYqggKIDzzy8CnPjDiqZsgM1kBGD3EUK7HJHKsuz0YQkQkJ0bGP6uKPr0Sk d4TkdBFdBOX64EqiJ8SGJ4oBXGh4IoBH6qClC2HTlPNca9fCW4GBjMO7t8ix1UgXjq/H7+ GTI2UJbcw0ov9QLHv4TfGPumYZ/bo/k= Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2109.outbound.protection.outlook.com [104.47.18.109]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-22-8DXHVFIHNUWxCDaoVqY7Tg-1; Mon, 27 Sep 2021 11:41:27 +0200 X-MC-Unique: 8DXHVFIHNUWxCDaoVqY7Tg-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOAy3zWUE7r/OddjuENWjXcxyT5ZRbzUQhYUbOz5/gj18zWMVjWl1eJ+6faSyPgl/6okA7QKSsrYH6seul7SfO2DPdD4d8nYINywq8gJPSzJf5R4RwWi3VxGdDq3f31Efm6YNJ4mldhNDkO+nYIgH9ehU/hxOG6vVyIeRU+COcPKw3Gc2dZkEisw3xWIJrtxrYTizyZCJyavgEUsoertP6x62Q8llYt8yCNHNY9QuicJ9Z3H/aMeuxN/mabuvzmhzNFC1dlzXsDiIYHHMNODzfOiH8rzHMAfUjvITZUQYmv4leyIo4Hk3Jh+VLj0cxs3zebdtABSCM+KA5NvnRZxqw== 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=RqGMZHRxGocK3Lb3FV4Fe3SarenvQp9edkj6+fo6qws=; b=YAJLaEuptlbnJjPHDxxSqI8Cw72xTZt0C3RVwl3v0G5umDfI3eXUJyJi3ln2oIB1BmE7dAqMuzb2FrotMItPT6QgdCProQvH/siAoIq+4dHvb3Xs82/g60yd4ItxndZmaay8bY6/oA13KBUFAc0qaIW/UahEcQDdY2C7DvJbYZie2Bw0x6hGKLTjQrX7rOW1r6nEx8AFU72pTX4DffR8lbuzhTnvMH2WXYWpni35XKaPK1+trZTu8T4u/fuS4j4YyhaG7Yts6oCWuquwlegNbO+cuFtvBvvJln9wlKybVp4LU9AgyNBVFyyTKk8I0u3dTjFjspnb1i7Neyj+dJMXEQ== 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 DU2PR04MB8773.eurprd04.prod.outlook.com (2603:10a6:10:2e0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Mon, 27 Sep 2021 09:41:26 +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.021; Mon, 27 Sep 2021 09:41:26 +0000 From: Michael Chang To: The development of GNU GRUB Subject: [PATCH v2] Fix build error in binutils 2.36 Date: Mon, 27 Sep 2021 17:41:21 +0800 Message-ID: <20210927094121.12646-1-mchang@suse.com> X-Mailer: git-send-email 2.31.1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-ClientProxiedBy: HK2PR02CA0160.apcprd02.prod.outlook.com (2603:1096:201:1f::20) 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 HK2PR02CA0160.apcprd02.prod.outlook.com (2603:1096:201:1f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 09:41:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 77944f46-e93d-472c-d02a-08d9819af9a9 X-MS-TrafficTypeDiagnostic: DU2PR04MB8773: 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: 0IBEqgR72pAoHp4ayK+hlM2/nHuSG65YQLqsBRw/ATL+kMv2i01FbpJTM13+FcOnLtM8BA0jQSbslQUavV2PQ8xOyzfFsGP6HLDraB8W4OHDqeAwP5CCmVL9FErnVVHtRRDGDlqwBgcm+aHENXPg5CwlYZC6hGFikdV8SCxoZSd8WzkAr+AizmrvpJ7/mM+joghLI7vCVyVHUfNxwgc2HVQ9W3UPF/oNLLvMv0KeTJkdYT1op5wPe/ixRi/jN0UNjcjmbCLzWBDONBF2blpknKw9gcUbzUZhQcSz7cPylt/Qf8XuVCm6taWCc8zhIZg8QcZ8Ih+krEw6rKz5KRxMxk79Dp8SldzeXeUi8FvSzsZ+S0Q1ax5VkHauwHuU8shipRrNAvEtHjNVJgjAsTdkYj1nH0PXep85sMz5tHOnv0MP0OJJ2wgbHKzNKuD2Qt27sO85Fub1EXkdJzS8fi8mVsjfBCeTui361kqXccCfaL88ODUBCE3OMpbaMUvily1YxuVroxtbmqRWQ9K8JI/1lV/hrthz9zqEQDK6vlsHz1OVcHRzl77Q6RFKhEG0ZqQ2W9vYj0bXIVetc+DlRlmgSUzO4AG/GX9sXxVhx8Y9WziSjyLmljhiX02xCFr9Hzfnn1uALwbrBoVSnmYy0UNYdvCwW+KKPO8FdcWq0KOoNJyf2faGo57KN8LzBy2XcgeQ1X8fmdbFg5mdMGSsc5+bG6BBOu3P2cbf6kwHqCNTMnEnDjm8+5izrxiyVs534m9qYjr6mPohQMtNuKLnL81X0Q== 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)(2906002)(8936002)(966005)(6916009)(6486002)(8676002)(6496006)(508600001)(316002)(38100700002)(186003)(5660300002)(86362001)(66556008)(36756003)(66946007)(2616005)(6666004)(83380400001)(1076003)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?H5w/sNwBX6gA2pbLGnyvgtJQo9WXcx1SBiKxnAF2QRlu4fxRMpIQ0A/KoYXS?= =?us-ascii?Q?NUcEFTAaZ6YeOJcSFdIbPqFbCo6h/dN13cauPctCwzUQYSyNTd/EkyF8XAq2?= =?us-ascii?Q?XQK+Ame7Y1Hrny6sIpe5i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f6?= =?us-ascii?Q?q795QV+g0OoL4gQWFUyB9bxiSzQDznN3fYWq+4i8Ra49LD/ZWGjDkycueJXv?= =?us-ascii?Q?caqQEMHA7I/IVvT4rdebgB0Tofh7EPlHnLGjzdHMTtmg+Age9LfZmfIpZ6+7?= =?us-ascii?Q?8ZnXwzwTHMrypt020nhwPbDr0s8je5XiTp/YgQFD3PjLpXcdxA/kKCDMXq8D?= =?us-ascii?Q?dvDsJIZFQkYQBgm/Jd+sS1D3NbP0MjjKpd6Lm+jkQLEa1SsvcLSStjLIUUw2?= =?us-ascii?Q?1pnYG/tZ8C5TENVlrH+eO5UJ87Z2XxlDbpLNAiSFRL9DE9LJ3NTwS3Epw0mE?= =?us-ascii?Q?VyAd/Zs+cLBNYvjcjLGRVtl0AS+C37Pq6SBQ66XAECRcTSZTWs279j6osmxI?= =?us-ascii?Q?lQ60S/vEPs/WdcFgxdtYFIxhptSc?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77944f46-e93d-472c-d02a-08d9819af9a9 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8648.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 09:41:26.4174 (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: sCv28UOwhlR6kI16WINy4CxNFgUVK8f3YOa/ig4O1BMUd1g1kh/hRvEdpl5khetf X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8773 Received-SPF: pass client-ip=194.104.111.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: Mon, 27 Sep 2021 09:41:34 -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://bugs.gentoo.org/787221 [3] Ref: https://sourceware.org/bugzilla/show_bug.cgi?id=3D27377 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