zelos
zelos copied to clipboard
Invalid PC value on ARM, EABI5 version 1 (SYSV)
Describe the bug It appears that PC register on 32 bit ARM has an invalid value, resulting in invalid PC-relative resolution.
To Reproduce Steps to reproduce the behavior:
- Download this
- Type
py -3 -m zelos ./libzlib.so
- See an error message
- Open this place in IDA and see correct address resolution (
0x15FD8
instead of0x15FD0
)
Expected behavior Correct PC value should not point at the exact address like IP on x86
Screenshots Not applicable
Additional context According to the ARM IC.
In ARM state, the value of the PC is the address of the current instruction plus 8 bytes. In Thumb state:
- For B, BL, CBNZ, and CBZ instructions, the value of the PC is the address of the current instruction plus 4 bytes.
- For all other instructions that use labels, the value of the PC is the address of the current instruction plus 4 bytes, with bit[1] of the result cleared to 0 to make it word-aligned.