diff options
author | Fangrui Song <i@maskray.me> | 2022-08-05 15:22:57 -0700 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2022-08-08 12:53:26 -0700 |
commit | 107b9db28bd7e16e8ba5a165a7936e8d3331fe64 (patch) | |
tree | 75959e0d271d4f41995de058eacdff7fe308008c | |
parent | 4acca1b014ece0073fd33c384b86b7a29dd3df9d (diff) | |
download | llvm-107b9db28bd7e16e8ba5a165a7936e8d3331fe64.zip llvm-107b9db28bd7e16e8ba5a165a7936e8d3331fe64.tar.gz llvm-107b9db28bd7e16e8ba5a165a7936e8d3331fe64.tar.bz2 |
[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)
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 919afc7..aa5e867 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); } |