Lines Matching refs:sec
52 static uint64_t getOutputSectionVA(SectionBase *sec) { in getOutputSectionVA() argument
53 OutputSection *os = sec->getOutputSection(); in getOutputSectionVA()
59 if (sec) in getValue()
60 return alignTo(sec->getOffset(val) + getOutputSectionVA(sec), in getValue()
66 if (sec) in getSecAddr()
67 return sec->getOffset(0) + getOutputSectionVA(sec); in getSecAddr()
75 if (alignment == 1 && !sec) in getSectionOffset()
83 OutputSection *sec; in createOutputSection() local
86 sec = secRef; in createOutputSection()
88 sec = make<OutputSection>(name, SHT_PROGBITS, 0); in createOutputSection()
90 secRef = sec; in createOutputSection()
92 sec->location = std::string(location); in createOutputSection()
93 return sec; in createOutputSection()
168 SectionBase *sec = value.isAbsolute() ? nullptr : value.sec; in addSymbol() local
182 uint64_t symValue = value.sec ? 0 : value.getValue(); in addSymbol()
185 symValue, 0, sec); in addSymbol()
300 auto *sec = cast<OutputSection>(base); in declareSymbols() local
301 if (sec->constraint != ConstraintKind::NoConstraint) in declareSymbols()
303 for (BaseCommand *base2 : sec->sectionCommands) in declareSymbols()
326 cmd->sym->section = v.sec; in assignSymbol()
374 sections, [](InputSectionBase *sec) { return sec->flags & SHF_WRITE; }); in matchConstraints() argument
456 InputSectionBase *sec = sections[i]; in computeInputSections() local
457 if (!sec->isLive() || sec->parent || seen.contains(i)) in computeInputSections()
465 if (isa<InputSection>(sec) && in computeInputSections()
466 cast<InputSection>(sec)->getRelocatedSection()) in computeInputSections()
470 if (!pat.sectionPat.match(sec->name)) in computeInputSections()
473 if (!cmd->matchesFile(sec->file) || pat.excludesFile(sec->file) || in computeInputSections()
474 (sec->flags & cmd->withFlags) != cmd->withFlags || in computeInputSections()
475 (sec->flags & cmd->withoutFlags) != 0) in computeInputSections()
478 ret.push_back(sec); in computeInputSections()
657 if (auto *sec = dyn_cast<OutputSection>(base)) in findByName() local
658 if (sec->name == name) in findByName()
659 return sec; in findByName()
665 OutputSection *sec = script->createOutputSection(outsecName, "<internal>"); in createSection() local
666 sec->recordSection(isec); in createSection()
667 return sec; in createSection()
691 auto *sec = cast<InputSection>(isec); in addInputSec() local
692 OutputSection *out = sec->getRelocatedSection()->getOutputSection(); in addInputSec()
695 out->relocationSection->recordSection(sec); in addInputSec()
746 for (OutputSection *sec : v) { in addInputSec()
747 if (sec->partition != isec->partition) in addInputSec()
756 cast<InputSectionDescription>(sec->sectionCommands[0]) in addInputSec()
766 sec->recordSection(isec); in addInputSec()
770 OutputSection *sec = createSection(isec, outsecName); in addInputSec() local
771 v.push_back(sec); in addInputSec()
772 return sec; in addInputSec()
788 } else if (OutputSection *sec = findByName(sectionCommands, name)) { in addOrphanSections() local
789 sec->recordSection(s); in addOrphanSections()
815 if (auto *sec = dyn_cast<InputSection>(isec)) in addOrphanSections() local
816 if (InputSectionBase *rel = sec->getRelocatedSection()) in addOrphanSections()
836 for (const InputSectionBase *sec : orphanSections) { in diagnoseOrphanHandling() local
839 if (isa<InputSection>(sec) && in diagnoseOrphanHandling()
840 cast<InputSection>(sec)->getRelocatedSection()) in diagnoseOrphanHandling()
843 StringRef name = getOutputSectionName(sec); in diagnoseOrphanHandling()
845 error(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
847 warn(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
868 void LinkerScript::switchTo(OutputSection *sec) { in switchTo() argument
869 ctx->outSec = sec; in switchTo()
872 if (sec->addrExpr && script->hasSectionsCommand) { in switchTo()
886 MemoryRegion *LinkerScript::findMemoryRegion(OutputSection *sec) { in findMemoryRegion() argument
889 if (!sec->memoryRegionName.empty()) { in findMemoryRegion()
890 if (MemoryRegion *m = memoryRegions.lookup(sec->memoryRegionName)) in findMemoryRegion()
892 error("memory region '" + sec->memoryRegionName + "' not declared"); in findMemoryRegion()
905 if ((m->flags & sec->flags) && (m->negFlags & sec->flags) == 0) in findMemoryRegion()
910 if (sec->flags & SHF_ALLOC) in findMemoryRegion()
911 error("no memory region specified for section '" + sec->name + "'"); in findMemoryRegion()
916 for (OutputSection *sec : outputSections) in findFirstSection()
917 if (sec->ptLoad == load) in findFirstSection()
918 return sec; in findFirstSection()
924 void LinkerScript::assignOffsets(OutputSection *sec) { in assignOffsets() argument
925 const bool isTbss = (sec->flags & SHF_TLS) && sec->type == SHT_NOBITS; in assignOffsets()
926 const bool sameMemRegion = ctx->memRegion == sec->memRegion; in assignOffsets()
929 ctx->memRegion = sec->memRegion; in assignOffsets()
930 ctx->lmaRegion = sec->lmaRegion; in assignOffsets()
932 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
945 if (sec->addrExpr) in assignOffsets()
946 setDot(sec->addrExpr, sec->location, false); in assignOffsets()
954 ctx->memRegion->name, sec->name); in assignOffsets()
957 switchTo(sec); in assignOffsets()
965 if (sec->lmaExpr) in assignOffsets()
966 ctx->lmaOffset = sec->lmaExpr().getValue() - dot; in assignOffsets()
967 else if (MemoryRegion *mr = sec->lmaRegion) in assignOffsets()
968 ctx->lmaOffset = alignTo(mr->curPos, sec->alignment) - dot; in assignOffsets()
974 if (sec == findFirstSection(l)) in assignOffsets()
979 sec->size = 0; in assignOffsets()
984 for (BaseCommand *base : sec->sectionCommands) { in assignOffsets()
1004 for (InputSection *sec : cast<InputSectionDescription>(base)->sections) in assignOffsets()
1005 output(sec); in assignOffsets()
1010 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
1019 static bool isDiscardable(OutputSection &sec) { in isDiscardable() argument
1020 if (sec.name == "/DISCARD/") in isDiscardable()
1026 if (sec.expressionsUseSymbols) in isDiscardable()
1032 if (sec.usedInExpression) in isDiscardable()
1035 for (BaseCommand *base : sec.sectionCommands) { in isDiscardable()
1048 static void maybePropagatePhdrs(OutputSection &sec, in maybePropagatePhdrs() argument
1050 if (sec.phdrs.empty()) { in maybePropagatePhdrs()
1053 if (sec.flags & SHF_ALLOC) in maybePropagatePhdrs()
1054 sec.phdrs = phdrs; in maybePropagatePhdrs()
1056 phdrs = sec.phdrs; in maybePropagatePhdrs()
1085 auto *sec = dyn_cast<OutputSection>(cmd); in adjustSectionsBeforeSorting() local
1086 if (!sec) in adjustSectionsBeforeSorting()
1090 if (sec->alignExpr) in adjustSectionsBeforeSorting()
1091 sec->alignment = in adjustSectionsBeforeSorting()
1092 std::max<uint32_t>(sec->alignment, sec->alignExpr().getValue()); in adjustSectionsBeforeSorting()
1096 if (sec->hasInputSections) in adjustSectionsBeforeSorting()
1097 flags = sec->flags; in adjustSectionsBeforeSorting()
1101 bool isEmpty = (getFirstInputSection(sec) == nullptr); in adjustSectionsBeforeSorting()
1103 sec->flags = flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) | in adjustSectionsBeforeSorting()
1115 if (sec->sectionIndex != UINT32_MAX) in adjustSectionsBeforeSorting()
1116 maybePropagatePhdrs(*sec, defPhdrs); in adjustSectionsBeforeSorting()
1118 if (isEmpty && isDiscardable(*sec)) { in adjustSectionsBeforeSorting()
1119 sec->markDead(); in adjustSectionsBeforeSorting()
1136 if (auto *sec = dyn_cast<OutputSection>(base)) { in adjustSectionsAfterSorting() local
1137 if (!sec->lmaRegionName.empty()) { in adjustSectionsAfterSorting()
1138 if (MemoryRegion *m = memoryRegions.lookup(sec->lmaRegionName)) in adjustSectionsAfterSorting()
1139 sec->lmaRegion = m; in adjustSectionsAfterSorting()
1141 error("memory region '" + sec->lmaRegionName + "' not declared"); in adjustSectionsAfterSorting()
1143 sec->memRegion = findMemoryRegion(sec); in adjustSectionsAfterSorting()
1163 if (auto *sec = dyn_cast<OutputSection>(base)) in adjustSectionsAfterSorting() local
1164 maybePropagatePhdrs(*sec, defPhdrs); in adjustSectionsAfterSorting()
1185 for (OutputSection *sec : outputSections) in allocateHeaders()
1186 if (sec->flags & SHF_ALLOC) in allocateHeaders()
1187 min = std::min<uint64_t>(min, sec->addr); in allocateHeaders()
1288 for (OutputSection *sec : outputSections) { in createPhdrs()
1290 for (size_t id : getPhdrIndices(sec)) { in createPhdrs()
1291 ret[id]->add(sec); in createPhdrs()
1293 ret[id]->p_flags |= sec->getPhdrFlags(); in createPhdrs()