getRelocatedValue may compute incorrect value for SHT_RELA-typed relocation entries.
uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off,
// This formula is correct for REL, but may be incorrect for RELA if the value // stored in the location (getUnsigned(Off, Size)) is not zero. return getUnsigned(Off, Size) + Rel->Value;
In this patch, we
- refactor these visit* functions to include a new parameter uint64_t A. Since these visit* functions are no longer used as visitors, rename them to resolve*. + REL: A is used as the addend. A is the value stored in the location where the relocation applies: getUnsigned(Off, Size) + RELA: The addend encoded in RelocationRef is used, e.g. getELFAddend(R)
- and add another set of supports* functions to check if a given relocation type is handled. DWARFObjInMemory uses them to fail early.