Skip to content

Commit d7cbfcf

Browse files
committed
[ELF][AArch64] Fix potentially corrupted section content for PAC
D74537 introduced a bug: if `(config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_PAC) != 0` with -z pac-plt unspecified, we incorrectly use AArch64BtiPac, whose writePlt will make out-of-bounds write after the .plt section. This is often benign because the output section after .plt will usually overwrite the content. This is very difficult to test without D131247 (Parallelize writes of different OutputSections).
1 parent e89d6d2 commit d7cbfcf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lld/ELF/Arch/AArch64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,8 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
884884
}
885885

886886
static TargetInfo *getTargetInfo() {
887-
if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI |
888-
GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
887+
if ((config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ||
888+
config->zPacPlt) {
889889
static AArch64BtiPac t;
890890
return &t;
891891
}

0 commit comments

Comments
 (0)