Lines Matching refs:sec
115 if (sec) in getValue()
116 return alignToPowerOf2(sec->getOutputSection()->addr + sec->getOffset(val), in getValue()
122 return sec ? sec->getOutputSection()->addr + sec->getOffset(0) : 0; in getSecAddr()
129 if (alignment == 1 && !sec) in getSectionOffset()
137 OutputDesc *sec; in createOutputSection() local
140 sec = secRef; in createOutputSection()
142 sec = make<OutputDesc>(name, SHT_PROGBITS, 0); in createOutputSection()
144 secRef = sec; in createOutputSection()
146 sec->osec.location = std::string(location); in createOutputSection()
147 return sec; in createOutputSection()
221 SectionBase *sec = value.isAbsolute() ? nullptr : value.sec; in addSymbol() local
235 uint64_t symValue = value.sec ? 0 : value.getValue(); in addSymbol()
238 symValue, 0, sec); in addSymbol()
356 const OutputSection &sec = cast<OutputDesc>(cmd)->osec; in declareSymbols() local
357 if (sec.constraint != ConstraintKind::NoConstraint) in declareSymbols()
359 for (SectionCommand *cmd : sec.commands) in declareSymbols()
382 cmd->sym->section = v.sec; in assignSymbol()
430 sections, [](InputSectionBase *sec) { return sec->flags & SHF_WRITE; }); in matchConstraints() argument
512 InputSectionBase *sec = sections[i]; in computeInputSections() local
513 if (!sec->isLive() || sec->parent || seen.contains(i)) in computeInputSections()
521 if (isa<InputSection>(sec) && in computeInputSections()
522 cast<InputSection>(sec)->getRelocatedSection()) in computeInputSections()
526 if (!pat.sectionPat.match(sec->name)) in computeInputSections()
529 if (!cmd->matchesFile(sec->file) || pat.excludesFile(sec->file) || in computeInputSections()
530 (sec->flags & cmd->withFlags) != cmd->withFlags || in computeInputSections()
531 (sec->flags & cmd->withoutFlags) != 0) in computeInputSections()
534 ret.push_back(sec); in computeInputSections()
569 for (InputSection *sec : s.dependentSections) in discard()
570 discard(*sec); in discard()
739 auto *sec = cast<InputSection>(isec); in addInputSec() local
740 OutputSection *out = sec->getRelocatedSection()->getOutputSection(); in addInputSec()
743 out->relocationSection->recordSection(sec); in addInputSec()
795 for (OutputSection *sec : v) { in addInputSec()
796 if (sec->partition != isec->partition) in addInputSec()
805 cast<InputSectionDescription>(sec->commands[0])->sectionBases[0]); in addInputSec()
814 sec->recordSection(isec); in addInputSec()
835 } else if (OutputSection *sec = findByName(sectionCommands, name)) { in addOrphanSections() local
836 sec->recordSection(s); in addOrphanSections()
862 if (auto *sec = dyn_cast<InputSection>(isec)) in addOrphanSections() local
863 if (InputSectionBase *rel = sec->getRelocatedSection()) in addOrphanSections()
889 for (const InputSectionBase *sec : orphanSections) { in diagnoseOrphanHandling() local
892 if (isa<InputSection>(sec) && in diagnoseOrphanHandling()
893 cast<InputSection>(sec)->getRelocatedSection()) in diagnoseOrphanHandling()
896 StringRef name = getOutputSectionName(sec); in diagnoseOrphanHandling()
898 error(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
900 warn(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
910 LinkerScript::findMemoryRegion(OutputSection *sec, MemoryRegion *hint) { in findMemoryRegion() argument
912 if (!(sec->flags & SHF_ALLOC)) { in findMemoryRegion()
913 if (!sec->memoryRegionName.empty()) in findMemoryRegion()
915 sec->name + "'"); in findMemoryRegion()
921 if (!sec->memoryRegionName.empty()) { in findMemoryRegion()
922 if (MemoryRegion *m = memoryRegions.lookup(sec->memoryRegionName)) in findMemoryRegion()
924 error("memory region '" + sec->memoryRegionName + "' not declared"); in findMemoryRegion()
935 if (sec->sectionIndex == UINT32_MAX && hint) in findMemoryRegion()
941 if (m->compatibleWith(sec->flags)) in findMemoryRegion()
946 error("no memory region specified for section '" + sec->name + "'"); in findMemoryRegion()
951 for (OutputSection *sec : outputSections) in findFirstSection()
952 if (sec->ptLoad == load) in findFirstSection()
953 return sec; in findFirstSection()
959 void LinkerScript::assignOffsets(OutputSection *sec) { in assignOffsets() argument
960 const bool isTbss = (sec->flags & SHF_TLS) && sec->type == SHT_NOBITS; in assignOffsets()
961 const bool sameMemRegion = state->memRegion == sec->memRegion; in assignOffsets()
964 state->memRegion = sec->memRegion; in assignOffsets()
965 state->lmaRegion = sec->lmaRegion; in assignOffsets()
967 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
980 if (sec->addrExpr) in assignOffsets()
981 setDot(sec->addrExpr, sec->location, false); in assignOffsets()
989 sec->name); in assignOffsets()
996 state->outSec = sec; in assignOffsets()
997 if (sec->addrExpr && script->hasSectionsCommand) { in assignOffsets()
999 sec->addr = dot; in assignOffsets()
1004 dot = alignToPowerOf2(dot, sec->addralign); in assignOffsets()
1005 sec->addr = dot; in assignOffsets()
1015 if (sec->lmaExpr) { in assignOffsets()
1016 state->lmaOffset = sec->lmaExpr().getValue() - dot; in assignOffsets()
1017 } else if (MemoryRegion *mr = sec->lmaRegion) { in assignOffsets()
1018 uint64_t lmaStart = alignToPowerOf2(mr->curPos, sec->addralign); in assignOffsets()
1020 expandMemoryRegion(mr, lmaStart - mr->curPos, sec->name); in assignOffsets()
1029 if (PhdrEntry *l = sec->ptLoad) in assignOffsets()
1030 if (sec == findFirstSection(l)) in assignOffsets()
1035 sec->size = 0; in assignOffsets()
1040 for (SectionCommand *cmd : sec->commands) { in assignOffsets()
1051 data->offset = dot - sec->addr; in assignOffsets()
1061 assert(isec->getParent() == sec); in assignOffsets()
1064 isec->outSecOff = dot - sec->addr; in assignOffsets()
1076 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
1085 static bool isDiscardable(const OutputSection &sec) { in isDiscardable() argument
1086 if (sec.name == "/DISCARD/") in isDiscardable()
1092 if (sec.expressionsUseSymbols) in isDiscardable()
1098 if (sec.usedInExpression) in isDiscardable()
1101 for (SectionCommand *cmd : sec.commands) { in isDiscardable()
1114 bool LinkerScript::isDiscarded(const OutputSection *sec) const { in isDiscarded()
1115 return hasSectionsCommand && (getFirstInputSection(sec) == nullptr) && in isDiscarded()
1116 isDiscardable(*sec); in isDiscarded()
1119 static void maybePropagatePhdrs(OutputSection &sec, in maybePropagatePhdrs() argument
1121 if (sec.phdrs.empty()) { in maybePropagatePhdrs()
1124 if (sec.flags & SHF_ALLOC) in maybePropagatePhdrs()
1125 sec.phdrs = phdrs; in maybePropagatePhdrs()
1127 phdrs = sec.phdrs; in maybePropagatePhdrs()
1158 auto *sec = &cast<OutputDesc>(cmd)->osec; in adjustOutputSections() local
1161 if (sec->alignExpr) in adjustOutputSections()
1162 sec->addralign = in adjustOutputSections()
1163 std::max<uint32_t>(sec->addralign, sec->alignExpr().getValue()); in adjustOutputSections()
1165 bool isEmpty = (getFirstInputSection(sec) == nullptr); in adjustOutputSections()
1166 bool discardable = isEmpty && isDiscardable(*sec); in adjustOutputSections()
1170 if (sec->hasInputSections && !discardable) in adjustOutputSections()
1171 flags = sec->flags; in adjustOutputSections()
1176 sec->flags = flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) | in adjustOutputSections()
1188 if (sec->sectionIndex != UINT32_MAX) in adjustOutputSections()
1189 maybePropagatePhdrs(*sec, defPhdrs); in adjustOutputSections()
1192 sec->markDead(); in adjustOutputSections()
1211 OutputSection *sec = &osd->osec; in adjustSectionsAfterSorting() local
1212 if (!sec->lmaRegionName.empty()) { in adjustSectionsAfterSorting()
1213 if (MemoryRegion *m = memoryRegions.lookup(sec->lmaRegionName)) in adjustSectionsAfterSorting()
1214 sec->lmaRegion = m; in adjustSectionsAfterSorting()
1216 error("memory region '" + sec->lmaRegionName + "' not declared"); in adjustSectionsAfterSorting()
1218 std::tie(sec->memRegion, hint) = findMemoryRegion(sec, hint); in adjustSectionsAfterSorting()
1260 for (OutputSection *sec : outputSections) in allocateHeaders()
1261 if (sec->flags & SHF_ALLOC) in allocateHeaders()
1262 min = std::min<uint64_t>(min, sec->addr); in allocateHeaders()
1363 for (OutputSection *sec : outputSections) { in createPhdrs()
1365 for (size_t id : getPhdrIndices(sec)) { in createPhdrs()
1366 ret[id]->add(sec); in createPhdrs()
1368 ret[id]->p_flags |= sec->getPhdrFlags(); in createPhdrs()