Then you can make this to
assert(Type == R_AMDGPU_REL32); write32le(Loc, Val);
This runs before relocateOne, so it is better to do error checking here rather than later.
if (Type == R_AMDGPU_REL32) return R_PC; error("do not know how to handle relocation");
Please update the commit message -- this handles not ABS32 but REL32.
Do you really need all this just to generate a relocation?
Add better error handling.
I made a slight modification to your suggestion to avoid "no return value" warnings for getRelExpr().
LGTM. Please address Rafael's comment before committing.
Then you can make this to