@@ -58,8 +58,17 @@ void AArch64TargetStreamer::finish() {
58
58
emitNoteSection (ELF::GNU_PROPERTY_AARCH64_FEATURE_1_BTI);
59
59
}
60
60
61
- void AArch64TargetStreamer::emitNoteSection (unsigned Flags) {
62
- if (Flags == 0 )
61
+ void AArch64TargetStreamer::emitNoteSection (unsigned Flags,
62
+ uint64_t PAuthABIPlatform,
63
+ uint64_t PAuthABIVersion) {
64
+ assert ((PAuthABIPlatform == uint64_t (-1 )) ==
65
+ (PAuthABIVersion == uint64_t (-1 )));
66
+ uint64_t DescSz = 0 ;
67
+ if (Flags != 0 )
68
+ DescSz += 4 * 4 ;
69
+ if (PAuthABIPlatform != uint64_t (-1 ))
70
+ DescSz += 4 + 4 + 8 * 2 ;
71
+ if (DescSz == 0 )
63
72
return ;
64
73
65
74
MCStreamer &OutStreamer = getStreamer ();
@@ -80,15 +89,25 @@ void AArch64TargetStreamer::emitNoteSection(unsigned Flags) {
80
89
// Emit the note header.
81
90
OutStreamer.emitValueToAlignment (Align (8 ));
82
91
OutStreamer.emitIntValue (4 , 4 ); // data size for "GNU\0"
83
- OutStreamer.emitIntValue (4 * 4 , 4 ); // Elf_Prop size
92
+ OutStreamer.emitIntValue (DescSz , 4 ); // Elf_Prop array size
84
93
OutStreamer.emitIntValue (ELF::NT_GNU_PROPERTY_TYPE_0, 4 );
85
94
OutStreamer.emitBytes (StringRef (" GNU" , 4 )); // note name
86
95
87
96
// Emit the PAC/BTI properties.
88
- OutStreamer.emitIntValue (ELF::GNU_PROPERTY_AARCH64_FEATURE_1_AND, 4 );
89
- OutStreamer.emitIntValue (4 , 4 ); // data size
90
- OutStreamer.emitIntValue (Flags, 4 ); // data
91
- OutStreamer.emitIntValue (0 , 4 ); // pad
97
+ if (Flags != 0 ) {
98
+ OutStreamer.emitIntValue (ELF::GNU_PROPERTY_AARCH64_FEATURE_1_AND, 4 );
99
+ OutStreamer.emitIntValue (4 , 4 ); // data size
100
+ OutStreamer.emitIntValue (Flags, 4 ); // data
101
+ OutStreamer.emitIntValue (0 , 4 ); // pad
102
+ }
103
+
104
+ // Emit the PAuth ABI compatibility info
105
+ if (PAuthABIPlatform != uint64_t (-1 )) {
106
+ OutStreamer.emitIntValue (ELF::GNU_PROPERTY_AARCH64_FEATURE_PAUTH, 4 );
107
+ OutStreamer.emitIntValue (8 * 2 , 4 ); // data size
108
+ OutStreamer.emitIntValue (PAuthABIPlatform, 8 );
109
+ OutStreamer.emitIntValue (PAuthABIVersion, 8 );
110
+ }
92
111
93
112
OutStreamer.endSection (Nt);
94
113
OutStreamer.switchSection (Cur);
0 commit comments