<div dir="ltr">I'm using the LLVM object file C API to examine the contents of native object files on disk, and I couldn't find any way to retrieve the relocation addend. If it's not there, I'd like to add it, but I have some questions. From include/llvm-c/Object.h the APIs are:<br><br>// RelocationRef accessors<br>uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);<br>LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);<br>uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);<br>// NOTE: Caller takes ownership of returned string of the two<br>// following functions.<br>const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);<br>const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);<br><div><br></div><div>Of those, LLVMGetRelocationValueString looks promising (in some sense the Addend is an optional value on the relocation) but that function is simply strdup("").</div><div><br></div><div>It looks like not all file formats support addends on their relocations, so an implementation would have to check what type of object file it is and downcast to the right one, when it's an object file that supports addends. Is it OK for a GetAddend API to return 0 for relocations that have no addend or should the API expose the difference between a zero addend and not having an addend?</div><div><br></div><div></div><div>While looking through LLVM, I also found definitions of relocations in BinaryFormat library and RuntimeDyld. Should we use one of those instead? Do either of them replace the object file library (or at least its Relocation), or have C APIs to inspect object files?</div><div><br></div><div>Nick</div><div><br></div><div></div><div></div></div>