Skip to content

Commit bf27137

Browse files
MaskRaytstellar
authored andcommitted
[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). (cherry picked from commit d7cbfcf)
1 parent 9383f82 commit bf27137

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
@@ -873,8 +873,8 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
873873
}
874874

875875
static TargetInfo *getTargetInfo() {
876-
if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI |
877-
GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
876+
if ((config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ||
877+
config->zPacPlt) {
878878
static AArch64BtiPac t;
879879
return &t;
880880
}

0 commit comments

Comments
 (0)