Lines Matching defs:sec
46 void relocateAlloc(InputSectionBase &sec, uint8_t *buf) const override;
593 void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
594 uint64_t secAddr = sec.getOutputSection()->addr;
595 if (auto *s = dyn_cast<InputSection>(&sec))
597 else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
601 const ArrayRef<Relocation> relocs = sec.relocs();
606 sec.getRelocTargetVA(sec.file, rel.type, rel.addend,
664 errorOrWarn(sec.getLocation(rel.offset) + ": ULEB128 value " +
671 errorOrWarn(sec.getLocation(rel.offset) +
686 for (InputSection *sec : getInputSections(*osec, storage)) {
687 sec->relaxAux = make<RelaxAux>();
688 if (sec->relocs().size()) {
689 sec->relaxAux->relocDeltas =
690 std::make_unique<uint32_t[]>(sec->relocs().size());
691 sec->relaxAux->relocTypes =
692 std::make_unique<RelType[]>(sec->relocs().size());
711 if (auto *sec = dyn_cast_or_null<InputSection>(d->section))
712 if (sec->flags & SHF_EXECINSTR && sec->relaxAux) {
713 // If sec is discarded, relaxAux will be nullptr.
714 sec->relaxAux->anchors.push_back({d->value, d, false});
715 sec->relaxAux->anchors.push_back({d->value + d->size, d, true});
725 for (InputSection *sec : getInputSections(*osec, storage)) {
726 llvm::sort(sec->relaxAux->anchors, [](auto &a, auto &b) {
735 static void relaxCall(const InputSection &sec, size_t i, uint64_t loc,
737 const bool rvc = getEFlags(sec.file) & EF_RISCV_RVC;
739 const uint64_t insnPair = read64le(sec.content().data() + r.offset);
746 sec.relaxAux->relocTypes[i] = R_RISCV_RVC_JUMP;
747 sec.relaxAux->writes.push_back(0xa001); // c.j
751 sec.relaxAux->relocTypes[i] = R_RISCV_RVC_JUMP;
752 sec.relaxAux->writes.push_back(0x2001); // c.jal
755 sec.relaxAux->relocTypes[i] = R_RISCV_JAL;
756 sec.relaxAux->writes.push_back(0x6f | rd << 7); // jal
762 static void relaxTlsLe(const InputSection &sec, size_t i, uint64_t loc,
767 uint32_t insn = read32le(sec.content().data() + r.offset);
772 sec.relaxAux->relocTypes[i] = R_RISCV_RELAX;
777 sec.relaxAux->relocTypes[i] = R_RISCV_32;
779 sec.relaxAux->writes.push_back(setLO12_I(insn, val));
783 sec.relaxAux->relocTypes[i] = R_RISCV_32;
785 sec.relaxAux->writes.push_back(setLO12_S(insn, val));
790 static void relaxHi20Lo12(const InputSection &sec, size_t i, uint64_t loc,
802 sec.relaxAux->relocTypes[i] = R_RISCV_RELAX;
806 sec.relaxAux->relocTypes[i] = INTERNAL_R_RISCV_GPREL_I;
809 sec.relaxAux->relocTypes[i] = INTERNAL_R_RISCV_GPREL_S;
814 static bool relax(InputSection &sec) {
815 const uint64_t secAddr = sec.getVA();
816 const MutableArrayRef<Relocation> relocs = sec.relocs();
817 auto &aux = *sec.relaxAux;
847 relaxCall(sec, i, loc, r, remove);
854 relaxTlsLe(sec, i, loc, r, remove);
860 relaxHi20Lo12(sec, i, loc, r, remove);
904 sec.bytesDropped = delta;
928 for (InputSection *sec : getInputSections(*osec, storage))
929 changed |= relax(*sec);
941 for (InputSection *sec : getInputSections(*osec, storage)) {
942 RelaxAux &aux = *sec->relaxAux;
946 MutableArrayRef<Relocation> rels = sec->relocs();
947 ArrayRef<uint8_t> old = sec->content();
953 sec->content_ = p;
954 sec->size = newSize;
955 sec->bytesDropped = 0;
1061 unsigned &mergedXlen, const InputSectionBase *sec,
1065 errorOrWarn(toString(sec) + ": " + s + ": " +
1186 for (const InputSectionBase *sec : sections) {
1188 if (Error e = parser.parse(sec->content(), llvm::endianness::little))
1189 warn(toString(sec) + ": " + llvm::toString(std::move(e)));
1197 firstStackAlign = sec;
1200 errorOrWarn(toString(sec) + " has stack_align=" + Twine(*i) +
1215 mergeArch(exts, xlen, sec, *s);
1229 firstAtomicAbi = sec;
1231 mergeAtomic(r.first, firstAtomicAbi, sec,