[ELF] Move SyntheticSection check from InputSection::writeTo to OutputSection::writeTo. NFC

Simplify code and make the heavyweight operation to the call site so that it is
clearer how to improve the inefficient scheduling in the future.
This commit is contained in:
Fangrui Song
2022-02-27 23:28:51 -08:00
parent fd37d489cf
commit 4976d1fe58
2 changed files with 4 additions and 6 deletions

View File

@@ -1213,11 +1213,6 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *buf,
}
template <class ELFT> void InputSection::writeTo(uint8_t *buf) {
if (auto *s = dyn_cast<SyntheticSection>(this)) {
s->writeTo(buf);
return;
}
if (LLVM_UNLIKELY(type == SHT_NOBITS))
return;
// If -r or --emit-relocs is given, then an InputSection

View File

@@ -431,7 +431,10 @@ template <class ELFT> void OutputSection::writeTo(uint8_t *buf) {
parallelForEachN(0, sections.size(), [&](size_t i) {
InputSection *isec = sections[i];
isec->writeTo<ELFT>(buf + isec->outSecOff);
if (auto *s = dyn_cast<SyntheticSection>(isec))
s->writeTo(buf + isec->outSecOff);
else
isec->writeTo<ELFT>(buf + isec->outSecOff);
// Fill gaps between sections.
if (nonZeroFiller) {