The ARM 32 and 64-bit ABI does not use 0 for undefined weak references that are used in PC relative relocations. In particular:
- A branch relocation to an undefined weak resolves to the next instruction.
- In all other cases the symbol resolves to the place so that S + A - P resolves to A.
The branch relocation resolving to the next instruction is the most important as it is a common idiom in statically linked ARM and AArch64 code to use branches to weak references to initialization functions of optional parts of the program. More importantly it can also cause spurious relocation out of range errors as the (S + A) - P of the branch relocation evaluates to (0 + A) - P which is often a large negative number.
References:
- ARM: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044f/IHI0044F_aaelf.pdf
- Section 4.5.1.1 Weak references and 4.6.1.4 Static ARM Relocations, search for Call and Jump Relocations
- AArch64: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0056c/IHI0056C_beta_aaelf64.pdf
- Section 4.5.1.1 Weak references and Section 4.6.7 Call and Jump Relocations
uint64_t -> uint32_t?