keystone
keystone copied to clipboard
ARM branch backwards with SYM_RESOLVER fails
(I'm using thumb)
When using the SYM_RESOLVER to jump to a symbol at lower address, the result is the same as encoding 'bl #0'
The reason is that negative relative values cause IsResolved to be set to false in ARMAsmBackend::processFixupValue. The following patch fixes it for me:
index f64d51b..d843ea8 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -699,7 +699,7 @@ void ARMAsmBackend::processFixupValue(const MCAssembler &Asm,
// If the symbol is out of range, produce a relocation and hope the
// linker can handle it. GNU AS produces an error in this case.
- if (Sym->isExternal() || Value >= 0x400004)
+ if (Sym->isExternal() || ((Value >= 0x400004) && (Value <= (uint64_t)(-0x400000))))
IsResolved = false;
}
// We must always generate a relocation for BL/BLX instructions if we have```
Just tried this on the master branch and this issue is still as valid as it was 18 months ago. Pull request #355 submitted over a year ago fixes it.