================ @@ -1278,29 +1285,69 @@ void ELFState<ELFT>::writeSectionContent( if (!Section.Relocations) return; + const bool IsCrel = Section.Type == llvm::ELF::SHT_CREL; const bool IsRela = Section.Type == llvm::ELF::SHT_RELA; + typename ELFT::uint OffsetMask = 8, Offset = 0, Addend = 0; + uint32_t Symidx = 0, Type = 0; + uint64_t CurrentOffset = CBA.getOffset(); + if (IsCrel) + for (const ELFYAML::Relocation &Rel : *Section.Relocations) + OffsetMask |= Rel.Offset; + const int Shift = llvm::countr_zero(OffsetMask); + if (IsCrel) + CBA.writeULEB128(Section.Relocations->size() * 8 + 4 + Shift); for (const ELFYAML::Relocation &Rel : *Section.Relocations) { const bool IsDynamic = Section.Link && (*Section.Link == ".dynsym"); - unsigned SymIdx = + uint32_t CurSymidx = Rel.Symbol ? toSymbolIndex(*Rel.Symbol, Section.Name, IsDynamic) : 0; - if (IsRela) { + if (IsCrel) { ---------------- MaskRay wrote:
I've thought about an abstraction. However, the variable and `toSymbolIndex` mechanism are different, making me feel that code sharing would be cumbersome... https://github.com/llvm/llvm-project/pull/91280 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits