Skip to content

Commit 11955a9

Browse files
committed
ICU-23269 Add PAC/BTI tags to generated aarch64 assembler data
Background: PAC and BTI are branch and pointer authentication technologies for aarch64: https://developer.arm.com/community/arm-community-blogs/b/architectures-and-processors-blog/posts/enabling-pac-and-bti-on-aarch64 For PAC/BTI to be used at runtime, all of the ELF segments loaded need to confirm that they're compatible. If given the right options both GCC and Clang automatically generate code that is compatible and add the annotations. However, if data files are built into binary objects with tools/gen* using assembler, then these tags are not present and all of ICU cannot use branch protection or pointer authentication. As the generated assembler is literally only data, we can just add the tags. This is similar to how Intel CET is enabled in the same file.
1 parent 1659052 commit 11955a9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (C) 2025 and later: Unicode, Inc. and others.
2+
// License & terms of use: http://www.unicode.org/copyright.html
3+
4+
/* Add BTI/PAC/GCS tags to GNU Notes section */
5+
#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
6+
#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
7+
#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0)
8+
#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1)
9+
#define GNU_PROPERTY_AARCH64_FEATURE_1_GCS (1U << 2)
10+
11+
.pushsection .note.gnu.property, "a"; /* Start a new allocatable section */
12+
.balign 8; /* align it on a byte boundry */
13+
.long 4; /* size of "GNU\0" */
14+
.long 0x10; /* size of descriptor */
15+
.long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */
16+
.asciz "GNU";
17+
.long GNU_PROPERTY_AARCH64_FEATURE_1_AND;
18+
.long 4; /* Four bytes of data */
19+
.long GNU_PROPERTY_AARCH64_FEATURE_1_BTI | GNU_PROPERTY_AARCH64_FEATURE_1_PAC | GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
20+
.long 0; /* padding for 8 byte alignment */
21+
.popsection; /* end the section */
22+
#endif

icu4c/source/tools/toolutil/pkg_genc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ static const struct AssemblyType {
137137
"#ifdef __CET__\n"
138138
"# include <cet.h>\n"
139139
"#endif\n"
140+
"#ifdef __aarch64__\n"
141+
"#include \"../tools/toolutil/aarch64.h\"\n"
142+
"#endif\n"
140143
"\t.section .rodata\n"
141144
"\t.balign 16\n"
142145
"#ifdef U_HIDE_DATA_SYMBOL\n"

0 commit comments

Comments
 (0)