================ @@ -1022,6 +1033,47 @@ ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const { uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin()); RelData.d.a = (Sec.p - SHT) / EF.getHeader().e_shentsize; RelData.d.b = 0; + if (reinterpret_cast<const Elf_Shdr *>(Sec.p)->sh_type == ELF::SHT_CREL) { + if (RelData.d.a + 1 > Crels.size()) { + Crels.resize(RelData.d.a + 1); + CrelErrs.resize(RelData.d.a + 1); + } + if (Crels[RelData.d.a].empty()) { + // Decode SHT_CREL. See ELFFile<ELFT>::decodeCrel. + ArrayRef<uint8_t> Content = cantFail(getSectionContents(Sec)); + DataExtractor Data(Content, ELFT::Endianness == endianness::little, + sizeof(typename ELFT::Addr)); + DataExtractor::Cursor Cur(0); + const uint64_t Hdr = Data.getULEB128(Cur); + const size_t Count = Hdr / 8; + const size_t FlagBits = Hdr & ELF::CREL_HDR_ADDEND ? 3 : 2; + const size_t Shift = Hdr % ELF::CREL_HDR_ADDEND; + uintX_t Offset = 0, Addend = 0; + uint32_t Symidx = 0, Type = 0; + for (size_t i = 0; i != Count; ++i) { ---------------- jh7370 wrote:
It really doesn't feel right that this whole algorithm is duplicated from the version in ELF.cpp. Surely they can be folded together into shared code somewhere? https://github.com/llvm/llvm-project/pull/97382 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits