Lines Matching refs:sec

87   void addStartStopSymbols(OutputSection *sec);
178 for (OutputSection *sec : outputSections) in removeEmptyPTLoad()
179 if (removed.count(sec->ptLoad)) in removeEmptyPTLoad()
180 sec->ptLoad = nullptr; in removeEmptyPTLoad()
228 static Defined *addOptionalRegular(StringRef name, SectionBase *sec, in addOptionalRegular() argument
236 /*size=*/0, sec}); in addOptionalRegular()
337 if (auto *sec = dyn_cast<OutputSection>(base)) in findSection() local
338 if (sec->name == name && sec->partition == partition) in findSection()
339 return sec; in findSection()
353 InputSection *sec = createInterpSection(); in createSyntheticSections() local
354 sec->partition = i; in createSyntheticSections()
355 inputSections.push_back(sec); in createSyntheticSections()
359 auto add = [](SyntheticSection *sec) { inputSections.push_back(sec); }; in createSyntheticSections() argument
390 if (auto *sec = MipsAbiFlagsSection<ELFT>::create()) in createSyntheticSections() local
391 add(sec); in createSyntheticSections()
392 if (auto *sec = MipsOptionsSection<ELFT>::create()) in createSyntheticSections() local
393 add(sec); in createSyntheticSections()
394 if (auto *sec = MipsReginfoSection<ELFT>::create()) in createSyntheticSections() local
395 add(sec); in createSyntheticSections()
401 auto add = [&](SyntheticSection *sec) { in createSyntheticSections() argument
402 sec->partition = part.getNumber(); in createSyntheticSections()
403 inputSections.push_back(sec); in createSyntheticSections()
601 for (OutputSection *sec : outputSections) in run()
602 sec->maybeCompress<ELFT>(); in run()
622 for (OutputSection *sec : outputSections) in run()
623 sec->addr = 0; in run()
738 SectionBase *sec = sym.section; in shouldKeepInSymtab() local
739 return !sec || !(sec->flags & SHF_MERGE); in shouldKeepInSymtab()
748 SectionBase *sec = d->section; in includeInSymtab() local
749 if (!sec) in includeInSymtab()
751 sec = sec->repl; in includeInSymtab()
754 if (isa<InputSectionBase>(sec) && !sec->isLive()) in includeInSymtab()
757 if (auto *s = dyn_cast<MergeInputSection>(sec)) in includeInSymtab()
797 auto *sec = dyn_cast<OutputSection>(base); in addSectionSymbols() local
798 if (!sec) in addSectionSymbols()
800 auto i = llvm::find_if(sec->sectionCommands, [](BaseCommand *base) { in addSectionSymbols()
805 if (i == sec->sectionCommands.end()) in addSectionSymbols()
835 static bool isRelroSection(const OutputSection *sec) { in isRelroSection() argument
839 uint64_t flags = sec->flags; in isRelroSection()
862 uint32_t type = sec->type; in isRelroSection()
870 if (in.got && sec == in.got->getParent()) in isRelroSection()
878 if (sec->name.equals(".toc")) in isRelroSection()
885 if (sec == in.gotPlt->getParent()) in isRelroSection()
891 if (sec->name == ".dynamic") in isRelroSection()
898 StringRef s = sec->name; in isRelroSection()
936 static unsigned getSectionRank(const OutputSection *sec) { in getSectionRank() argument
937 unsigned rank = sec->partition * RF_PARTITION; in getSectionRank()
941 if (config->sectionStartMap.count(sec->name)) in getSectionRank()
947 if (!(sec->flags & SHF_ALLOC)) in getSectionRank()
950 if (sec->type == SHT_LLVM_PART_EHDR) in getSectionRank()
954 if (sec->type == SHT_LLVM_PART_PHDR) in getSectionRank()
960 if (sec->name == ".interp") in getSectionRank()
968 if (sec->type == SHT_NOTE) in getSectionRank()
983 bool isExec = sec->flags & SHF_EXECINSTR; in getSectionRank()
984 bool isWrite = sec->flags & SHF_WRITE; in getSectionRank()
993 } else if (sec->type == SHT_PROGBITS) { in getSectionRank()
1006 if (!isRelroSection(sec)) in getSectionRank()
1015 if (!(sec->flags & SHF_TLS)) in getSectionRank()
1020 if (sec->type == SHT_NOBITS) in getSectionRank()
1032 StringRef name = sec->name; in getSectionRank()
1052 if (sec->flags & SHF_MIPS_GPREL) in getSectionRank()
1055 if (sec->name != ".got") in getSectionRank()
1075 void PhdrEntry::add(OutputSection *sec) { in add() argument
1076 lastSec = sec; in add()
1078 firstSec = sec; in add()
1079 p_align = std::max(p_align, sec->alignment); in add()
1081 sec->ptLoad = this; in add()
1220 auto *sec = dyn_cast<OutputSection>(b); in getRankProximity() local
1221 return (sec && sec->hasInputSections) ? getRankProximityAux(a, sec) : -1; in getRankProximity()
1250 OutputSection *sec = cast<OutputSection>(*e); in findOrphanPos() local
1254 return getRankProximity(sec, a) < getRankProximity(sec, b); in findOrphanPos()
1260 int proximity = getRankProximity(sec, *i); in findOrphanPos()
1265 if (getRankProximity(sec, curSec) != proximity || in findOrphanPos()
1266 sec->sortRank < curSec->sortRank) in findOrphanPos()
1302 for (InputSectionBase *sec : sections) in maybeShuffle()
1303 if (patAndSeed.first.match(sec->name)) in maybeShuffle()
1304 matched.push_back(sec); in maybeShuffle()
1317 for (InputSectionBase *&sec : sections) in maybeShuffle()
1318 if (patAndSeed.first.match(sec->name)) in maybeShuffle()
1319 sec = matched[i++]; in maybeShuffle()
1325 for (InputSectionBase *sec : sections) { in maybeShuffle()
1326 if (order.try_emplace(sec, prio).second) in maybeShuffle()
1365 if (auto *sec = dyn_cast_or_null<InputSectionBase>(d->section)) { in buildSectionOrder() local
1366 int &priority = sectionOrder[cast<InputSectionBase>(sec->repl)]; in buildSectionOrder()
1458 static void sortSection(OutputSection *sec, in sortSection() argument
1460 StringRef name = sec->name; in sortSection()
1471 if (in.relaIplt->getParent() == sec) in sortSection()
1479 for (BaseCommand *b : sec->sectionCommands) in sortSection()
1487 sec->sortInitFini(); in sortSection()
1494 sec->sortCtorsDtors(); in sortSection()
1506 assert(sec->sectionCommands.size() == 1); in sortSection()
1507 auto *isd = cast<InputSectionDescription>(sec->sectionCommands[0]); in sortSection()
1524 if (auto *sec = dyn_cast<OutputSection>(base)) in sortInputSections() local
1525 sortSection(sec, order); in sortInputSections()
1549 for (InputSection *sec : getInputSections(os)) in sortSections()
1550 sec->outSecOff = i++; in sortSections()
1611 if (auto *sec = dyn_cast<OutputSection>(base)) in sortSections() local
1612 return sec->sectionIndex == UINT32_MAX; in sortSections()
1664 for (OutputSection *sec : outputSections) { in resolveShfLinkOrder()
1665 if (!(sec->flags & SHF_LINK_ORDER)) in resolveShfLinkOrder()
1671 sec->type == SHT_ARM_EXIDX) in resolveShfLinkOrder()
1678 for (BaseCommand *base : sec->sectionCommands) { in resolveShfLinkOrder()
1705 static void finalizeSynthetic(SyntheticSection *sec) { in finalizeSynthetic() argument
1706 if (sec && sec->isNeeded() && sec->getParent()) { in finalizeSynthetic()
1707 llvm::TimeTraceScope timeScope("Finalize synthetic sections", sec->name); in finalizeSynthetic()
1708 sec->finalizeContents(); in finalizeSynthetic()
1801 const SectionBase *sec = def->section; in fixSymbolsAfterShrinking() local
1802 if (!sec) in fixSymbolsAfterShrinking()
1805 const InputSectionBase *inputSec = dyn_cast<InputSectionBase>(sec->repl); in fixSymbolsAfterShrinking()
1944 if (auto *sec = dyn_cast<OutputSection>(base)) in finalizeSections() local
1945 addStartStopSymbols(sec); in finalizeSections()
1965 OutputSection *sec = findSection(".sdata"); in finalizeSections() local
1967 addOptionalRegular("__global_pointer$", sec ? sec : Out::elfHeader, in finalizeSections()
2098 if (auto *sec = dyn_cast<OutputSection>(base)) in finalizeSections() local
2099 outputSections.push_back(sec); in finalizeSections()
2102 for (OutputSection *sec : outputSections) { in finalizeSections()
2103 auto i = config->sectionStartMap.find(sec->name); in finalizeSections()
2105 sec->addrExpr = [=] { return i->second; }; in finalizeSections()
2123 OutputSection *sec = outputSections[i]; in finalizeSections() local
2124 sec->sectionIndex = i + 1; in finalizeSections()
2125 sec->shName = in.shStrTab->addString(sec->name); in finalizeSections()
2241 for (OutputSection *sec : outputSections) in finalizeSections()
2242 sec->finalize(); in finalizeSections()
2297 if (OutputSection *sec = findSection(".ARM.exidx")) in addStartEndSymbols() local
2298 define("__exidx_start", "__exidx_end", sec); in addStartEndSymbols()
2307 void Writer<ELFT>::addStartStopSymbols(OutputSection *sec) { in addStartStopSymbols() argument
2308 StringRef s = sec->name; in addStartStopSymbols()
2311 addOptionalRegular(saver.save("__start_" + s), sec, 0, in addStartStopSymbols()
2313 addOptionalRegular(saver.save("__stop_" + s), sec, -1, in addStartStopSymbols()
2317 static bool needsPtLoad(OutputSection *sec) { in needsPtLoad() argument
2318 if (!(sec->flags & SHF_ALLOC)) in needsPtLoad()
2324 if ((sec->flags & SHF_TLS) && sec->type == SHT_NOBITS) in needsPtLoad()
2391 for (OutputSection *sec : outputSections) { in createPhdrs()
2392 if (sec->partition != partNo || !needsPtLoad(sec)) in createPhdrs()
2394 if (isRelroSection(sec)) { in createPhdrs()
2397 relRo->add(sec); in createPhdrs()
2399 error("section: " + sec->name + " is not contiguous with other relro" + in createPhdrs()
2403 relroEnd = sec; in createPhdrs()
2407 for (OutputSection *sec : outputSections) { in createPhdrs()
2408 if (!needsPtLoad(sec)) in createPhdrs()
2417 if (sec->partition != partNo) { in createPhdrs()
2418 if (isMain && sec->partition == 255) in createPhdrs()
2419 addHdr(PT_LOAD, computeFlags(sec->getPhdrFlags()))->add(sec); in createPhdrs()
2430 uint64_t newFlags = computeFlags(sec->getPhdrFlags()); in createPhdrs()
2432 load && !sec->lmaExpr && sec->lmaRegion == load->firstSec->lmaRegion; in createPhdrs()
2433 if (!(load && newFlags == flags && sec != relroEnd && in createPhdrs()
2434 sec->memRegion == load->firstSec->memRegion && in createPhdrs()
2440 load->add(sec); in createPhdrs()
2445 for (OutputSection *sec : outputSections) in createPhdrs()
2446 if (sec->partition == partNo && sec->flags & SHF_TLS) in createPhdrs()
2447 tlsHdr->add(sec); in createPhdrs()
2452 if (OutputSection *sec = part.dynamic->getParent()) in createPhdrs() local
2453 addHdr(PT_DYNAMIC, sec->getPhdrFlags())->add(sec); in createPhdrs()
2493 for (OutputSection *sec : outputSections) { in createPhdrs()
2494 if (sec->partition != partNo) in createPhdrs()
2496 if (sec->type == SHT_NOTE && (sec->flags & SHF_ALLOC)) { in createPhdrs()
2497 if (!note || sec->lmaExpr || note->lastSec->alignment != sec->alignment) in createPhdrs()
2499 note->add(sec); in createPhdrs()
2628 auto needsOffset = [](OutputSection &sec) { in assignFileOffsetsBinary() argument
2629 return sec.type != SHT_NOBITS && (sec.flags & SHF_ALLOC) && sec.size > 0; in assignFileOffsetsBinary()
2632 for (OutputSection *sec : outputSections) in assignFileOffsetsBinary()
2633 if (needsOffset(*sec)) { in assignFileOffsetsBinary()
2634 sec->offset = sec->getLMA(); in assignFileOffsetsBinary()
2635 minAddr = std::min(minAddr, sec->offset); in assignFileOffsetsBinary()
2640 for (OutputSection *sec : outputSections) in assignFileOffsetsBinary()
2641 if (needsOffset(*sec)) { in assignFileOffsetsBinary()
2642 sec->offset -= minAddr; in assignFileOffsetsBinary()
2643 fileSize = std::max(fileSize, sec->offset + sec->size); in assignFileOffsetsBinary()
2665 for (OutputSection *sec : outputSections) { in assignFileOffsets()
2666 if (!(sec->flags & SHF_ALLOC)) in assignFileOffsets()
2668 off = setFileOffset(sec, off); in assignFileOffsets()
2674 lastRX->lastSec == sec) in assignFileOffsets()
2677 for (OutputSection *sec : outputSections) in assignFileOffsets()
2678 if (!(sec->flags & SHF_ALLOC)) in assignFileOffsets()
2679 off = setFileOffset(sec, off); in assignFileOffsets()
2693 for (OutputSection *sec : outputSections) { in assignFileOffsets()
2694 if (sec->type == SHT_NOBITS) in assignFileOffsets()
2696 if ((sec->offset > fileSize) || (sec->offset + sec->size > fileSize)) in assignFileOffsets()
2697 error("unable to place section " + sec->name + " at file offset " + in assignFileOffsets()
2698 rangeToString(sec->offset, sec->size) + in assignFileOffsets()
2742 OutputSection *sec; member
2760 if (b.offset >= a.offset + a.sec->size) in checkOverlap()
2765 if (isVirtualAddr && a.sec->inOverlay && b.sec->inOverlay) in checkOverlap()
2768 errorOrWarn("section " + a.sec->name + " " + name + in checkOverlap()
2769 " range overlaps with " + b.sec->name + "\n>>> " + a.sec->name + in checkOverlap()
2770 " range is " + rangeToString(a.offset, a.sec->size) + "\n>>> " + in checkOverlap()
2771 b.sec->name + " range is " + in checkOverlap()
2772 rangeToString(b.offset, b.sec->size)); in checkOverlap()
2796 for (OutputSection *sec : outputSections) in checkSections()
2797 if (sec->size > 0 && sec->type != SHT_NOBITS && in checkSections()
2798 (!config->oFormatBinary || (sec->flags & SHF_ALLOC))) in checkSections()
2799 fileOffs.push_back({sec, sec->offset}); in checkSections()
2814 for (OutputSection *sec : outputSections) in checkSections()
2815 if (sec->size > 0 && (sec->flags & SHF_ALLOC) && !(sec->flags & SHF_TLS)) in checkSections()
2816 vmas.push_back({sec, sec->addr}); in checkSections()
2823 for (OutputSection *sec : outputSections) in checkSections()
2824 if (sec->size > 0 && (sec->flags & SHF_ALLOC) && !(sec->flags & SHF_TLS)) in checkSections()
2825 lmas.push_back({sec, sec->getLMA()}); in checkSections()
2848 if (OutputSection *sec = findSection(".text")) { in getEntryAddr() local
2851 utohexstr(sec->addr)); in getEntryAddr()
2852 return sec->addr; in getEntryAddr()
2903 for (OutputSection *sec : outputSections) in writeHeader()
2904 sec->writeHeaderTo<ELFT>(++sHdrs); in writeHeader()
2940 for (OutputSection *sec : outputSections) in writeSectionsBinary()
2941 if (sec->flags & SHF_ALLOC) in writeSectionsBinary()
2942 sec->writeTo<ELFT>(Out::bufferStart + sec->offset); in writeSectionsBinary()
2985 for (OutputSection *sec : outputSections) in writeSections()
2986 if (sec->type == SHT_REL || sec->type == SHT_RELA) in writeSections()
2987 sec->writeTo<ELFT>(Out::bufferStart + sec->offset); in writeSections()
2989 for (OutputSection *sec : outputSections) in writeSections()
2990 if (sec->type != SHT_REL && sec->type != SHT_RELA) in writeSections()
2991 sec->writeTo<ELFT>(Out::bufferStart + sec->offset); in writeSections()
2995 for (OutputSection *sec : outputSections) in writeSections()
2996 if (sec->type == SHT_REL || sec->type == SHT_RELA) in writeSections()
2997 sec->checkDynRelAddends(Out::bufferStart); in writeSections()