[clang] [llvm] [MC,llvm-readobj,yaml2obj] Support CREL relocation format (PR #91280)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 07:50:32 PDT 2024


================
@@ -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)
----------------
smithp35 wrote:

Looking at the implementation of `encodeCrel` in ELFObjectWriter.cpp the algorithm used is the same, but there are some comment differences that could apply to both. I think it would be helpful to use the same comments in both implementations. For example at this point there is:
```
    // The delta offset and flags member may be larger than uint64_t. Special
    // case the first byte (3 flag bits and 4 offset bits). Other ULEB128 bytes
    // encode the remaining delta offset bits.
```

https://github.com/llvm/llvm-project/pull/91280


More information about the llvm-commits mailing list