[llvm-branch-commits] [lld] 107b9db - [ELF][PPC64] Fix potentially corrupted section content with empty .got
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 8 12:53:49 PDT 2022
Author: Fangrui Song
Date: 2022-08-08T12:53:26-07:00
New Revision: 107b9db28bd7e16e8ba5a165a7936e8d3331fe64
URL: https://github.com/llvm/llvm-project/commit/107b9db28bd7e16e8ba5a165a7936e8d3331fe64
DIFF: https://github.com/llvm/llvm-project/commit/107b9db28bd7e16e8ba5a165a7936e8d3331fe64.diff
LOG: [ELF][PPC64] Fix potentially corrupted section content with empty .got
D91426 makes .got possibly empty while needed. If .got and .data have the same
address, and .got's content is written after .data, the first word of .data will
be corrupted.
The bug is not testable without D131247.
(cherry picked from commit 28d05d672300e51f53c73fe9a4bd053e73844247)
Added:
Modified:
lld/ELF/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 919afc7a6e0e..aa5e8675dd31 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -712,6 +712,9 @@ bool GotSection::isNeeded() const {
}
void GotSection::writeTo(uint8_t *buf) {
+ // On PPC64 .got may be needed but empty. Skip the write.
+ if (size == 0)
+ return;
target->writeGotHeader(buf);
relocateAlloc(buf, buf + size);
}
More information about the llvm-branch-commits
mailing list