Lines Matching refs:sec

118   if (sec)  in getValue()
119 return alignToPowerOf2(sec->getOutputSection()->addr + sec->getOffset(val), in getValue()
125 return sec ? sec->getOutputSection()->addr + sec->getOffset(0) : 0; in getSecAddr()
135 OutputDesc *sec; in createOutputSection() local
138 sec = secRef; in createOutputSection()
140 sec = make<OutputDesc>(name, SHT_PROGBITS, 0); in createOutputSection()
142 secRef = sec; in createOutputSection()
144 sec->osec.location = std::string(location); in createOutputSection()
145 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 visibility, value.type, symValue, 0, sec); in addSymbol()
360 const OutputSection &sec = cast<OutputDesc>(cmd)->osec; in declareSymbols() local
361 if (sec.constraint != ConstraintKind::NoConstraint) in declareSymbols()
363 for (SectionCommand *cmd : sec.commands) in declareSymbols()
386 cmd->sym->section = v.sec; in assignSymbol()
434 sections, [](InputSectionBase *sec) { return sec->flags & SHF_WRITE; }); in matchConstraints() argument
518 InputSectionBase *sec = sections[i]; in computeInputSections() local
519 if (!sec->isLive() || sec->parent || seen.contains(i)) in computeInputSections()
527 if (isa<InputSection>(sec) && in computeInputSections()
528 cast<InputSection>(sec)->getRelocatedSection()) in computeInputSections()
532 if (!pat.sectionPat.match(sec->name)) in computeInputSections()
535 if (!cmd->matchesFile(sec->file) || pat.excludesFile(sec->file) || in computeInputSections()
536 (sec->flags & cmd->withFlags) != cmd->withFlags || in computeInputSections()
537 (sec->flags & cmd->withoutFlags) != 0) in computeInputSections()
540 ret.push_back(sec); in computeInputSections()
575 for (InputSection *sec : s.dependentSections) in discard()
576 discard(*sec); in discard()
745 auto *sec = cast<InputSection>(isec); in addInputSec() local
746 OutputSection *out = sec->getRelocatedSection()->getOutputSection(); in addInputSec()
749 out->relocationSection->recordSection(sec); in addInputSec()
801 for (OutputSection *sec : v) { in addInputSec()
802 if (sec->partition != isec->partition) in addInputSec()
811 cast<InputSectionDescription>(sec->commands[0])->sectionBases[0]); in addInputSec()
820 sec->recordSection(isec); in addInputSec()
841 } else if (OutputSection *sec = findByName(sectionCommands, name)) { in addOrphanSections() local
842 sec->recordSection(s); in addOrphanSections()
868 if (auto *sec = dyn_cast<InputSection>(isec)) in addOrphanSections() local
869 if (InputSectionBase *rel = sec->getRelocatedSection()) in addOrphanSections()
895 for (const InputSectionBase *sec : orphanSections) { in diagnoseOrphanHandling() local
898 if (sec == in.relroPadding.get()) in diagnoseOrphanHandling()
902 if (isa<InputSection>(sec) && in diagnoseOrphanHandling()
903 cast<InputSection>(sec)->getRelocatedSection()) in diagnoseOrphanHandling()
906 StringRef name = getOutputSectionName(sec); in diagnoseOrphanHandling()
908 error(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
910 warn(toString(sec) + " is being placed in '" + name + "'"); in diagnoseOrphanHandling()
918 OutputSection *sec = findByName(sectionCommands, ".gnu.sgstubs"); in diagnoseMissingSGSectionAddress() local
919 if (sec && !sec->addrExpr && !config->sectionStartMap.count(".gnu.sgstubs")) in diagnoseMissingSGSectionAddress()
920 error("no address assigned to the veneers output section " + sec->name); in diagnoseMissingSGSectionAddress()
929 LinkerScript::findMemoryRegion(OutputSection *sec, MemoryRegion *hint) { in findMemoryRegion() argument
931 if (!(sec->flags & SHF_ALLOC)) { in findMemoryRegion()
933 sec->hasInputSections || in findMemoryRegion()
934 llvm::any_of(sec->commands, [](SectionCommand *comm) { in findMemoryRegion()
937 if (!sec->memoryRegionName.empty() && hasInputOrByteCommand) in findMemoryRegion()
939 sec->name + "'"); in findMemoryRegion()
945 if (!sec->memoryRegionName.empty()) { in findMemoryRegion()
946 if (MemoryRegion *m = memoryRegions.lookup(sec->memoryRegionName)) in findMemoryRegion()
948 error("memory region '" + sec->memoryRegionName + "' not declared"); in findMemoryRegion()
959 if (sec->sectionIndex == UINT32_MAX && hint) in findMemoryRegion()
965 if (m->compatibleWith(sec->flags)) in findMemoryRegion()
970 error("no memory region specified for section '" + sec->name + "'"); in findMemoryRegion()
975 for (OutputSection *sec : outputSections) in findFirstSection()
976 if (sec->ptLoad == load) in findFirstSection()
977 return sec; in findFirstSection()
983 void LinkerScript::assignOffsets(OutputSection *sec) { in assignOffsets() argument
984 const bool isTbss = (sec->flags & SHF_TLS) && sec->type == SHT_NOBITS; in assignOffsets()
985 const bool sameMemRegion = state->memRegion == sec->memRegion; in assignOffsets()
988 state->memRegion = sec->memRegion; in assignOffsets()
989 state->lmaRegion = sec->lmaRegion; in assignOffsets()
991 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
1004 if (sec->addrExpr) in assignOffsets()
1005 setDot(sec->addrExpr, sec->location, false); in assignOffsets()
1013 sec->name); in assignOffsets()
1016 state->outSec = sec; in assignOffsets()
1017 if (sec->addrExpr && script->hasSectionsCommand) { in assignOffsets()
1019 sec->addr = dot; in assignOffsets()
1024 dot = alignToPowerOf2(dot, sec->addralign); in assignOffsets()
1025 sec->addr = dot; in assignOffsets()
1035 if (sec->lmaExpr) { in assignOffsets()
1036 state->lmaOffset = sec->lmaExpr().getValue() - dot; in assignOffsets()
1037 } else if (MemoryRegion *mr = sec->lmaRegion) { in assignOffsets()
1038 uint64_t lmaStart = alignToPowerOf2(mr->curPos, sec->addralign); in assignOffsets()
1040 expandMemoryRegion(mr, lmaStart - mr->curPos, sec->name); in assignOffsets()
1047 if (PhdrEntry *l = sec->ptLoad) in assignOffsets()
1048 if (sec == findFirstSection(l)) in assignOffsets()
1053 sec->size = 0; in assignOffsets()
1058 for (SectionCommand *cmd : sec->commands) { in assignOffsets()
1069 data->offset = dot - sec->addr; in assignOffsets()
1079 assert(isec->getParent() == sec); in assignOffsets()
1082 isec->outSecOff = dot - sec->addr; in assignOffsets()
1094 if (in.relroPadding && sec == in.relroPadding->getParent()) in assignOffsets()
1099 if (!(sec->flags & SHF_ALLOC)) { in assignOffsets()
1108 static bool isDiscardable(const OutputSection &sec) { in isDiscardable() argument
1109 if (sec.name == "/DISCARD/") in isDiscardable()
1115 if (sec.expressionsUseSymbols) in isDiscardable()
1121 if (sec.usedInExpression) in isDiscardable()
1124 for (SectionCommand *cmd : sec.commands) { in isDiscardable()
1137 bool LinkerScript::isDiscarded(const OutputSection *sec) const { in isDiscarded()
1138 return hasSectionsCommand && (getFirstInputSection(sec) == nullptr) && in isDiscarded()
1139 isDiscardable(*sec); in isDiscarded()
1142 static void maybePropagatePhdrs(OutputSection &sec, in maybePropagatePhdrs() argument
1144 if (sec.phdrs.empty()) { in maybePropagatePhdrs()
1147 if (sec.flags & SHF_ALLOC) in maybePropagatePhdrs()
1148 sec.phdrs = phdrs; in maybePropagatePhdrs()
1150 phdrs = sec.phdrs; in maybePropagatePhdrs()
1184 auto *sec = &cast<OutputDesc>(cmd)->osec; in adjustOutputSections() local
1187 if (sec->alignExpr) in adjustOutputSections()
1188 sec->addralign = in adjustOutputSections()
1189 std::max<uint32_t>(sec->addralign, sec->alignExpr().getValue()); in adjustOutputSections()
1191 bool isEmpty = (getFirstInputSection(sec) == nullptr); in adjustOutputSections()
1192 bool discardable = isEmpty && isDiscardable(*sec); in adjustOutputSections()
1196 if (sec->hasInputSections && !discardable) in adjustOutputSections()
1197 flags = sec->flags; in adjustOutputSections()
1202 sec->flags = in adjustOutputSections()
1203 flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) | SHF_WRITE); in adjustOutputSections()
1214 if (sec->sectionIndex != UINT32_MAX) in adjustOutputSections()
1215 maybePropagatePhdrs(*sec, defPhdrs); in adjustOutputSections()
1220 if (in.relroPadding && in.relroPadding->getParent() == sec && !seenRelro) in adjustOutputSections()
1223 sec->markDead(); in adjustOutputSections()
1227 sec->relro && !(sec->type == SHT_NOBITS && (sec->flags & SHF_TLS)); in adjustOutputSections()
1245 OutputSection *sec = &osd->osec; in adjustSectionsAfterSorting() local
1246 if (!sec->lmaRegionName.empty()) { in adjustSectionsAfterSorting()
1247 if (MemoryRegion *m = memoryRegions.lookup(sec->lmaRegionName)) in adjustSectionsAfterSorting()
1248 sec->lmaRegion = m; in adjustSectionsAfterSorting()
1250 error("memory region '" + sec->lmaRegionName + "' not declared"); in adjustSectionsAfterSorting()
1252 std::tie(sec->memRegion, hint) = findMemoryRegion(sec, hint); in adjustSectionsAfterSorting()
1294 for (OutputSection *sec : outputSections) in allocateHeaders()
1295 if (sec->flags & SHF_ALLOC) in allocateHeaders()
1296 min = std::min<uint64_t>(min, sec->addr); in allocateHeaders()
1398 for (OutputSection *sec : outputSections) { in createPhdrs()
1400 for (size_t id : getPhdrIndices(sec)) { in createPhdrs()
1401 ret[id]->add(sec); in createPhdrs()
1403 ret[id]->p_flags |= sec->getPhdrFlags(); in createPhdrs()
1514 for (const OutputSection *sec : outputSections) { in checkFinalScriptConditions() local
1515 if (const MemoryRegion *memoryRegion = sec->memRegion) in checkFinalScriptConditions()
1516 checkMemoryRegion(memoryRegion, sec, sec->addr); in checkFinalScriptConditions()
1517 if (const MemoryRegion *lmaRegion = sec->lmaRegion) in checkFinalScriptConditions()
1518 checkMemoryRegion(lmaRegion, sec, sec->getLMA()); in checkFinalScriptConditions()