aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-08-05 18:24:53 -0700
committerTom Stellard <tstellar@redhat.com>2022-08-08 12:53:26 -0700
commitbf271375cc086c1d0a382d6a4ffc0dd3976c964d (patch)
tree7b56db63584e9c351831703425f853f9c52e9ca9
parent9383f823971f847baafd0b05dc35c6cc530000e1 (diff)
downloadllvm-bf271375cc086c1d0a382d6a4ffc0dd3976c964d.zip
llvm-bf271375cc086c1d0a382d6a4ffc0dd3976c964d.tar.gz
llvm-bf271375cc086c1d0a382d6a4ffc0dd3976c964d.tar.bz2
[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 d7cbfcf36ace575ec90434624279dd3ebce78c47)
-rw-r--r--lld/ELF/Arch/AArch64.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 1949169..b236848 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -873,8 +873,8 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
}
static TargetInfo *getTargetInfo() {
- if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI |
- GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
+ if ((config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ||
+ config->zPacPlt) {
static AArch64BtiPac t;
return &t;
}