diff options
author | Csanád Hajdú <csanad.hajdu@arm.com> | 2025-04-01 09:35:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-01 09:35:27 +0200 |
commit | 5ff8c036063d83c6eff495de7709b12875113d62 (patch) | |
tree | 09f1f6044e3b7037ac78f31c7045dcb963741f78 /llvm/lib | |
parent | 6b647de031a7d590663a791a503525f21cb98d03 (diff) | |
download | llvm-5ff8c036063d83c6eff495de7709b12875113d62.zip llvm-5ff8c036063d83c6eff495de7709b12875113d62.tar.gz llvm-5ff8c036063d83c6eff495de7709b12875113d62.tar.bz2 |
[AArch64] Bugfix when using execute-only and memtag sanitizer together (#133084)
Support for execute-only code generation (#125687) introduced a bug in
the case where the memtag sanitizer is used in a module containing a mix
of execute-only and non-execute-only functions.
The bug is caused by using `return` instead of `break` to short-circuit
a loop, which meant that the rest of the function dealing with memtag
sanitizer logic wasn't run.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp index 98bd102..b12a124 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -511,11 +511,17 @@ void AArch64TargetELFStreamer::finish() { })) { auto *Text = static_cast<MCSectionELF *>(Ctx.getObjectFileInfo()->getTextSection()); - for (auto &F : *Text) - if (auto *DF = dyn_cast<MCDataFragment>(&F)) - if (!DF->getContents().empty()) - return; - Text->setFlags(Text->getFlags() | ELF::SHF_AARCH64_PURECODE); + bool Empty = true; + for (auto &F : *Text) { + if (auto *DF = dyn_cast<MCDataFragment>(&F)) { + if (!DF->getContents().empty()) { + Empty = false; + break; + } + } + } + if (Empty) + Text->setFlags(Text->getFlags() | ELF::SHF_AARCH64_PURECODE); } MCSectionELF *MemtagSec = nullptr; |