Lines Matching refs:sec

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