aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-12-23 11:32:44 -0800
committerFangrui Song <i@maskray.me>2021-12-23 11:32:44 -0800
commitbf45624ba07f8bd65f38db872c89d8c0e4ffd5fe (patch)
treef9b66a90d48f6d527bb8d45810e0c9ff09821a8f /lld/ELF/SyntheticSections.cpp
parentf103ee2e9e3fc530fbada7cf3db6ca6913a502c1 (diff)
downloadllvm-bf45624ba07f8bd65f38db872c89d8c0e4ffd5fe.zip
llvm-bf45624ba07f8bd65f38db872c89d8c0e4ffd5fe.tar.gz
llvm-bf45624ba07f8bd65f38db872c89d8c0e4ffd5fe.tar.bz2
[ELF][PPC32] Support .got2 in an output section description
I added `PPC32Got2Section` D62464 to support .got2 but did not implement .got2 in another output section. PR52799 has a linker script placing .got2 in .rodata, which causes a null pointer dereference because a MergeSyntheticSection's file is nullptr. Add the support.
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r--lld/ELF/SyntheticSections.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 9bf6118..872dd0e 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -3620,14 +3620,12 @@ void PPC32Got2Section::finalizeContents() {
// .got2 . This function computes outSecOff of each .got2 to be used in
// PPC32PltCallStub::writeTo(). The purpose of this empty synthetic section is
// to collect input sections named ".got2".
- uint32_t offset = 0;
for (SectionCommand *cmd : getParent()->commands)
if (auto *isd = dyn_cast<InputSectionDescription>(cmd)) {
for (InputSection *isec : isd->sections) {
- if (isec == this)
- continue;
- isec->file->ppc32Got2OutSecOff = offset;
- offset += (uint32_t)isec->getSize();
+ // isec->file may be nullptr for MergeSyntheticSection.
+ if (isec != this && isec->file)
+ isec->file->ppc32Got2 = isec;
}
}
}