diff options
author | Fangrui Song <i@maskray.me> | 2022-08-05 18:24:53 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-08-05 18:24:54 -0700 |
commit | d7cbfcf36ace575ec90434624279dd3ebce78c47 (patch) | |
tree | 94e4fd690366d3e20b33b12c14892db20ce825ad | |
parent | e89d6d2ac527f973c43563373dfdeb9e4c3bbcc5 (diff) |
[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).
-rw-r--r-- | lld/ELF/Arch/AArch64.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp index 807e5dda9d5b..fc564ab6f15a 100644 --- a/lld/ELF/Arch/AArch64.cpp +++ b/lld/ELF/Arch/AArch64.cpp @@ -884,8 +884,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; } |