Given
.weak target
.global _start
_start:
b target
The intention is that the branch goes to the instruction after the branch, effectively turning it on a nop. The branch adds the runtime PC, but we were adding it statically too.
I noticed the oddity by inspection, but llvm-objdump seems to agree, since it now prints things like:
b #-4 <_start+0x4>
Might be worth making the default case unreachable.
The ABI (ARM ELF 4.5.1.1) says:
During linking, the value of an undefined weak reference is:
The intention for just returning A was that default: would cover the absolute case. However as long as getARMUndefinedRelativeWeakVA is only called from pc-relative locations this wouldn't happen so I don't expect the default case to ever get hit.