Lines Matching full:sec

120   if (sec)
121 return alignToPowerOf2(sec->getOutputSection()->addr + sec->getOffset(val),
127 return sec ? sec->getOutputSection()->addr + sec->getOffset(0) : 0;
137 OutputDesc *sec;
140 sec = secRef;
142 sec = make<OutputDesc>(name, SHT_PROGBITS, 0);
144 secRef = sec;
146 sec->osec.location = std::string(location);
147 return sec;
213 SectionBase *sec = value.isAbsolute() ? nullptr : value.sec;
227 uint64_t symValue = value.sec ? 0 : value.getValue();
230 visibility, value.type, symValue, 0, sec);
356 const OutputSection &sec = cast<OutputDesc>(cmd)->osec;
357 if (sec.constraint != ConstraintKind::NoConstraint)
359 for (SectionCommand *cmd : sec.commands)
382 cmd->sym->section = v.sec;
430 sections, [](InputSectionBase *sec) { return sec->flags & SHF_WRITE; });
516 InputSectionBase *sec = sections[i];
517 if (!sec->isLive() || seen.contains(i))
525 if (isa<InputSection>(sec) &&
526 cast<InputSection>(sec)->getRelocatedSection())
530 if (!pat.sectionPat.match(sec->name))
533 if (!cmd->matchesFile(sec->file) || pat.excludesFile(sec->file) ||
534 (sec->flags & cmd->withFlags) != cmd->withFlags ||
535 (sec->flags & cmd->withoutFlags) != 0)
538 if (sec->parent) {
550 if (sec->parent->name == "/DISCARD/")
555 if (sec->parent == &outCmd)
558 spills.insert(sec);
561 ret.push_back(sec);
593 for (InputSectionBase *&sec : ret) {
594 if (!spills.contains(sec))
600 *sec, const_cast<InputSectionDescription &>(*cmd));
602 potentialSpillLists.try_emplace(sec, PotentialSpillList{pss, pss});
607 sec = pss;
620 for (InputSection *sec : s.dependentSections)
621 discard(*sec);
792 auto *sec = cast<InputSection>(isec);
793 OutputSection *out = sec->getRelocatedSection()->getOutputSection();
796 relSec->recordSection(sec);
848 for (OutputSection *sec : v) {
849 if (sec->partition != isec->partition)
858 cast<InputSectionDescription>(sec->commands[0])->sectionBases[0]);
867 sec->recordSection(isec);
888 } else if (OutputSection *sec = findByName(sectionCommands, name)) {
889 sec->recordSection(s);
915 if (auto *sec = dyn_cast<InputSection>(isec))
916 if (InputSectionBase *rel = sec->getRelocatedSection())
943 for (const InputSectionBase *sec : orphanSections) {
946 if (sec == in.relroPadding.get())
950 if (isa<InputSection>(sec) &&
951 cast<InputSection>(sec)->getRelocatedSection())
954 StringRef name = getOutputSectionName(sec);
956 error(toString(sec) + " is being placed in '" + name + "'");
958 warn(toString(sec) + " is being placed in '" + name + "'");
966 OutputSection *sec = findByName(sectionCommands, ".gnu.sgstubs");
967 if (sec && !sec->addrExpr && !config->sectionStartMap.count(".gnu.sgstubs"))
968 error("no address assigned to the veneers output section " + sec->name);
977 LinkerScript::findMemoryRegion(OutputSection *sec, MemoryRegion *hint) {
979 if (!(sec->flags & SHF_ALLOC)) {
981 sec->hasInputSections ||
982 llvm::any_of(sec->commands, [](SectionCommand *comm) {
985 if (!sec->memoryRegionName.empty() && hasInputOrByteCommand)
987 sec->name + "'");
993 if (!sec->memoryRegionName.empty()) {
994 if (MemoryRegion *m = memoryRegions.lookup(sec->memoryRegionName))
996 error("memory region '" + sec->memoryRegionName + "' not declared");
1007 if (sec->sectionIndex == UINT32_MAX && hint)
1013 if (m->compatibleWith(sec->flags))
1018 error("no memory region specified for section '" + sec->name + "'");
1023 for (OutputSection *sec : outputSections)
1024 if (sec->ptLoad == load)
1025 return sec;
1031 bool LinkerScript::assignOffsets(OutputSection *sec) {
1032 const bool isTbss = (sec->flags & SHF_TLS) && sec->type == SHT_NOBITS;
1033 const bool sameMemRegion = state->memRegion == sec->memRegion;
1037 state->memRegion = sec->memRegion;
1038 state->lmaRegion = sec->lmaRegion;
1040 if (!(sec->flags & SHF_ALLOC)) {
1053 if (sec->addrExpr)
1054 setDot(sec->addrExpr, sec->location, false);
1062 sec->name);
1065 state->outSec = sec;
1066 if (!(sec->addrExpr && script->hasSectionsCommand)) {
1067 // ALIGN is respected. sec->alignment is the max of ALIGN and the maximum of
1070 dot = alignToPowerOf2(dot, sec->addralign);
1073 addressChanged = sec->addr != dot;
1074 sec->addr = dot;
1082 if (sec->lmaExpr) {
1083 state->lmaOffset = sec->lmaExpr().getValue() - dot;
1084 } else if (MemoryRegion *mr = sec->lmaRegion) {
1085 uint64_t lmaStart = alignToPowerOf2(mr->curPos, sec->addralign);
1087 expandMemoryRegion(mr, lmaStart - mr->curPos, sec->name);
1094 if (PhdrEntry *l = sec->ptLoad)
1095 if (sec == findFirstSection(l))
1100 sec->size = 0;
1105 for (SectionCommand *cmd : sec->commands) {
1116 data->offset = dot - sec->addr;
1128 assert(isec->getParent() == sec);
1133 isec->outSecOff = dot - sec->addr;
1145 if (in.relroPadding && sec == in.relroPadding->getParent())
1150 if (!(sec->flags & SHF_ALLOC)) {
1160 static bool isDiscardable(const OutputSection &sec) {
1161 if (sec.name == "/DISCARD/")
1167 if (sec.expressionsUseSymbols)
1173 if (sec.usedInExpression)
1176 for (SectionCommand *cmd : sec.commands) {
1189 static void maybePropagatePhdrs(OutputSection &sec,
1191 if (sec.phdrs.empty()) {
1194 if (sec.flags & SHF_ALLOC)
1195 sec.phdrs = phdrs;
1197 phdrs = sec.phdrs;
1231 auto *sec = &cast<OutputDesc>(cmd)->osec;
1234 if (sec->alignExpr)
1235 sec->addralign =
1236 std::max<uint32_t>(sec->addralign, sec->alignExpr().getValue());
1238 bool isEmpty = (getFirstInputSection(sec) == nullptr);
1239 bool discardable = isEmpty && isDiscardable(*sec);
1240 // If sec has at least one input section and not discarded, remember its
1241 // flags to be inherited by subsequent output sections. (sec may contain
1243 if (sec->hasInputSections && !discardable)
1244 flags = sec->flags;
1249 sec->flags =
1250 flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) | SHF_WRITE);
1251 sec->sortRank = getSectionRank(*sec);
1263 if (sec->sectionIndex != UINT32_MAX)
1264 maybePropagatePhdrs(*sec, defPhdrs);
1269 if (in.relroPadding && in.relroPadding->getParent() == sec && !seenRelro)
1272 sec->markDead();
1276 sec->relro && !(sec->type == SHT_NOBITS && (sec->flags & SHF_TLS));
1294 OutputSection *sec = &osd->osec;
1295 if (!sec->lmaRegionName.empty()) {
1296 if (MemoryRegion *m = memoryRegions.lookup(sec->lmaRegionName))
1297 sec->lmaRegion = m;
1299 error("memory region '" + sec->lmaRegionName + "' not declared");
1301 std::tie(sec->memRegion, hint) = findMemoryRegion(sec, hint);
1343 for (OutputSection *sec : outputSections)
1344 if (sec->flags & SHF_ALLOC)
1345 min = std::min<uint64_t>(min, sec->addr);
1558 for (OutputSection *sec : outputSections) {
1560 for (size_t id : getPhdrIndices(sec)) {
1561 ret[id]->add(sec);
1563 ret[id]->p_flags |= sec->getPhdrFlags();
1679 for (const OutputSection *sec : outputSections) {
1680 if (const MemoryRegion *memoryRegion = sec->memRegion)
1681 checkMemoryRegion(memoryRegion, sec, sec->addr);
1682 if (const MemoryRegion *lmaRegion = sec->lmaRegion)
1683 checkMemoryRegion(lmaRegion, sec, sec->getLMA());