Skip to content

Commit 107b9db

Browse files
MaskRaytstellar
authored andcommitted
[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 28d05d6)
1 parent 4acca1b commit 107b9db

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lld/ELF/SyntheticSections.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ bool GotSection::isNeeded() const {
712712
}
713713

714714
void GotSection::writeTo(uint8_t *buf) {
715+
// On PPC64 .got may be needed but empty. Skip the write.
716+
if (size == 0)
717+
return;
715718
target->writeGotHeader(buf);
716719
relocateAlloc(buf, buf + size);
717720
}

0 commit comments

Comments
 (0)