Lines Matching refs:sec

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