From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130047.outbound.protection.outlook.com [40.107.13.47]) by sourceware.org (Postfix) with ESMTPS id 022CF3857830 for ; Thu, 31 Mar 2022 14:05:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 022CF3857830 Received: from AS8PR05CA0006.eurprd05.prod.outlook.com (2603:10a6:20b:311::11) by VI1PR08MB3198.eurprd08.prod.outlook.com (2603:10a6:803:49::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Thu, 31 Mar 2022 14:05:21 +0000 Received: from VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:311:cafe::2c) by AS8PR05CA0006.outlook.office365.com (2603:10a6:20b:311::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.21 via Frontend Transport; Thu, 31 Mar 2022 14:05:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT047.mail.protection.outlook.com (10.152.19.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 14:05:19 +0000 Received: ("Tessian outbound ac9bb5dd84f6:v118"); Thu, 31 Mar 2022 14:05:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 80a9f82288c20bc6 X-CR-MTA-TID: 64aa7808 Received: from 9fddcb9eb973.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 77A6A81F-2DEC-4002-B039-3760575F49BC.1; Thu, 31 Mar 2022 14:05:12 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9fddcb9eb973.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 31 Mar 2022 14:05:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ilUiBwE9OAkXefY/vEsiQK98zpty7Nrdl3nmjkkt7E8MtutOxhmLUQC4gDIL46eK0RRwi22qKMaJ6FsFml8C7sKKUcRoh6Z0wAkafLxwUNeble5Hce+YlFUUfPP7MlHB5msOZz1LCZxWyKB2vY/hqIk+0Y0zzFBBku22EYExS6s6PcQyFiBWziNlLSZEVqho7EwEkx4xFyOnVqrGkZFWduEm2Z7yraoWWHscswYTFI/l6CrBFWrTK+HvgEAugiKGeSjsck3NVOoZAr4qACs3rw5ntj7BBZRTuBFM/NiczzxTgZf/cQ7DZ/lakyhARJG5Cmu1JbTrPaahvudrC+SM4Q== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zEBRXtiM5Z/uTEr3T+cCKkE0p6UGQL+rHiUOH0wglw4=; b=IGJATVOE5em42oM0MWCfnfnJU87DJ8h3byuRWCKHEkxmJJnFy5U1SwoqKbRxR/nbB3fzcSrOi/BttYBw+Sw8Sm9ryQxM6Ki721ITrZFsrVDoDY7evzRrrds2mdtIYYcUNjRlNmpPjdE+pvO6ZTI+WNHa1lA76jHrSpjm6h9vkWkzqpeA4zzIsW5oPVK7+OmzHX1eO8qD/w2LcPpanSDBU8y1t4X3fJlRgtPUpyQWD5QubHAqdvc+eI3qUviormbeWfwQA2stM4reBqsoG2ZnjTS0y8ACIRbieGJl4nMM8+DUveqoJfsBfCGcBlWcWawB9qG0ufF0S3RSHRWZrh2CTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) 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 Received: from AM6PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:6e::22) by AS8PR08MB6646.eurprd08.prod.outlook.com (2603:10a6:20b:350::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Thu, 31 Mar 2022 14:05:09 +0000 Received: from VE1EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:6e:cafe::7d) by AM6PR02CA0009.outlook.office365.com (2603:10a6:20b:6e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.22 via Frontend Transport; Thu, 31 Mar 2022 14:05:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) 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 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT012.mail.protection.outlook.com (10.152.18.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 14:05:08 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 31 Mar 2022 14:05:04 +0000 Received: from e129171.cambridge.arm.com (10.2.80.38) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Thu, 31 Mar 2022 14:05:04 +0000 From: Luis Machado To: Subject: Support AArch64 MTE memory tag dumps in core files Date: Thu, 31 Mar 2022 15:04:57 +0100 Message-ID: <20220331140457.9237-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: b045e825-de2c-484e-6573-08da131f7d3c X-MS-TrafficTypeDiagnostic: AS8PR08MB6646:EE_|VE1EUR03FT047:EE_|VI1PR08MB3198:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ucjsm7QhVXSEje7h14IGjsBUtCckIZs+Q4v81i1lKDzX23izsp10M9m6ck5hwW1STVPv0FyrLYD6JwHuPvc3CFE4UX7+UoHjyIQKRYZ7QGrnT87UHTGkYhiDPW3gzrrC0YMb9s52yJg6SiRY8MXyHwdu2C8WaLVLTHMeb8mdVS2KScn4FtzRiUNeZHd5UXrizNMEuD8A2D0M2y3myDmlI5GNPMOsm0KBZHUPio+eVNE3vdE/zpIBowHAVZiAssSvaHP/c4dXrqfCC6Os1q8WNYkyGHAF6AdmswuylwEyg1LA1gY1ZLzCpgpiLSY40ykgDbsMJJoJoIG07X5F5PRfVvObHEewVpeiNOduIW28BGayRrhwNMEaLolJgmY1kejgJjGq9c0DPdR5O9JfMcFHYlI6KkPYoaUZStHJK4D1hIkqITQUx2yWu9iNqFQd6SyMclzA+mbDCQAvesNux8WPwO7cHjy2CCKvONmdetmYe8OQGovtPKb2EeJp/q9NsTn7PLtjk0wGKhIvtOnR3kFtTElsD7cbBF06bbALVsrKOCTxUC/0ZodNU85IK8LUrqyJD28mle9on1l6nPqpvOv4CPw90XcMvNIRBDQI32zfrLRXKRDWtLsGoEap1f1JiwWnnfJzNmdAMTd17GISnQAHRadB/TeKiCTcokBMT2bjtbYG0MmmTBCmC8Mz3SVdm7yyMsLr2PTKhUbhwW7GNHsFjA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(36756003)(40460700003)(508600001)(5660300002)(356005)(81166007)(83380400001)(36860700001)(6916009)(316002)(26005)(426003)(2616005)(1076003)(82310400004)(8936002)(336012)(7696005)(186003)(6666004)(8676002)(44832011)(2906002)(47076005)(70586007)(86362001)(70206006)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6646 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a44f5d5e-dfd6-4fe0-4780-08da131f7727 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1uS+FPxm3J51PkyhiQglevdQehdeIxzq2gDGczDe4WNCEdJmJRbnRIZd4Ia/v2uj59BwSKwzcU/s9VHIyPZWX1zRnCOiQISAiPmYW5AEMAyabTl8VqGiQ0GXsNbpRNnMwx2iwEN6+QtbJVtTA74SOHZvZUWlxO0MijHPTaNJJI4FjGb0/5zDU8UtvXbhbK1yz+wB1KM4pR7oydg7UbhU10dGMgnIrqloQ4vUzKNlIEMt8rMwR4NMeuxYy8B0QnBXKSHJpcnWS3IuJshYC9EcABYulwV1BeXdN6dYQh3wUNkMSlzv123NNsdTrrGa0E1HSwjozNLyXropDly3cHUfgiip8FfT6Rip/HIwQ8s9fMm/GAvNs9goJp040Ah91XBpNg8gh/qzA9eNHu/s3JbaPYzBDFppD3zXY8XqtqzKIID6qtRPrNuojWqk/rd3RHm3rv0l3L/AbFb45/5VXQfVs89sQ0lmJxBzqWmf/pXtiKjVRFEF3ZEKpBXF76MIwsucCAkol7QabkdOSWowVSoLirkU8bEoa3uDrEzdac487D0nZStn1Ne/IXoL/aGPuHrYY8l94EInOJZ8vOVhNVGA1e+9ocBtymT1XbTI627ks8pTI6iCqKxzqz/EkwjR+UTyt8PS71IS+O1ew77phg8gfSUq3znQ8JOgDgR+MyyfBqkO0T36rPkG9kYac3gK0P+1 X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(316002)(36756003)(81166007)(2906002)(6666004)(86362001)(83380400001)(7696005)(6916009)(5660300002)(8936002)(36860700001)(47076005)(70206006)(44832011)(40460700003)(2616005)(26005)(336012)(1076003)(82310400004)(186003)(426003)(508600001)(70586007)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 14:05:19.0964 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b045e825-de2c-484e-6573-08da131f7d3c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3198 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2022 14:05:28 -0000 The Linux kernel can dump memory tag segments to a core file, one segment per mapped range. The format and documentation can be found in the Linux kernel tree [1]. The following patch adjusts bfd and binutils see they can handle this new segment type and display it accordingly. It also adds code required so GDB can properly read/dump core file data containing memory tags. Upon reading, each segment that contains memory tags gets mapped to a .memtag section. These sections will be used by GDB to lookup the tag data. There is another patch for GDB that enables both reading and dumping of memory tag segments. Given sections based on segments are numbered, I had to update the code to not number the memory tag ones. This simplifies GDB's lookup of the memory tag sections. Tested on aarch64-linux Ubuntu 20.04. [1] Documentation/arm64/memory-tagging-extension.rst (Core Dump Support) --- bfd/bfd-in2.h | 19 +++++++--- bfd/elf-bfd.h | 2 ++ bfd/elf.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ bfd/section.c | 24 +++++++++---- binutils/readelf.c | 1 + include/elf/common.h | 5 +++ 6 files changed, 123 insertions(+), 10 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index c0b563aec02..0e5e7104555 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1027,6 +1027,9 @@ typedef struct bfd_section /* Nonzero if this section uses RELA relocations, rather than REL. */ unsigned int use_rela_p:1; + /* Nonzero if this section contains memory tag data. Default is 0. */ + unsigned int has_memory_tags : 1; + /* Bits used by various backends. The generic code doesn't touch these fields. */ @@ -1070,6 +1073,11 @@ typedef struct bfd_section /* The compressed size of the section in octets. */ bfd_size_type compressed_size; + /* If HAS_MEMORY_TAGS is true, MEMORY_TAGS_RANGE_SIZE is the original memory + range size, in octets, of the memory that contained the tags stored in this + section. SIZE is the size of the packed tags from that memory range. */ + bfd_size_type memory_tags_range_size; + /* Relaxation table. */ struct relax_table *relax; @@ -1330,14 +1338,17 @@ discarded_section (const asection *sec) /* linker_mark, linker_has_input, gc_mark, decompress_status, */ \ 0, 0, 1, 0, \ \ - /* segment_mark, sec_info_type, use_rela_p, */ \ - 0, 0, 0, \ + /* segment_mark, sec_info_type, use_rela_p, has_memory_tags, */ \ + 0, 0, 0, 0, \ \ /* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, */ \ 0, 0, 0, 0, 0, 0, \ \ - /* vma, lma, size, rawsize, compressed_size, relax, relax_count, */ \ - 0, 0, 0, 0, 0, 0, 0, \ + /* vma, lma, size, rawsize, compressed_size, */ \ + 0, 0, 0, 0, 0, \ + \ + /* memory_tags_range_size, relax, relax_count, */ \ + 0, 0, 0, \ \ /* output_offset, output_section, alignment_power, */ \ 0, &SEC, 0, \ diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 5c3985f6e57..dc4c4faea7e 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2227,6 +2227,8 @@ extern bool bfd_elf_mkcorefile (bfd *); extern bool _bfd_elf_make_section_from_shdr (bfd *, Elf_Internal_Shdr *, const char *, int); +extern bool _bfd_elf_make_memtag_section_from_phdr + (bfd *, Elf_Internal_Phdr *); extern bool _bfd_elf_make_section_from_phdr (bfd *, Elf_Internal_Phdr *, int, const char *); extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc diff --git a/bfd/elf.c b/bfd/elf.c index 82b53be99f9..422f0f50151 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1629,10 +1629,30 @@ _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd) return true; } +/* Given P_TYPE, return TRUE if it represents a memory tag type. Otherwise + return false. */ + +static bool +is_memory_tag_p_type (unsigned int p_type) +{ + switch (p_type) + { + case PT_ARM_MEMTAG_MTE: + return true; + default: + return false; + } +} + static const char * get_segment_type (unsigned int p_type) { const char *pt; + + /* Handle memory tag p_type's first. */ + if (is_memory_tag_p_type (p_type)) + return "MEMTAG"; + switch (p_type) { case PT_NULL: pt = "NULL"; break; @@ -2896,6 +2916,47 @@ _bfd_elf_new_section_hook (bfd *abfd, asection *sec) return _bfd_generic_new_section_hook (abfd, sec); } +/* Create a new bfd section for a memory tag ELF segment. + + The name of the section is "memtag" and there can be multiple such + sections. */ + +bool +_bfd_elf_make_memtag_section_from_phdr (bfd *abfd, + Elf_Internal_Phdr *hdr) +{ + asection *newsect; + unsigned int opb = bfd_octets_per_byte (abfd, NULL); + + if (!is_memory_tag_p_type (hdr->p_type)) + return false; + + if (hdr->p_filesz > 0) + { + /* Sections created from memory tag p_type's are always named + "memtag". */ + newsect = bfd_make_section_anyway (abfd, "memtag"); + + if (newsect == NULL) + return false; + + /* p_vaddr holds the original start address of the tagged memory + range. */ + newsect->vma = hdr->p_vaddr / opb; + + /* p_filesz holds the storage size of the packed tags. */ + newsect->size = hdr->p_filesz; + newsect->filepos = hdr->p_offset; + + /* Set the memory tags range size to the original length of the tagged + memory range. */ + newsect->has_memory_tags = 1; + newsect->memory_tags_range_size = hdr->p_memsz; + } + + return true; +} + /* Create a new bfd section from an ELF program header. Since program segments have no names, we generate a synthetic name @@ -3018,6 +3079,10 @@ bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int hdr_index) { const struct elf_backend_data *bed; + /* Handle memory tag p_type's first. */ + if (is_memory_tag_p_type (hdr->p_type)) + return _bfd_elf_make_memtag_section_from_phdr (abfd, hdr); + switch (hdr->p_type) { case PT_NULL: @@ -5896,6 +5961,23 @@ assign_file_positions_for_load_sections (bfd *abfd, p->p_filesz += adjust; } + /* For memory tag sections, the content size is smaller than the + size of the memory range. Adjust the file size and memory + size accordingly. */ + if (is_memory_tag_p_type (p->p_type) + && bfd_get_format (abfd) == bfd_core) + { + if (m->count > 0) + { + /* The storage size of tags in the section is usually much + smaller than the memory range size of the memory the tags + cover, so we need to adjust the file size and memory size + fields. */ + asection *memtag_section = m->sections[0]; + p->p_memsz = memtag_section->memory_tags_range_size; + } + } + if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core) { /* The section at i == 0 is the one that actually contains diff --git a/bfd/section.c b/bfd/section.c index 9a1071454f5..e8c7caf9dd4 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -412,6 +412,9 @@ CODE_FRAGMENT . {* Nonzero if this section uses RELA relocations, rather than REL. *} . unsigned int use_rela_p:1; . +. {* Nonzero if this section contains memory tag data. Default is 0. *} +. unsigned int has_memory_tags : 1; +. . {* Bits used by various backends. The generic code doesn't touch . these fields. *} . @@ -455,6 +458,11 @@ CODE_FRAGMENT . {* The compressed size of the section in octets. *} . bfd_size_type compressed_size; . +. {* If HAS_MEMORY_TAGS is true, MEMORY_TAGS_RANGE_SIZE is the original memory +. range size, in octets, of the memory that contained the tags stored in this +. section. SIZE is the size of the packed tags from that memory range. *} +. bfd_size_type memory_tags_range_size; +. . {* Relaxation table. *} . struct relax_table *relax; . @@ -715,14 +723,17 @@ CODE_FRAGMENT . {* linker_mark, linker_has_input, gc_mark, decompress_status, *} \ . 0, 0, 1, 0, \ . \ -. {* segment_mark, sec_info_type, use_rela_p, *} \ -. 0, 0, 0, \ +. {* segment_mark, sec_info_type, use_rela_p, has_memory_tags, *} \ +. 0, 0, 0, 0, \ . \ . {* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, *} \ . 0, 0, 0, 0, 0, 0, \ . \ -. {* vma, lma, size, rawsize, compressed_size, relax, relax_count, *} \ -. 0, 0, 0, 0, 0, 0, 0, \ +. {* vma, lma, size, rawsize, compressed_size, *} \ +. 0, 0, 0, 0, 0, \ +. \ +. {* memory_tags_range_size, relax, relax_count, *} \ +. 0, 0, 0, \ . \ . {* output_offset, output_section, alignment_power, *} \ . 0, &SEC, 0, \ @@ -1499,7 +1510,8 @@ bfd_set_section_contents (bfd *abfd, { bfd_size_type sz; - if (!(bfd_section_flags (section) & SEC_HAS_CONTENTS)) + if (!section->has_memory_tags + && !(bfd_section_flags (section) & SEC_HAS_CONTENTS)) { bfd_set_error (bfd_error_no_contents); return false; @@ -1588,7 +1600,7 @@ bfd_get_section_contents (bfd *abfd, /* Don't bother. */ return true; - if ((section->flags & SEC_HAS_CONTENTS) == 0) + if (!section->has_memory_tags && (section->flags & SEC_HAS_CONTENTS) == 0) { memset (location, 0, (size_t) count); return true; diff --git a/binutils/readelf.c b/binutils/readelf.c index a2dbaa4722e..ae1399c0577 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -4499,6 +4499,7 @@ get_aarch64_segment_type (unsigned long type) switch (type) { case PT_AARCH64_ARCHEXT: return "AARCH64_ARCHEXT"; + case PT_ARM_MEMTAG_MTE: return "ARM_MEMTAG_MTE"; default: return NULL; } } diff --git a/include/elf/common.h b/include/elf/common.h index 70d63e3299c..5a682e3bde7 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -500,6 +500,11 @@ #define PT_GNU_MBIND_LO (PT_LOOS + 0x474e555) #define PT_GNU_MBIND_HI (PT_GNU_MBIND_LO + PT_GNU_MBIND_NUM - 1) +/* ARM memory tag segment types. */ + +/* MTE memory tag segment type. */ +#define PT_ARM_MEMTAG_MTE (PT_LOPROC + 0x1) + /* Program segment permissions, in program header p_flags field. */ #define PF_X (1 << 0) /* Segment is executable */ -- 2.25.1