| Message ID | 20250918150606.1630916-2-matthieu.longo@arm.com |
|---|---|
| State | New |
| Headers |
Return-Path: <binutils-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1ED33858435 for <patchwork@sourceware.org>; Thu, 18 Sep 2025 15:07:47 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010029.outbound.protection.outlook.com [52.101.69.29]) by sourceware.org (Postfix) with ESMTPS id 2BA6E3858C42 for <binutils@sourceware.org>; Thu, 18 Sep 2025 15:07:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2BA6E3858C42 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2BA6E3858C42 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=52.101.69.29 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1758208029; cv=pass; b=rpWEtiXzaMXfJuA5tSAdqHYHX4eeI5YSE3j7C6UstpBYCNxL9JUgF2NRlakiK4Ds2QLJn8CP4kD6v8aN1P+9w3UQSnMqLlmFAbNfySDBrkSmyxZacifWZt5BzqMcCOAB/jyEo69lPvmR/8CjSzhkVvZ+o1Kz3J5N0zDiT+3M6gU= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1758208029; c=relaxed/simple; bh=RlksmDjVclIa77RFv4VTVjOq0GwWTE1ZNlnEJ4IzE08=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=v5DhRV1MSUk7tvih5Nz6v+Pkb9FUoe5GGFYAW11sWk7q26lcsYnIeUST5lSFgyGMr14UqhNu4z5q+hCz3p/akG5eLDBlepWR3e2+m2u9+R/9Ca1hC7JlHBa5Unqe4dWq2fMeYI2/NZlsJCAMHSDnIzVPVmx1wO+PCKieHCG3MGU= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=LD9oRFUSpd/hzT0VXOynloqoPhmMqVmR+M0cNTKgMApGFHa95W7ReIKwt4KrKPfyI7UxpofMc8HPIhgJaPAv3Qx5RzK+wmwgxxApLFZ2v8YHSwyqWZaImd8P5EBL5pY7ciHJHgDSFja1hzZPI4Sg4s4ECcGkKxihj6qsB81O7x5FBVTSv52nzrAzfPm05yLBXpnubzQxcZdfK0cJ8fSFW/KXUgUbgu3XjhrkWSCkJv5KXGPoS8o/y0CaaMZxyqqeXY3uK+kL1QzfmjBzdQLCQ+C/ccvwvKE3qK7N8B/HMov9LZXXn0vQedNudVQZV5R69SmDMvBl/1HOKFGOye9cpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uGNVN5DtPXnBL6gjMgcgiQNhtpYyXsDUrQsthYiY8SE=; b=K3NP/Lmw/hUXDwrEN3AIqte9rcvoCgCEVNYf0GcMUhIBDWBlqOFnYj1AN/K1jtiKuTik0rvj+gQ4FAAhReUe+WvYSOPwq4wEtmqjHdfarUZ2TZDXQ0evVD54A1ofg6Tsyj5C5Bf+Ha77bF4w7jKR+GndOyYY69xTgYRecJouoYLuMforR94sLiB2Va6fROBi0DNrMzBUh5rpGTdHcVGtPDmPMK3C0zfUCea9oTR5cpfvPyDGaXv6xyYxsnbsiv/OH/VIIAgeFwgIjq2awp05B3ToRyMMWvK4WSysJZ/QJmP1n5MSZFfe6pkb+aTUld0gri56AOLomJOHcKDF80jVxQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uGNVN5DtPXnBL6gjMgcgiQNhtpYyXsDUrQsthYiY8SE=; b=oDaK9RklghpJLxnqivp5esRoNqzZBC9O++LjTrGMNLjKml2BP3YVNMKIOACwZt9F37HucsocTZnOQAA2v0MMzA9Q5sr/0nh9dRWJQj7LWGgMcF0F8Dw7rTknNre5bfVbWXL+845Sj2Vwewjct0YM862uT9Z9FU3aAn8G3KVsYe8= Received: from DB8PR03CA0024.eurprd03.prod.outlook.com (2603:10a6:10:be::37) by AS2PR08MB9546.eurprd08.prod.outlook.com (2603:10a6:20b:60d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9137.14; Thu, 18 Sep 2025 15:07:03 +0000 Received: from DU6PEPF00009523.eurprd02.prod.outlook.com (2603:10a6:10:be:cafe::8c) by DB8PR03CA0024.outlook.office365.com (2603:10a6:10:be::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9137.14 via Frontend Transport; Thu, 18 Sep 2025 15:07:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; pr=C Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by DU6PEPF00009523.mail.protection.outlook.com (10.167.8.4) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9137.12 via Frontend Transport; Thu, 18 Sep 2025 15:07:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ROCq6F0wKxdQt9Z0cYNBLurdvej49OMta78DIS5EbfUfcnsO4UTGKfGryp/xp2PhuGi1a/rmrbKgMi7N5gNXdqFbFDHzG7JUG5EDkDqo4/nO9mGZmLVj+bSFdpcpcLiK2dptQ7xXY6I4+/SyMWIYTQxONrvZcc9jV8Jc0bI5ukFIas2YDxv1aOKoEu38XPifdT+eKH13OKg1Yxmb4m3Xqe7uTw3d7dCvFC7Qb8oSbCO2mYlRQKwFyNIKDPiacahplLi761qJv+IgxKms7tiI8qwElZlGUqX6ZeilivS28vMKdgo79vsI2z75TkSm0TpPOdunZHlrFYe6LsCOhUIhcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uGNVN5DtPXnBL6gjMgcgiQNhtpYyXsDUrQsthYiY8SE=; b=bHnVP1QH5o2+qOkRDjCSnN6q1SYMNxyyFKOkHeZG7Y1bY7em25cPJPTQRoW5Bps/01OYEIauNmhBEBZPxNhvxkN4x883PFJuZdZ7781GxrYP1Anj7W4/mRru6wjRDFM3mmCx4U3fkqdmN2j8yAZsBwjXMq783dL98hHxA95jYIEmQoAC+sW8ro81ZaAFFj071pdsjtFmVWY0haLlf0tEbGOo/8Vvvmxw6cvqGmlcxCefxCrgWwYc6W3qH9fJ9S/yXMicLPBUfRzqwjfb8cmas0rYjaIcCBBiK+PzUdURKTDWibdR96eWxUgkdlPanoo06z4M2qgnFnSQC7pgp4e7Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uGNVN5DtPXnBL6gjMgcgiQNhtpYyXsDUrQsthYiY8SE=; b=oDaK9RklghpJLxnqivp5esRoNqzZBC9O++LjTrGMNLjKml2BP3YVNMKIOACwZt9F37HucsocTZnOQAA2v0MMzA9Q5sr/0nh9dRWJQj7LWGgMcF0F8Dw7rTknNre5bfVbWXL+845Sj2Vwewjct0YM862uT9Z9FU3aAn8G3KVsYe8= Received: from DU2PR04CA0066.eurprd04.prod.outlook.com (2603:10a6:10:232::11) by GV1PR08MB8356.eurprd08.prod.outlook.com (2603:10a6:150:a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9137.13; Thu, 18 Sep 2025 15:06:25 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:232:cafe::4a) by DU2PR04CA0066.outlook.office365.com (2603:10a6:10:232::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9137.13 via Frontend Transport; Thu, 18 Sep 2025 15:06:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (172.205.89.229) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.9137.12 via Frontend Transport; Thu, 18 Sep 2025 15:06:24 +0000 Received: from AZ-NEU-EXJ01.Arm.com (10.240.25.132) by AZ-NEU-EX06.Arm.com (10.240.25.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 18 Sep 2025 15:06:23 +0000 Received: from AZ-NEU-EX06.Arm.com (10.240.25.134) by AZ-NEU-EXJ01.Arm.com (10.240.25.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 18 Sep 2025 15:06:23 +0000 Received: from PW070M4K.arm.com (10.57.61.196) by mail.arm.com (10.240.25.134) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 18 Sep 2025 15:06:22 +0000 From: Matthieu Longo <matthieu.longo@arm.com> To: <binutils@sourceware.org> CC: Christophe Lyon <christophe.lyon@arm.com>, Alan Modra <amodra@gmail.com>, Tamar Christina <tamar.christina@arm.com>, Richard Earnshaw <Richard.Earnshaw@arm.com>, Surya Kumari Jangala <jskumari@linux.ibm.com>, Peter Bergner <bergner@tenstorrent.com>, Matthieu Longo <matthieu.longo@arm.com> Subject: [PATCH v1 1/5] ld: fix segfault caused by untagged stub sections Date: Thu, 18 Sep 2025 16:06:02 +0100 Message-ID: <20250918150606.1630916-2-matthieu.longo@arm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918150606.1630916-1-matthieu.longo@arm.com> References: <20250918150606.1630916-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GV1PR08MB8356:EE_|DU6PEPF00009523:EE_|AS2PR08MB9546:EE_ X-MS-Office365-Filtering-Correlation-Id: 77eface3-6930-4caf-5b3f-08ddf6c5062d x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info-Original: 60EH5iuFvNvGCqkuldNrTnozErZKT9CDReN/UP5M4aIfctjd/5bJGXCLW2WJw4/L4e4s95+3tnkjygHkUs5Vv88MofSlv/A1ekPmc1HqIa8i2msj8kbI/RZDqgu/zxON1hovpZ5VlX8ZUrowf0Yir0T9PWzMImV8tvd2byYcEWIIxoFMC0Qg7PItOWuLvhriqmpgNJ44FFuvNjEfwiqzOyd2vy1GZKHKkQFRggrai9YIXzs+VjITcTtlgueWHM/e1Yv9cjHFLFjUzPEZ6On6doaOC7TcwTQwYqTHgUN+LK82iVwXVhMOpuUfXfbh3aW1gDrGzUrn7qcVdTFnp6G10pf1HGAPqMOpcUeK2ok3ZOmqE15qIrRQBkawmYdVpkn2WpIUlyfIm6lMcGCkeJcW8oY39Sp/3AwzXzVNzAIkkugR1Y+GdiApPdUOExAiRcu5sF88V1rLR02nBtcdpGmcTKedIfDxVZRXtqX1XnhHj39GX60hofZnzJPe5SxBlT9/DLN1U7c/mvz1SrJ2QektGu0iyUX8fHJ3LFurxZHLXwBBxKiHE9ixk3TawWokkMZj6+44b5wPd4Asj9bSHGWoHwzbxprOVtkb7vBejUaVk9ULl8Q61pq89MSoRXEN4/ytmboMe+V6L+ABqcd32EJp2/YHupnCVKR9ev+HeFybpYfypvGH5Kviw6Qvs+15T4pNLhXwEfPBoC8TXIm+WUwwucnGOtgtdql2WA1gH0iBiXl4wjjtZXqfuaLH0NKn8dpA5Agk4Am2j/RC2FAXFk39W/qxmZZ/TVb+Jj84e+EatlpUZaDkRyTKkLfF+4GLA7zWtn+DDL43FsG7sLwK0LUMDOKqCp/zuCQLdCyn2FCwKm2j5+ZruynW9yN5MOVM1yV3mmxlMsTtizQ/ugORaYVZUeOMrx7GAewju4VHE0yvGWYasUnR3sPEdfF9ySZ+Jh1msaLjNUCFOPt06UsCUy3bVUXlYSnGN2S00ZGL5Y5GD/wHv7GzIK7E+4oSk7tXtg5A6zIYz50/jx3Gey1v1JrbrPyyL9MFFT4UThvIDxweFLxobotnobxk1MxiVI6vETZxia766nFazqBvmMAoz/4P5N1dr7pPU2lX/b7CxqRrJHht9Hoeqwrdo1idlkR94hVgkMxFdgCHDqB6W0725fFK72Cmj44ZRY2oqLSCCt3SgEDsJ+/z9Z/7seXvgFIwe8q5JxaTrg1JJGKEONs6AIzJJJOxE4EJ3DIOixtpqkiMS6zFGRKeXX1Jm+51n5h6stfJgkxF92J9hxZWgJT2cmPknAJSJS2yfrY0iKy65QPU3+fHGHCvDWtXH2V9i0j4NXI/ALfmyxkn7CJpDDzu8i8nMGlQVQCvp6gTEYN/dxAHZyCXDJQoMcTSnbrs/S+udEicTrxdIo9noD8RpsOw6DpJTh4sR1hWZrKLknOqVtoBexNRKIkV4OmXJ35ZV4lGeJmYs+sraar4m1rscCbG8KkhgcwSMqULEOPza6sids56ZG3M3BIjF213LDMRQRqIFGZy X-Forefront-Antispam-Report-Untrusted: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8356 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF00009523.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 56da4c29-ca37-416b-b447-08ddf6c4ef98 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|35042699022|14060799003|376014|1800799024; X-Microsoft-Antispam-Message-Info: bYfAVXUKmsyoyopMyMVAGfEr6CZEC5x8Mt80osLhcsRFsk7pdOiB/tbW1L4NN/7EhGry6ptSovYE/1XP/hNQaskI0fuCNpnzKOL4vudaSBFtm6z7wQ7q7SKud1YhBWVtDEfwkndG4d1tKrhA27uQGI4xrxyuxIghOGP09cEg83Yu48htKHe4X+dodpPR2+PYeCHMfDG/ogwC5JUuXJQR2k+w6Qxs33kB5gPVypoKlEe72yN+qzW9J03edEMGoXPd66sDlLL2hSHnnxVLYJBhPxsEsOvWlp6pJCMl6LvDfsIPHQoJai9nG0l12LWei+l7Gw2YghSl4OTExXTVCS5XckfjTod8GG9TVenzeWwHGN/WvKzuX0J/i7JP3gkWqSkgfhvmNgJ6qRW4lIWDgPYPlfzSRGG8JbkE44xmbvOWSHpdhloGgyp7OoJ3xrGzxfkGYeuB/m18xvbwDWwUu9Iwt9FrwVXIBR1oKaJXnL7nkCtXKMZVglihlj87f5cFFhPI46Jy/H2BurK3IhfUgD9FSMObPq45zDGMMrNeXbJCYGQEjiRAlK9CiEz5vnCsy7mpQxqlH13Y69WrDsbvnEi8Tl+G8nTrH82u/NsGR/3Gb1puzjpWA6FZQ5HRKnvM8mb4Kz4YuLDaxzEV1JjRS6U69apadGRFPHAx83F7oJxLbN/80W+gPV665nNfl0kgw68Z1YCtHOQPJ1hGLmeZEpzQ30Gfn9g2TOq7xdy2W5kLG4xDqDg67kXFN7Pedbw2ca7lykpTXOAe5Y0il+srufvn80ud+eQ2vBrQEEe13TpP0qI+XOg36I4xTqayUahlT1vyXcFqP8nRLzjiMjaSp9mGSW6N/W4HtkCeitt0CJ3nJ8+cwYcwG6T8+cDHBXPBYtQs44FM9n5nn5m9azTbDBEcBW1BZH7R6wiIHUrXS9vLObThbjLV/6M0iElLs3IcFBjfltYNR+j1+GSXUlgHxC3MX+6Ly0+/U4XAwuCmKCqXLfJvwqX7AvLoGPfI2EMnG5D3vAOFJ+DlFUc/gmMRyMgjIt6A7uOi5BFsNWqDRbk5FmKe2Wfh7GqWOKarSLsseo6+yxLf7diNySe4X8KhCn8M11gwMszLC1HdDWzt/NATmX7PHEQlpil4ezGzUislmMNINM4hVPoQ/NHxNkmFTy9IIUTXbRW0q1lSmPyWX/ayetfBDZ3Uu0TS7rcWhV5kw4pTbQEzXFsZSABlMKxlR2aXIh8wZvBQ/Rea7gcpluZpCDypDa6XuUULqjaXpp8tysMVA8G3pkYVEnfddLU7MMwYrbtGZMulCKLOjmVNAMg3Yk6OM87mVVnvCfOuZvF0tJJWIF3x4PEPCMylF+tkADBKtN2DEHkr4qfLGTfJFmJwf8AvjSWJaoox2EqSBF55MD3TAdVgUscN07kZOw03lD068qx+URpYmKxum5D+NQurYYJr7kdQjXhYPkvAbHdFyUcFVHQwIOGP8ht55gYf1WtjjnzK44yIAEP1uVmmPHui/qRxg49Rj7DWGRPZvUa9mJkn X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(35042699022)(14060799003)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2025 15:07:02.7929 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77eface3-6930-4caf-5b3f-08ddf6c5062d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: DU6PEPF00009523.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9546 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
ld: fix segfaults when non-contiguous memory support is enabled
|
|
Commit Message
Matthieu Longo
Sept. 18, 2025, 3:06 p.m. UTC
In the case of non-contiguous memory regions, a far-call stub section must be assigned to the memory of the section it was originally emitted for. If the stub section does not fit, the section is marked as dropped, and removed later. To emit a useful message to the user, however, a stub section needs to be discernible from sections originating from input objects. Previously [1], this distinction was made using the SEC_LINKER_CREATED flag only the AArch32 backend handler <arch>_add_stub_section. Other backends that didn't set this flag on their stub sections skipped required checks in ld/ldlang.c:size_input_section(). On AArch64, this caused the linker to proceed into code paths that assumed output sections were set, instead of reporting fatal errors, and ultimately led to a segmentation fault. However, the SEC_LINKER_CREATED flag does not solely indicate that a section was created by the linker. Its original meaning also meant that the section should not be handled by the generic relocation code. Reusing this flag to identify stub sections, while it appeared to fix the issue, introduced unintended side effects. On PowerPC, for instance, it skipped relocations present in the stubs and interpreted them as absolute addresses. This patch proposes a new approach: a new boolean attribute 'veneer' added to 'asection'. The attribute is set on AArch64 and PowerPC immediately after the creation of the stub section. Others architectures are left unchanged, as they do not appear to support non-contiguous memory regions (no tests were found to verify the fix). Additionally, the diagnostic message was improved when a stub cannot be placed in the same memory region as its referencing code. [1]: abf874a, Add support for non-contiguous memory regions. --- bfd/bfd-in2.h | 6 ++++++ bfd/libbfd.h | 4 ++-- bfd/section.c | 10 ++++++++-- ld/emultempl/aarch64elf.em | 2 ++ ld/emultempl/armelf.em | 5 +++-- ld/emultempl/ppc64elf.em | 2 ++ ld/ldlang.c | 13 +++++++------ ld/testsuite/ld-arm/non-contiguous-arm4.d | 2 +- ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d | 2 +- 9 files changed, 32 insertions(+), 14 deletions(-)
Comments
On 18.09.2025 17:06, Matthieu Longo wrote: > In the case of non-contiguous memory regions, a far-call stub section > must be assigned to the memory of the section it was originally emitted > for. If the stub section does not fit, the section is marked as dropped, > and removed later. To emit a useful message to the user, however, a stub > section needs to be discernible from sections originating from input > objects. > > Previously [1], this distinction was made using the SEC_LINKER_CREATED > flag only the AArch32 backend handler <arch>_add_stub_section. Other > backends that didn't set this flag on their stub sections skipped required > checks in ld/ldlang.c:size_input_section(). On AArch64, this caused the > linker to proceed into code paths that assumed output sections were set, > instead of reporting fatal errors, and ultimately led to a segmentation > fault. > > However, the SEC_LINKER_CREATED flag does not solely indicate that a > section was created by the linker. Its original meaning also meant that > the section should not be handled by the generic relocation code. Reusing > this flag to identify stub sections, while it appeared to fix the issue, > introduced unintended side effects. On PowerPC, for instance, it skipped > relocations present in the stubs and interpreted them as absolute > addresses. > > This patch proposes a new approach: a new boolean attribute 'veneer' added > to 'asection'. The attribute is set on AArch64 and PowerPC immediately > after the creation of the stub section. Others architectures are left > unchanged, as they do not appear to support non-contiguous memory regions > (no tests were found to verify the fix). Additionally, the diagnostic > message was improved when a stub cannot be placed in the same memory > region as its referencing code. > > [1]: abf874a, Add support for non-contiguous memory regions. > --- > bfd/bfd-in2.h | 6 ++++++ > bfd/libbfd.h | 4 ++-- > bfd/section.c | 10 ++++++++-- > ld/emultempl/aarch64elf.em | 2 ++ > ld/emultempl/armelf.em | 5 +++-- > ld/emultempl/ppc64elf.em | 2 ++ > ld/ldlang.c | 13 +++++++------ > ld/testsuite/ld-arm/non-contiguous-arm4.d | 2 +- > ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d | 2 +- > 9 files changed, 32 insertions(+), 14 deletions(-) I'm okay with the approach, yet there is a largely mechanical issue: > --- a/bfd/bfd-in2.h > +++ b/bfd/bfd-in2.h > @@ -834,6 +834,12 @@ typedef struct bfd_section > const char *linked_to_symbol_name; > } map_head, map_tail; > > + /* Indicate that the section contains branch veneers. This is used when > + support for non-contiguous memory regions is enabled. The veneers have > + to be allocated to the same memory region as the code they are refered > + by, i.e. they cannot be moved to a subsequent memory region. */ > + bool veneer; Why would you put a bool between two pointer-sized fields, thus introducing yet more padding, when in fact existing padding could be used. There's a set of bitfields further up from here, and you could simply add a single-bit field there, for example. Generic code changes are okay with that change, but arch-specific ones will need arch maintainer approval. Jan
On Thu, Sep 18, 2025 at 11:07 PM Matthieu Longo <matthieu.longo@arm.com> wrote: > > In the case of non-contiguous memory regions, a far-call stub section > must be assigned to the memory of the section it was originally emitted > for. If the stub section does not fit, the section is marked as dropped, > and removed later. To emit a useful message to the user, however, a stub > section needs to be discernible from sections originating from input > objects. > > Previously [1], this distinction was made using the SEC_LINKER_CREATED > flag only the AArch32 backend handler <arch>_add_stub_section. Other > backends that didn't set this flag on their stub sections skipped required > checks in ld/ldlang.c:size_input_section(). On AArch64, this caused the > linker to proceed into code paths that assumed output sections were set, > instead of reporting fatal errors, and ultimately led to a segmentation > fault. > > However, the SEC_LINKER_CREATED flag does not solely indicate that a > section was created by the linker. Its original meaning also meant that > the section should not be handled by the generic relocation code. Reusing > this flag to identify stub sections, while it appeared to fix the issue, > introduced unintended side effects. On PowerPC, for instance, it skipped > relocations present in the stubs and interpreted them as absolute > addresses. > > This patch proposes a new approach: a new boolean attribute 'veneer' added > to 'asection'. The attribute is set on AArch64 and PowerPC immediately > after the creation of the stub section. Others architectures are left > unchanged, as they do not appear to support non-contiguous memory regions > (no tests were found to verify the fix). Additionally, the diagnostic > message was improved when a stub cannot be placed in the same memory > region as its referencing code. > > [1]: abf874a, Add support for non-contiguous memory regions. > --- > bfd/bfd-in2.h | 6 ++++++ > bfd/libbfd.h | 4 ++-- > bfd/section.c | 10 ++++++++-- > ld/emultempl/aarch64elf.em | 2 ++ > ld/emultempl/armelf.em | 5 +++-- > ld/emultempl/ppc64elf.em | 2 ++ > ld/ldlang.c | 13 +++++++------ > ld/testsuite/ld-arm/non-contiguous-arm4.d | 2 +- > ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d | 2 +- > 9 files changed, 32 insertions(+), 14 deletions(-) > > diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h > index 5e7c6ddf1ee..a4049fa0e98 100644 > --- a/bfd/bfd-in2.h > +++ b/bfd/bfd-in2.h > @@ -834,6 +834,12 @@ typedef struct bfd_section > const char *linked_to_symbol_name; > } map_head, map_tail; > > + /* Indicate that the section contains branch veneers. This is used when > + support for non-contiguous memory regions is enabled. The veneers have > + to be allocated to the same memory region as the code they are refered > + by, i.e. they cannot be moved to a subsequent memory region. */ > + bool veneer; > + > /* Points to the output section this section is already assigned to, > if any. This is used when support for non-contiguous memory > regions is enabled. */ > diff --git a/bfd/libbfd.h b/bfd/libbfd.h > index f2485d99078..df9d5c8cc19 100644 > --- a/bfd/libbfd.h > +++ b/bfd/libbfd.h > @@ -3694,8 +3694,8 @@ bool _bfd_unrecognized_reloc > /* symbol, */ \ > (struct bfd_symbol *) SYM, \ > \ > - /* map_head, map_tail, already_assigned, type */ \ > - { NULL }, { NULL }, NULL, 0 \ > + /* map_head, map_tail, veneer, already_assigned, type */ \ > + { NULL }, { NULL }, false, NULL, 0 \ > \ > } > > diff --git a/bfd/section.c b/bfd/section.c > index 5f0cf6e71cb..33524762e7a 100644 > --- a/bfd/section.c > +++ b/bfd/section.c > @@ -560,6 +560,12 @@ CODE_FRAGMENT > . const char *linked_to_symbol_name; > . } map_head, map_tail; > . > +. {* Indicate that the section contains branch veneers. This is used when > +. support for non-contiguous memory regions is enabled. The veneers have > +. to be allocated to the same memory region as the code they are refered > +. by, i.e. they cannot be moved to a subsequent memory region. *} > +. bool veneer; Why not a bitfield here? > +. > . {* Points to the output section this section is already assigned to, > . if any. This is used when support for non-contiguous memory > . regions is enabled. *} > @@ -747,8 +753,8 @@ INTERNAL > . {* symbol, *} \ > . (struct bfd_symbol *) SYM, \ > . \ > -. {* map_head, map_tail, already_assigned, type *} \ > -. { NULL }, { NULL }, NULL, 0 \ > +. {* map_head, map_tail, veneer, already_assigned, type *} \ > +. { NULL }, { NULL }, false, NULL, 0 \ > . \ > . } > . > diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em > index 91d58d8fe5a..08f5c4c7d58 100644 > --- a/ld/emultempl/aarch64elf.em > +++ b/ld/emultempl/aarch64elf.em > @@ -200,6 +200,8 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name, > if (stub_sec == NULL) > goto err_ret; > > + stub_sec->veneer = true; > + > /* Long branch stubs contain a 64-bit address, so the section requires > 8 byte alignment. */ > bfd_set_section_alignment (stub_sec, 3); > diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em > index 6f652c59a3c..d946f096faa 100644 > --- a/ld/emultempl/armelf.em > +++ b/ld/emultempl/armelf.em > @@ -237,13 +237,14 @@ elf32_arm_add_stub_section (const char * stub_sec_name, > struct hook_stub_info info; > > flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE > - | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP > - | SEC_LINKER_CREATED); > + | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); > stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, > stub_sec_name, flags); > if (stub_sec == NULL) > goto err_ret; > > + stub_sec->veneer = true; > + > bfd_set_section_alignment (stub_sec, alignment_power); > > os = lang_output_section_get (output_section); > diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em > index 857cf54ad06..8e3f60cb12a 100644 > --- a/ld/emultempl/ppc64elf.em > +++ b/ld/emultempl/ppc64elf.em > @@ -440,6 +440,8 @@ ppc_add_stub_section (const char *stub_sec_name, asection *input_section) > : 5))) > goto err_ret; > > + stub_sec->veneer = true; > + > output_section = input_section->output_section; > os = lang_output_section_get (output_section); > > diff --git a/ld/ldlang.c b/ld/ldlang.c > index 3c57bf7541c..bdda599a7a4 100644 > --- a/ld/ldlang.c > +++ b/ld/ldlang.c > @@ -5637,10 +5637,12 @@ size_input_section > > if (dot + TO_ADDR (i->size) > end) > { > - if (i->flags & SEC_LINKER_CREATED) > - fatal (_("%P: Output section `%pA' not large enough for " > - "the linker-created stubs section `%pA'.\n"), > - i->output_section, i); > + if (i->veneer) > + fatal (_("%P: Memory region `%s' not large enough for the " > + "linker-created stubs section `%pA' associated to " > + "output section `%pA'\n"), > + output_section_statement->region->name_list.name, i, > + i->output_section); > > if (i->rawsize && i->rawsize != i->size) > fatal (_("%P: Relaxation not supported with " > @@ -8239,8 +8241,7 @@ warn_non_contiguous_discards (void) > continue; > > for (asection *s = file->the_bfd->sections; s != NULL; s = s->next) > - if (s->output_section == NULL > - && (s->flags & SEC_LINKER_CREATED) == 0) > + if (s->output_section == NULL && !s->veneer) > einfo (_("%P: warning: --enable-non-contiguous-regions " > "discards section `%pA' from `%pB'\n"), > s, file->the_bfd); > diff --git a/ld/testsuite/ld-arm/non-contiguous-arm4.d b/ld/testsuite/ld-arm/non-contiguous-arm4.d > index a8e9d66caca..d4c4b284dce 100644 > --- a/ld/testsuite/ld-arm/non-contiguous-arm4.d > +++ b/ld/testsuite/ld-arm/non-contiguous-arm4.d > @@ -1,4 +1,4 @@ > #name: non-contiguous-arm4 > #source: non-contiguous-arm.s > #ld: --enable-non-contiguous-regions -T non-contiguous-arm4.ld > -# error: .*Output section .?\.ramu.? not large enough for the linker-created stubs section .?\.code\.3\.__stub.\.? > +# error: Memory region `RAMU' not large enough for the linker-created stubs section `\.code\.3\.__stub' associated to output section `\.ramu' > diff --git a/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d b/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d > index 9f903bbea35..1a7e4c5a23b 100644 > --- a/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d > +++ b/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d > @@ -2,4 +2,4 @@ > #source: non-contiguous-powerpc.s > #as: -a64 > #ld: -melf64ppc --enable-non-contiguous-regions -T non-contiguous-powerpc.ld > -#error: .*Could not assign .?\.text\.one\.stub.? to an output section\. Retry without --enable-non-contiguous-regions\. > +#error: Memory region `one' not large enough for the linker-created stubs section `\.text\.one\.stub' associated to output section `one' > -- > 2.51.0 >
On 2025-09-26 14:13, Jan Beulich wrote: > On 18.09.2025 17:06, Matthieu Longo wrote: >> In the case of non-contiguous memory regions, a far-call stub section >> must be assigned to the memory of the section it was originally emitted >> for. If the stub section does not fit, the section is marked as dropped, >> and removed later. To emit a useful message to the user, however, a stub >> section needs to be discernible from sections originating from input >> objects. >> >> Previously [1], this distinction was made using the SEC_LINKER_CREATED >> flag only the AArch32 backend handler <arch>_add_stub_section. Other >> backends that didn't set this flag on their stub sections skipped required >> checks in ld/ldlang.c:size_input_section(). On AArch64, this caused the >> linker to proceed into code paths that assumed output sections were set, >> instead of reporting fatal errors, and ultimately led to a segmentation >> fault. >> >> However, the SEC_LINKER_CREATED flag does not solely indicate that a >> section was created by the linker. Its original meaning also meant that >> the section should not be handled by the generic relocation code. Reusing >> this flag to identify stub sections, while it appeared to fix the issue, >> introduced unintended side effects. On PowerPC, for instance, it skipped >> relocations present in the stubs and interpreted them as absolute >> addresses. >> >> This patch proposes a new approach: a new boolean attribute 'veneer' added >> to 'asection'. The attribute is set on AArch64 and PowerPC immediately >> after the creation of the stub section. Others architectures are left >> unchanged, as they do not appear to support non-contiguous memory regions >> (no tests were found to verify the fix). Additionally, the diagnostic >> message was improved when a stub cannot be placed in the same memory >> region as its referencing code. >> >> [1]: abf874a, Add support for non-contiguous memory regions. >> --- >> bfd/bfd-in2.h | 6 ++++++ >> bfd/libbfd.h | 4 ++-- >> bfd/section.c | 10 ++++++++-- >> ld/emultempl/aarch64elf.em | 2 ++ >> ld/emultempl/armelf.em | 5 +++-- >> ld/emultempl/ppc64elf.em | 2 ++ >> ld/ldlang.c | 13 +++++++------ >> ld/testsuite/ld-arm/non-contiguous-arm4.d | 2 +- >> ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d | 2 +- >> 9 files changed, 32 insertions(+), 14 deletions(-) > > I'm okay with the approach, yet there is a largely mechanical issue: > >> --- a/bfd/bfd-in2.h >> +++ b/bfd/bfd-in2.h >> @@ -834,6 +834,12 @@ typedef struct bfd_section >> const char *linked_to_symbol_name; >> } map_head, map_tail; >> >> + /* Indicate that the section contains branch veneers. This is used when >> + support for non-contiguous memory regions is enabled. The veneers have >> + to be allocated to the same memory region as the code they are refered >> + by, i.e. they cannot be moved to a subsequent memory region. */ >> + bool veneer; > > Why would you put a bool between two pointer-sized fields, thus introducing > yet more padding, when in fact existing padding could be used. There's a set > of bitfields further up from here, and you could simply add a single-bit > field there, for example. Generic code changes are okay with that change, > but arch-specific ones will need arch maintainer approval. > > Jan Hi Jan, Sorry for the silence, I was on annual leave for about 3 weeks. Here is the new attribute as a flag: diff --git a/bfd/section.c b/bfd/section.c index 5f0cf6e71cb..f110ed77363 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -379,6 +379,12 @@ CODE_FRAGMENT . when memory read flag isn't set. *} .#define SEC_COFF_NOREAD 0x40000000 . +. {* Indicate that the section contains branch veneers. This is used when +. support for non-contiguous memory regions is enabled. The veneers have +. to be allocated to the same memory region as the code they are refered +. by, i.e. they cannot be moved to a subsequent memory region. *} +.#define SEC_VENEER 0x80000000 +. . {* End of section flags. *} . . {* Some internal packed boolean fields. *} With the tagging of the stub section on AArch64: diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em index 91d58d8fe5a..b00c9460da2 100644 --- a/ld/emultempl/aarch64elf.em +++ b/ld/emultempl/aarch64elf.em @@ -193,7 +193,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name, lang_output_section_statement_type *os; struct hook_stub_info info; - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_VENEER | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, stub_sec_name, flags); Same thing on AArch32 and PowerPC. Is this what you suggested ? Matthieu
On 2025-09-26 22:39, H.J. Lu wrote: > On Thu, Sep 18, 2025 at 11:07 PM Matthieu Longo <matthieu.longo@arm.com> wrote: >> >> diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h >> index 5e7c6ddf1ee..a4049fa0e98 100644 >> --- a/bfd/bfd-in2.h >> +++ b/bfd/bfd-in2.h >> @@ -834,6 +834,12 @@ typedef struct bfd_section >> const char *linked_to_symbol_name; >> } map_head, map_tail; >> >> + /* Indicate that the section contains branch veneers. This is used when >> + support for non-contiguous memory regions is enabled. The veneers have >> + to be allocated to the same memory region as the code they are refered >> + by, i.e. they cannot be moved to a subsequent memory region. */ >> + bool veneer; >> + >> /* Points to the output section this section is already assigned to, >> if any. This is used when support for non-contiguous memory >> regions is enabled. */ >> diff --git a/bfd/section.c b/bfd/section.c >> index 5f0cf6e71cb..33524762e7a 100644 >> --- a/bfd/section.c >> +++ b/bfd/section.c >> @@ -560,6 +560,12 @@ CODE_FRAGMENT >> . const char *linked_to_symbol_name; >> . } map_head, map_tail; >> . >> +. {* Indicate that the section contains branch veneers. This is used when >> +. support for non-contiguous memory regions is enabled. The veneers have >> +. to be allocated to the same memory region as the code they are refered >> +. by, i.e. they cannot be moved to a subsequent memory region. *} >> +. bool veneer; > > Why not a bitfield here? Jan also suggested it. See my reply to his email. Matthieu
On 13.10.2025 17:22, Matthieu Longo wrote: > On 2025-09-26 14:13, Jan Beulich wrote: >> On 18.09.2025 17:06, Matthieu Longo wrote: >>> --- a/bfd/bfd-in2.h >>> +++ b/bfd/bfd-in2.h >>> @@ -834,6 +834,12 @@ typedef struct bfd_section >>> const char *linked_to_symbol_name; >>> } map_head, map_tail; >>> >>> + /* Indicate that the section contains branch veneers. This is used when >>> + support for non-contiguous memory regions is enabled. The veneers have >>> + to be allocated to the same memory region as the code they are refered >>> + by, i.e. they cannot be moved to a subsequent memory region. */ >>> + bool veneer; >> >> Why would you put a bool between two pointer-sized fields, thus introducing >> yet more padding, when in fact existing padding could be used. There's a set >> of bitfields further up from here, and you could simply add a single-bit >> field there, for example. Generic code changes are okay with that change, >> but arch-specific ones will need arch maintainer approval. > > Here is the new attribute as a flag: > > diff --git a/bfd/section.c b/bfd/section.c > index 5f0cf6e71cb..f110ed77363 100644 > --- a/bfd/section.c > +++ b/bfd/section.c > @@ -379,6 +379,12 @@ CODE_FRAGMENT > . when memory read flag isn't set. *} > .#define SEC_COFF_NOREAD 0x40000000 > . > +. {* Indicate that the section contains branch veneers. This is used when > +. support for non-contiguous memory regions is enabled. The > veneers have > +. to be allocated to the same memory region as the code they are > refered > +. by, i.e. they cannot be moved to a subsequent memory region. *} > +.#define SEC_VENEER 0x80000000 > +. > . {* End of section flags. *} > . > . {* Some internal packed boolean fields. *} > > > With the tagging of the stub section on AArch64: > > diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em > index 91d58d8fe5a..b00c9460da2 100644 > --- a/ld/emultempl/aarch64elf.em > +++ b/ld/emultempl/aarch64elf.em > @@ -193,7 +193,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char > *stub_sec_name, > lang_output_section_statement_type *os; > struct hook_stub_info info; > > - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE > + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_VENEER > | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); > stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, > stub_sec_name, flags); > > Same thing on AArch32 and PowerPC. > > Is this what you suggested ? No, sorry. I said "bit field", not "section flag". I'd rather not see you use the last available section flag. Right below where you put the new #define is a comment "Some internal packed boolean fields" - that's where I thought your new flag would go. Jan
On 2025-10-13 16:30, Jan Beulich wrote: > On 13.10.2025 17:22, Matthieu Longo wrote: >> On 2025-09-26 14:13, Jan Beulich wrote: >>> On 18.09.2025 17:06, Matthieu Longo wrote: >>>> --- a/bfd/bfd-in2.h >>>> +++ b/bfd/bfd-in2.h >>>> @@ -834,6 +834,12 @@ typedef struct bfd_section >>>> const char *linked_to_symbol_name; >>>> } map_head, map_tail; >>>> >>>> + /* Indicate that the section contains branch veneers. This is used when >>>> + support for non-contiguous memory regions is enabled. The veneers have >>>> + to be allocated to the same memory region as the code they are refered >>>> + by, i.e. they cannot be moved to a subsequent memory region. */ >>>> + bool veneer; >>> >>> Why would you put a bool between two pointer-sized fields, thus introducing >>> yet more padding, when in fact existing padding could be used. There's a set >>> of bitfields further up from here, and you could simply add a single-bit >>> field there, for example. Generic code changes are okay with that change, >>> but arch-specific ones will need arch maintainer approval. >> >> Here is the new attribute as a flag: >> >> diff --git a/bfd/section.c b/bfd/section.c >> index 5f0cf6e71cb..f110ed77363 100644 >> --- a/bfd/section.c >> +++ b/bfd/section.c >> @@ -379,6 +379,12 @@ CODE_FRAGMENT >> . when memory read flag isn't set. *} >> .#define SEC_COFF_NOREAD 0x40000000 >> . >> +. {* Indicate that the section contains branch veneers. This is used when >> +. support for non-contiguous memory regions is enabled. The >> veneers have >> +. to be allocated to the same memory region as the code they are >> refered >> +. by, i.e. they cannot be moved to a subsequent memory region. *} >> +.#define SEC_VENEER 0x80000000 >> +. >> . {* End of section flags. *} >> . >> . {* Some internal packed boolean fields. *} >> >> >> With the tagging of the stub section on AArch64: >> >> diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em >> index 91d58d8fe5a..b00c9460da2 100644 >> --- a/ld/emultempl/aarch64elf.em >> +++ b/ld/emultempl/aarch64elf.em >> @@ -193,7 +193,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char >> *stub_sec_name, >> lang_output_section_statement_type *os; >> struct hook_stub_info info; >> >> - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE >> + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_VENEER >> | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); >> stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, >> stub_sec_name, flags); >> >> Same thing on AArch32 and PowerPC. >> >> Is this what you suggested ? > > No, sorry. I said "bit field", not "section flag". I'd rather not see you > use the last available section flag. Right below where you put the new > #define is a comment "Some internal packed boolean fields" - that's where > I thought your new flag would go. > > Jan What about the below ? diff --git a/bfd/section.c b/bfd/section.c index 5f0cf6e71cb..424e53029d9 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -428,6 +428,12 @@ CODE_FRAGMENT . {* Nonzero if section contents should not be freed. *} . unsigned int alloced:1; . +. {* Indicate that the section contains branch veneers. This is used when +. support for non-contiguous memory regions is enabled. The veneers have +. to be allocated to the same memory region as the code they are refered +. by, i.e. they cannot be moved to a subsequent memory region. *} +. unsigned int veneer : 1; +. . {* Bits used by various backends. The generic code doesn't touch . these fields. *} . @@ -723,11 +729,11 @@ INTERNAL . {* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced, *} \ . 0, 0, 0, 0, 0, \ . \ -. {* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, *} \ +. {* veneer, sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, *} \ . 0, 0, 0, 0, 0, 0, \ . \ -. {* vma, lma, size, rawsize, compressed_size, *} \ -. 0, 0, 0, 0, 0, \ +. {* sec_flg5, vma, lma, size, rawsize, compressed_size, *} \ +. 0, 0, 0, 0, 0, 0, \ . \ . {* output_offset, output_section, relocation, orelocation, *} \ . 0, &SEC, NULL, NULL, \ Matthieu
On 13.10.2025 19:01, Matthieu Longo wrote: > On 2025-10-13 16:30, Jan Beulich wrote: >> On 13.10.2025 17:22, Matthieu Longo wrote: >>> On 2025-09-26 14:13, Jan Beulich wrote: >>>> On 18.09.2025 17:06, Matthieu Longo wrote: >>>>> --- a/bfd/bfd-in2.h >>>>> +++ b/bfd/bfd-in2.h >>>>> @@ -834,6 +834,12 @@ typedef struct bfd_section >>>>> const char *linked_to_symbol_name; >>>>> } map_head, map_tail; >>>>> >>>>> + /* Indicate that the section contains branch veneers. This is used when >>>>> + support for non-contiguous memory regions is enabled. The veneers have >>>>> + to be allocated to the same memory region as the code they are refered >>>>> + by, i.e. they cannot be moved to a subsequent memory region. */ >>>>> + bool veneer; >>>> >>>> Why would you put a bool between two pointer-sized fields, thus introducing >>>> yet more padding, when in fact existing padding could be used. There's a set >>>> of bitfields further up from here, and you could simply add a single-bit >>>> field there, for example. Generic code changes are okay with that change, >>>> but arch-specific ones will need arch maintainer approval. >>> >>> Here is the new attribute as a flag: >>> >>> diff --git a/bfd/section.c b/bfd/section.c >>> index 5f0cf6e71cb..f110ed77363 100644 >>> --- a/bfd/section.c >>> +++ b/bfd/section.c >>> @@ -379,6 +379,12 @@ CODE_FRAGMENT >>> . when memory read flag isn't set. *} >>> .#define SEC_COFF_NOREAD 0x40000000 >>> . >>> +. {* Indicate that the section contains branch veneers. This is used when >>> +. support for non-contiguous memory regions is enabled. The >>> veneers have >>> +. to be allocated to the same memory region as the code they are >>> refered >>> +. by, i.e. they cannot be moved to a subsequent memory region. *} >>> +.#define SEC_VENEER 0x80000000 >>> +. >>> . {* End of section flags. *} >>> . >>> . {* Some internal packed boolean fields. *} >>> >>> >>> With the tagging of the stub section on AArch64: >>> >>> diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em >>> index 91d58d8fe5a..b00c9460da2 100644 >>> --- a/ld/emultempl/aarch64elf.em >>> +++ b/ld/emultempl/aarch64elf.em >>> @@ -193,7 +193,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char >>> *stub_sec_name, >>> lang_output_section_statement_type *os; >>> struct hook_stub_info info; >>> >>> - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE >>> + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_VENEER >>> | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); >>> stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, >>> stub_sec_name, flags); >>> >>> Same thing on AArch32 and PowerPC. >>> >>> Is this what you suggested ? >> >> No, sorry. I said "bit field", not "section flag". I'd rather not see you >> use the last available section flag. Right below where you put the new >> #define is a comment "Some internal packed boolean fields" - that's where >> I thought your new flag would go. > > What about the below ? Yes, with one cosmetic request though: > diff --git a/bfd/section.c b/bfd/section.c > index 5f0cf6e71cb..424e53029d9 100644 > --- a/bfd/section.c > +++ b/bfd/section.c > @@ -428,6 +428,12 @@ CODE_FRAGMENT > . {* Nonzero if section contents should not be freed. *} > . unsigned int alloced:1; > . > +. {* Indicate that the section contains branch veneers. This is used when > +. support for non-contiguous memory regions is enabled. The > veneers have > +. to be allocated to the same memory region as the code they are > refered > +. by, i.e. they cannot be moved to a subsequent memory region. *} > +. unsigned int veneer : 1; > +. > . {* Bits used by various backends. The generic code doesn't touch > . these fields. *} > . > @@ -723,11 +729,11 @@ INTERNAL > . {* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced, > *} \ > . 0, 0, 0, 0, 0, \ > . \ > -. {* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, *} Please can these all stay on one line, while you ... > \ > +. {* veneer, sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, *} ... add a new line to put the new initializer on? (Overall the macro likely wants switching to C99 dedicated initializers, at which point the comments can all go away, as can the many 0s and NULL-s. But that's for another day, I guess.) Jan
On 2025-10-14 08:23, Jan Beulich wrote: > On 13.10.2025 19:01, Matthieu Longo wrote: >> On 2025-10-13 16:30, Jan Beulich wrote: >>> On 13.10.2025 17:22, Matthieu Longo wrote: >>>> On 2025-09-26 14:13, Jan Beulich wrote: >>>>> On 18.09.2025 17:06, Matthieu Longo wrote: >>>>>> --- a/bfd/bfd-in2.h >>>>>> +++ b/bfd/bfd-in2.h >>>>>> @@ -834,6 +834,12 @@ typedef struct bfd_section >>>>>> const char *linked_to_symbol_name; >>>>>> } map_head, map_tail; >>>>>> >>>>>> + /* Indicate that the section contains branch veneers. This is used when >>>>>> + support for non-contiguous memory regions is enabled. The veneers have >>>>>> + to be allocated to the same memory region as the code they are refered >>>>>> + by, i.e. they cannot be moved to a subsequent memory region. */ >>>>>> + bool veneer; >>>>> >>>>> Why would you put a bool between two pointer-sized fields, thus introducing >>>>> yet more padding, when in fact existing padding could be used. There's a set >>>>> of bitfields further up from here, and you could simply add a single-bit >>>>> field there, for example. Generic code changes are okay with that change, >>>>> but arch-specific ones will need arch maintainer approval. >>>> >>>> Here is the new attribute as a flag: >>>> >>>> diff --git a/bfd/section.c b/bfd/section.c >>>> index 5f0cf6e71cb..f110ed77363 100644 >>>> --- a/bfd/section.c >>>> +++ b/bfd/section.c >>>> @@ -379,6 +379,12 @@ CODE_FRAGMENT >>>> . when memory read flag isn't set. *} >>>> .#define SEC_COFF_NOREAD 0x40000000 >>>> . >>>> +. {* Indicate that the section contains branch veneers. This is used when >>>> +. support for non-contiguous memory regions is enabled. The >>>> veneers have >>>> +. to be allocated to the same memory region as the code they are >>>> refered >>>> +. by, i.e. they cannot be moved to a subsequent memory region. *} >>>> +.#define SEC_VENEER 0x80000000 >>>> +. >>>> . {* End of section flags. *} >>>> . >>>> . {* Some internal packed boolean fields. *} >>>> >>>> >>>> With the tagging of the stub section on AArch64: >>>> >>>> diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em >>>> index 91d58d8fe5a..b00c9460da2 100644 >>>> --- a/ld/emultempl/aarch64elf.em >>>> +++ b/ld/emultempl/aarch64elf.em >>>> @@ -193,7 +193,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char >>>> *stub_sec_name, >>>> lang_output_section_statement_type *os; >>>> struct hook_stub_info info; >>>> >>>> - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE >>>> + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_VENEER >>>> | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); >>>> stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, >>>> stub_sec_name, flags); >>>> >>>> Same thing on AArch32 and PowerPC. >>>> >>>> Is this what you suggested ? >>> >>> No, sorry. I said "bit field", not "section flag". I'd rather not see you >>> use the last available section flag. Right below where you put the new >>> #define is a comment "Some internal packed boolean fields" - that's where >>> I thought your new flag would go. >> >> What about the below ? > > Yes, with one cosmetic request though: > >> diff --git a/bfd/section.c b/bfd/section.c >> index 5f0cf6e71cb..424e53029d9 100644 >> --- a/bfd/section.c >> +++ b/bfd/section.c >> @@ -428,6 +428,12 @@ CODE_FRAGMENT >> . {* Nonzero if section contents should not be freed. *} >> . unsigned int alloced:1; >> . >> +. {* Indicate that the section contains branch veneers. This is used when >> +. support for non-contiguous memory regions is enabled. The >> veneers have >> +. to be allocated to the same memory region as the code they are >> refered >> +. by, i.e. they cannot be moved to a subsequent memory region. *} >> +. unsigned int veneer : 1; >> +. >> . {* Bits used by various backends. The generic code doesn't touch >> . these fields. *} >> . >> @@ -723,11 +729,11 @@ INTERNAL >> . {* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced, >> *} \ >> . 0, 0, 0, 0, 0, \ >> . \ >> -. {* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, *} > > Please can these all stay on one line, while you ... > >> \ >> +. {* veneer, sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, *} > > ... add a new line to put the new initializer on? (Overall the macro likely > wants switching to C99 dedicated initializers, at which point the comments > can all go away, as can the many 0s and NULL-s. But that's for another day, > I guess.) > > Jan Fixed in the next revision. Matthieu
On 2025-10-14 11:38, Matthieu Longo wrote: > On 2025-10-14 08:23, Jan Beulich wrote: >> On 13.10.2025 19:01, Matthieu Longo wrote: >>> On 2025-10-13 16:30, Jan Beulich wrote: >>>> On 13.10.2025 17:22, Matthieu Longo wrote: >>>>> On 2025-09-26 14:13, Jan Beulich wrote: >>>>>> On 18.09.2025 17:06, Matthieu Longo wrote: >>>>>>> --- a/bfd/bfd-in2.h >>>>>>> +++ b/bfd/bfd-in2.h >>>>>>> @@ -834,6 +834,12 @@ typedef struct bfd_section >>>>>>> const char *linked_to_symbol_name; >>>>>>> } map_head, map_tail; >>>>>>> + /* Indicate that the section contains branch veneers. This is >>>>>>> used when >>>>>>> + support for non-contiguous memory regions is enabled. The >>>>>>> veneers have >>>>>>> + to be allocated to the same memory region as the code they >>>>>>> are refered >>>>>>> + by, i.e. they cannot be moved to a subsequent memory >>>>>>> region. */ >>>>>>> + bool veneer; >>>>>> >>>>>> Why would you put a bool between two pointer-sized fields, thus >>>>>> introducing >>>>>> yet more padding, when in fact existing padding could be used. >>>>>> There's a set >>>>>> of bitfields further up from here, and you could simply add a >>>>>> single-bit >>>>>> field there, for example. Generic code changes are okay with that >>>>>> change, >>>>>> but arch-specific ones will need arch maintainer approval. >>>>> >>>>> Here is the new attribute as a flag: >>>>> >>>>> diff --git a/bfd/section.c b/bfd/section.c >>>>> index 5f0cf6e71cb..f110ed77363 100644 >>>>> --- a/bfd/section.c >>>>> +++ b/bfd/section.c >>>>> @@ -379,6 +379,12 @@ CODE_FRAGMENT >>>>> . when memory read flag isn't set. *} >>>>> .#define SEC_COFF_NOREAD 0x40000000 >>>>> . >>>>> +. {* Indicate that the section contains branch veneers. This is >>>>> used when >>>>> +. support for non-contiguous memory regions is enabled. The >>>>> veneers have >>>>> +. to be allocated to the same memory region as the code they are >>>>> refered >>>>> +. by, i.e. they cannot be moved to a subsequent memory >>>>> region. *} >>>>> +.#define SEC_VENEER 0x80000000 >>>>> +. >>>>> . {* End of section flags. *} >>>>> . >>>>> . {* Some internal packed boolean fields. *} >>>>> >>>>> >>>>> With the tagging of the stub section on AArch64: >>>>> >>>>> diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em >>>>> index 91d58d8fe5a..b00c9460da2 100644 >>>>> --- a/ld/emultempl/aarch64elf.em >>>>> +++ b/ld/emultempl/aarch64elf.em >>>>> @@ -193,7 +193,7 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char >>>>> *stub_sec_name, >>>>> lang_output_section_statement_type *os; >>>>> struct hook_stub_info info; >>>>> >>>>> - flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE >>>>> + flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | >>>>> SEC_VENEER >>>>> | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | >>>>> SEC_KEEP); >>>>> stub_sec = bfd_make_section_anyway_with_flags (stub_file- >>>>> >the_bfd, >>>>> stub_sec_name, >>>>> flags); >>>>> >>>>> Same thing on AArch32 and PowerPC. >>>>> >>>>> Is this what you suggested ? >>>> >>>> No, sorry. I said "bit field", not "section flag". I'd rather not >>>> see you >>>> use the last available section flag. Right below where you put the new >>>> #define is a comment "Some internal packed boolean fields" - that's >>>> where >>>> I thought your new flag would go. >>> >>> What about the below ? >> >> Yes, with one cosmetic request though: >> >>> diff --git a/bfd/section.c b/bfd/section.c >>> index 5f0cf6e71cb..424e53029d9 100644 >>> --- a/bfd/section.c >>> +++ b/bfd/section.c >>> @@ -428,6 +428,12 @@ CODE_FRAGMENT >>> . {* Nonzero if section contents should not be freed. *} >>> . unsigned int alloced:1; >>> . >>> +. {* Indicate that the section contains branch veneers. This is >>> used when >>> +. support for non-contiguous memory regions is enabled. The >>> veneers have >>> +. to be allocated to the same memory region as the code they are >>> refered >>> +. by, i.e. they cannot be moved to a subsequent memory region. *} >>> +. unsigned int veneer : 1; >>> +. >>> . {* Bits used by various backends. The generic code doesn't touch >>> . these fields. *} >>> . >>> @@ -723,11 +729,11 @@ INTERNAL >>> . {* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced, >>> *} \ >>> . 0, 0, 0, 0, >>> 0, \ >>> . \ >>> -. {* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, *} >> >> Please can these all stay on one line, while you ... >> >>> \ >>> +. {* veneer, sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, *} >> >> ... add a new line to put the new initializer on? (Overall the macro >> likely >> wants switching to C99 dedicated initializers, at which point the >> comments >> can all go away, as can the many 0s and NULL-s. But that's for another >> day, >> I guess.) >> >> Jan > > Fixed in the next revision. > > Matthieu Sorry Jan, I sent the new revision but forgot to add you in CC. Matthieu
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 5e7c6ddf1ee..a4049fa0e98 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -834,6 +834,12 @@ typedef struct bfd_section const char *linked_to_symbol_name; } map_head, map_tail; + /* Indicate that the section contains branch veneers. This is used when + support for non-contiguous memory regions is enabled. The veneers have + to be allocated to the same memory region as the code they are refered + by, i.e. they cannot be moved to a subsequent memory region. */ + bool veneer; + /* Points to the output section this section is already assigned to, if any. This is used when support for non-contiguous memory regions is enabled. */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index f2485d99078..df9d5c8cc19 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -3694,8 +3694,8 @@ bool _bfd_unrecognized_reloc /* symbol, */ \ (struct bfd_symbol *) SYM, \ \ - /* map_head, map_tail, already_assigned, type */ \ - { NULL }, { NULL }, NULL, 0 \ + /* map_head, map_tail, veneer, already_assigned, type */ \ + { NULL }, { NULL }, false, NULL, 0 \ \ } diff --git a/bfd/section.c b/bfd/section.c index 5f0cf6e71cb..33524762e7a 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -560,6 +560,12 @@ CODE_FRAGMENT . const char *linked_to_symbol_name; . } map_head, map_tail; . +. {* Indicate that the section contains branch veneers. This is used when +. support for non-contiguous memory regions is enabled. The veneers have +. to be allocated to the same memory region as the code they are refered +. by, i.e. they cannot be moved to a subsequent memory region. *} +. bool veneer; +. . {* Points to the output section this section is already assigned to, . if any. This is used when support for non-contiguous memory . regions is enabled. *} @@ -747,8 +753,8 @@ INTERNAL . {* symbol, *} \ . (struct bfd_symbol *) SYM, \ . \ -. {* map_head, map_tail, already_assigned, type *} \ -. { NULL }, { NULL }, NULL, 0 \ +. {* map_head, map_tail, veneer, already_assigned, type *} \ +. { NULL }, { NULL }, false, NULL, 0 \ . \ . } . diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em index 91d58d8fe5a..08f5c4c7d58 100644 --- a/ld/emultempl/aarch64elf.em +++ b/ld/emultempl/aarch64elf.em @@ -200,6 +200,8 @@ elf${ELFSIZE}_aarch64_add_stub_section (const char *stub_sec_name, if (stub_sec == NULL) goto err_ret; + stub_sec->veneer = true; + /* Long branch stubs contain a 64-bit address, so the section requires 8 byte alignment. */ bfd_set_section_alignment (stub_sec, 3); diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em index 6f652c59a3c..d946f096faa 100644 --- a/ld/emultempl/armelf.em +++ b/ld/emultempl/armelf.em @@ -237,13 +237,14 @@ elf32_arm_add_stub_section (const char * stub_sec_name, struct hook_stub_info info; flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE - | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP - | SEC_LINKER_CREATED); + | SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP); stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd, stub_sec_name, flags); if (stub_sec == NULL) goto err_ret; + stub_sec->veneer = true; + bfd_set_section_alignment (stub_sec, alignment_power); os = lang_output_section_get (output_section); diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index 857cf54ad06..8e3f60cb12a 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -440,6 +440,8 @@ ppc_add_stub_section (const char *stub_sec_name, asection *input_section) : 5))) goto err_ret; + stub_sec->veneer = true; + output_section = input_section->output_section; os = lang_output_section_get (output_section); diff --git a/ld/ldlang.c b/ld/ldlang.c index 3c57bf7541c..bdda599a7a4 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -5637,10 +5637,12 @@ size_input_section if (dot + TO_ADDR (i->size) > end) { - if (i->flags & SEC_LINKER_CREATED) - fatal (_("%P: Output section `%pA' not large enough for " - "the linker-created stubs section `%pA'.\n"), - i->output_section, i); + if (i->veneer) + fatal (_("%P: Memory region `%s' not large enough for the " + "linker-created stubs section `%pA' associated to " + "output section `%pA'\n"), + output_section_statement->region->name_list.name, i, + i->output_section); if (i->rawsize && i->rawsize != i->size) fatal (_("%P: Relaxation not supported with " @@ -8239,8 +8241,7 @@ warn_non_contiguous_discards (void) continue; for (asection *s = file->the_bfd->sections; s != NULL; s = s->next) - if (s->output_section == NULL - && (s->flags & SEC_LINKER_CREATED) == 0) + if (s->output_section == NULL && !s->veneer) einfo (_("%P: warning: --enable-non-contiguous-regions " "discards section `%pA' from `%pB'\n"), s, file->the_bfd); diff --git a/ld/testsuite/ld-arm/non-contiguous-arm4.d b/ld/testsuite/ld-arm/non-contiguous-arm4.d index a8e9d66caca..d4c4b284dce 100644 --- a/ld/testsuite/ld-arm/non-contiguous-arm4.d +++ b/ld/testsuite/ld-arm/non-contiguous-arm4.d @@ -1,4 +1,4 @@ #name: non-contiguous-arm4 #source: non-contiguous-arm.s #ld: --enable-non-contiguous-regions -T non-contiguous-arm4.ld -# error: .*Output section .?\.ramu.? not large enough for the linker-created stubs section .?\.code\.3\.__stub.\.? +# error: Memory region `RAMU' not large enough for the linker-created stubs section `\.code\.3\.__stub' associated to output section `\.ramu' diff --git a/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d b/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d index 9f903bbea35..1a7e4c5a23b 100644 --- a/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d +++ b/ld/testsuite/ld-powerpc/non-contiguous-powerpc64.d @@ -2,4 +2,4 @@ #source: non-contiguous-powerpc.s #as: -a64 #ld: -melf64ppc --enable-non-contiguous-regions -T non-contiguous-powerpc.ld -#error: .*Could not assign .?\.text\.one\.stub.? to an output section\. Retry without --enable-non-contiguous-regions\. +#error: Memory region `one' not large enough for the linker-created stubs section `\.text\.one\.stub' associated to output section `one'