Skip to content

Commit 28d05d6

Browse files
committed
[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.
1 parent 5f1c7e2 commit 28d05d6

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
@@ -678,6 +678,9 @@ bool GotSection::isNeeded() const {
678678
}
679679

680680
void GotSection::writeTo(uint8_t *buf) {
681+
// On PPC64 .got may be needed but empty. Skip the write.
682+
if (size == 0)
683+
return;
681684
target->writeGotHeader(buf);
682685
relocateAlloc(buf, buf + size);
683686
}

0 commit comments

Comments
 (0)