diff options
author | Fangrui Song <i@maskray.me> | 2022-08-05 15:22:57 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-08-05 15:22:57 -0700 |
commit | 28d05d672300e51f53c73fe9a4bd053e73844247 (patch) | |
tree | e132ab89f1537224f049f52715eb072af76a16bd | |
parent | 5f1c7e2cc5a3c07cbc2412e851a7283c1841f520 (diff) |
[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.
-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 a33f79b628eb..ff48f085a2d7 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -678,6 +678,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); } |