forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
5f1c7e2cc5
commit
28d05d6723
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue