Lines Matching refs:sec
114 if (sec) in getValue()
115 return alignToPowerOf2(sec->getOutputSection()->addr + sec->getOffset(val), in getValue()
121 return sec ? sec->getOutputSection()->addr + sec->getOffset(0) : 0; in getSecAddr()
128 if (alignment == 1 && !sec) in getSectionOffset()
136 OutputDesc *sec; in createOutputSection() local
139 sec = secRef; in createOutputSection()
141 sec = make<OutputDesc>(name, SHT_PROGBITS, 0); in createOutputSection()
143 secRef = sec; in createOutputSection()
145 sec->osec.location = std::string(location); in createOutputSection()
146 return sec; in createOutputSection()
220 SectionBase *sec = value.isAbsolute() ? nullptr : value.sec; in addSymbol() local
234 uint64_t symValue = value.sec ? 0 : value.getValue(); in addSymbol()
237 symValue, 0, sec); in addSymbol()
355 const OutputSection &sec = cast<OutputDesc>(cmd)->osec; in declareSymbols() local
356 if (sec.constraint != ConstraintKind::NoConstraint) in declareSymbols()
358 for (SectionCommand *cmd : sec.commands) in declareSymbols()
381 cmd->sym->section = v.sec; in assignSymbol()
429 sections, [](InputSectionBase *sec) { return sec->flags & SHF_WRITE; }); in matchConstraints() argument
511 InputSectionBase *sec = sections[i]; in computeInputSections() local
512 if (!sec->isLive() || sec->parent || seen.contains(i)) in computeInputSections()
520 if (isa<InputSection>(sec) && in computeInputSections()
521 cast<InputSection>(sec)->getRelocatedSection()) in computeInputSections()
525 if (!pat.sectionPat.match(sec->name)) in computeInputSections()
528 if (!cmd->matchesFile(sec->file) || pat.excludesFile(sec->file) || in computeInputSections()
529 (sec->flags & cmd->withFlags) != cmd->withFlags || in computeInputSections()
530 (sec->flags & cmd->withoutFlags) != 0) in computeInputSections()
533 ret.push_back(sec); in computeInputSections()
568 for (InputSection *sec : s.dependentSections) in discard()
569 discard(*sec); in discard()
738 auto *sec = cast<InputSection>(isec); in addInputSec() local
739 OutputSection *out = sec->getRelocatedSection()->getOutputSection(); in addInputSec()
742 out->relocationSection->recordSection(sec); in addInputSec()
794 for (OutputSection *sec : v) { in addInputSec()
795 if (sec->partition != isec->partition) in addInputSec()
804 cast<InputSectionDescription>(sec->commands[0])->sectionBases[0]); in addInputSec()
813 sec->recordSection(isec); in addInputSec()
834 } else if (OutputSection *sec = findByName(sectionCommands, name)) { in addOrphanSections() local
835 sec->recordSection(s); in addOrphanSections()
856 if (auto *sec = dyn_cast<InputSection>(isec)) in addOrphanSections() local
857 if (InputSectionBase *rel = sec->getRelocatedSection()) in addOrphanSections()
881 for (const InputSectionBase *sec : orphanSections) { in diagnoseOrphanHandling() local
884 if (isa<InputSection>(sec) && in diagnoseOrphanHandling()
885 cast<InputSection>(sec)->getRelocatedSection()) in diagnoseOrphanHandling()
888 StringRef name = getOutputSectionName(sec); in diagnoseOrphanHandling()
890 error(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
892 warn(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
902 LinkerScript::findMemoryRegion(OutputSection *sec, MemoryRegion *hint) { in findMemoryRegion() argument
904 if (!(sec->flags & SHF_ALLOC)) { in findMemoryRegion()
905 if (!sec->memoryRegionName.empty()) in findMemoryRegion()
907 sec->name + "'"); in findMemoryRegion()
913 if (!sec->memoryRegionName.empty()) { in findMemoryRegion()
914 if (MemoryRegion *m = memoryRegions.lookup(sec->memoryRegionName)) in findMemoryRegion()
916 error("memory region '" + sec->memoryRegionName + "' not declared"); in findMemoryRegion()
927 if (sec->sectionIndex == UINT32_MAX && hint) in findMemoryRegion()
933 if (m->compatibleWith(sec->flags)) in findMemoryRegion()
938 error("no memory region specified for section '" + sec->name + "'"); in findMemoryRegion()
943 for (OutputSection *sec : outputSections) in findFirstSection()
944 if (sec->ptLoad == load) in findFirstSection()
945 return sec; in findFirstSection()
951 void LinkerScript::assignOffsets(OutputSection *sec) { in assignOffsets() argument
952 const bool isTbss = (sec->flags & SHF_TLS) && sec->type == SHT_NOBITS; in assignOffsets()
953 const bool sameMemRegion = ctx->memRegion == sec->memRegion; in assignOffsets()
956 ctx->memRegion = sec->memRegion; in assignOffsets()
957 ctx->lmaRegion = sec->lmaRegion; in assignOffsets()
959 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
972 if (sec->addrExpr) in assignOffsets()
973 setDot(sec->addrExpr, sec->location, false); in assignOffsets()
981 sec->name); in assignOffsets()
984 ctx->outSec = sec; in assignOffsets()
985 if (sec->addrExpr && script->hasSectionsCommand) { in assignOffsets()
987 sec->addr = dot; in assignOffsets()
992 dot = alignToPowerOf2(dot, sec->alignment); in assignOffsets()
993 sec->addr = dot; in assignOffsets()
1003 if (sec->lmaExpr) { in assignOffsets()
1004 ctx->lmaOffset = sec->lmaExpr().getValue() - dot; in assignOffsets()
1005 } else if (MemoryRegion *mr = sec->lmaRegion) { in assignOffsets()
1006 uint64_t lmaStart = alignToPowerOf2(mr->curPos, sec->alignment); in assignOffsets()
1008 expandMemoryRegion(mr, lmaStart - mr->curPos, sec->name); in assignOffsets()
1015 if (PhdrEntry *l = sec->ptLoad) in assignOffsets()
1016 if (sec == findFirstSection(l)) in assignOffsets()
1021 sec->size = 0; in assignOffsets()
1026 for (SectionCommand *cmd : sec->commands) { in assignOffsets()
1037 data->offset = dot - sec->addr; in assignOffsets()
1047 assert(isec->getParent() == sec); in assignOffsets()
1050 isec->outSecOff = dot - sec->addr; in assignOffsets()
1062 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
1071 static bool isDiscardable(const OutputSection &sec) { in isDiscardable() argument
1072 if (sec.name == "/DISCARD/") in isDiscardable()
1078 if (sec.expressionsUseSymbols) in isDiscardable()
1084 if (sec.usedInExpression) in isDiscardable()
1087 for (SectionCommand *cmd : sec.commands) { in isDiscardable()
1100 bool LinkerScript::isDiscarded(const OutputSection *sec) const { in isDiscarded()
1101 return hasSectionsCommand && (getFirstInputSection(sec) == nullptr) && in isDiscarded()
1102 isDiscardable(*sec); in isDiscarded()
1105 static void maybePropagatePhdrs(OutputSection &sec, in maybePropagatePhdrs() argument
1107 if (sec.phdrs.empty()) { in maybePropagatePhdrs()
1110 if (sec.flags & SHF_ALLOC) in maybePropagatePhdrs()
1111 sec.phdrs = phdrs; in maybePropagatePhdrs()
1113 phdrs = sec.phdrs; in maybePropagatePhdrs()
1144 auto *sec = &cast<OutputDesc>(cmd)->osec; in adjustOutputSections() local
1147 if (sec->alignExpr) in adjustOutputSections()
1148 sec->alignment = in adjustOutputSections()
1149 std::max<uint32_t>(sec->alignment, sec->alignExpr().getValue()); in adjustOutputSections()
1151 bool isEmpty = (getFirstInputSection(sec) == nullptr); in adjustOutputSections()
1152 bool discardable = isEmpty && isDiscardable(*sec); in adjustOutputSections()
1156 if (sec->hasInputSections && !discardable) in adjustOutputSections()
1157 flags = sec->flags; in adjustOutputSections()
1162 sec->flags = flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) | in adjustOutputSections()
1174 if (sec->sectionIndex != UINT32_MAX) in adjustOutputSections()
1175 maybePropagatePhdrs(*sec, defPhdrs); in adjustOutputSections()
1178 sec->markDead(); in adjustOutputSections()
1197 OutputSection *sec = &osd->osec; in adjustSectionsAfterSorting() local
1198 if (!sec->lmaRegionName.empty()) { in adjustSectionsAfterSorting()
1199 if (MemoryRegion *m = memoryRegions.lookup(sec->lmaRegionName)) in adjustSectionsAfterSorting()
1200 sec->lmaRegion = m; in adjustSectionsAfterSorting()
1202 error("memory region '" + sec->lmaRegionName + "' not declared"); in adjustSectionsAfterSorting()
1204 std::tie(sec->memRegion, hint) = findMemoryRegion(sec, hint); in adjustSectionsAfterSorting()
1246 for (OutputSection *sec : outputSections) in allocateHeaders()
1247 if (sec->flags & SHF_ALLOC) in allocateHeaders()
1248 min = std::min<uint64_t>(min, sec->addr); in allocateHeaders()
1349 for (OutputSection *sec : outputSections) { in createPhdrs()
1351 for (size_t id : getPhdrIndices(sec)) { in createPhdrs()
1352 ret[id]->add(sec); in createPhdrs()
1354 ret[id]->p_flags |= sec->getPhdrFlags(); in createPhdrs()