Fangrui Song c03fdd3403 [ELF] Fix the branch range computation when reusing a thunk
Notation: dst is `t->getThunkTargetSym()->getVA()`

On AArch64, when `src-0x8000000-r_addend <= dst < src-0x8000000`, the condition
`target->inBranchRange(rel.type, src, rel.sym->getVA(rel.addend))` may
incorrectly consider a thunk reusable.
`rel.addend = -getPCBias(rel.type)` resets the addend to 0 for AArch64/PPC
and the zero addend is used by `rel.sym->getVA(rel.addend)` to check
out-of-range relocations.

See the test for a case this computation is wrong:
`error: a.o:(.text_high+0x4): relocation R_AARCH64_JUMP26 out of range: -134217732 is not in [-134217728, 134217727]`
I have seen a real world case with r_addend=19960.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D117734
2022-01-24 09:03:21 -08:00
..
2021-02-08 08:55:29 -08:00
2021-02-08 08:55:29 -08:00
2021-02-08 08:55:29 -08:00
2021-02-08 08:55:29 -08:00
2021-02-08 08:55:29 -08:00
2018-07-05 16:03:20 +00:00
2020-06-01 10:19:41 -07:00
2021-10-31 12:10:43 -07:00
2020-03-27 11:56:02 -07:00
2020-03-31 12:41:18 +01:00
2019-09-07 10:42:11 +00:00
2021-01-22 19:07:02 -08:00
2020-04-13 19:32:44 -05:00
2021-10-04 11:10:10 +01:00
2021-10-04 11:10:10 +01:00
2021-10-04 11:10:10 +01:00
2021-10-04 11:10:10 +01:00
2018-08-08 14:50:33 +00:00
2018-08-08 14:50:33 +00:00
2018-08-08 14:50:33 +00:00
2020-08-07 22:08:44 -07:00
2021-02-05 09:37:37 -08:00
2020-06-01 10:19:41 -07:00
2022-01-15 22:33:51 -08:00
2022-01-15 22:33:51 -08:00
2019-07-25 07:12:23 +00:00
2019-09-07 10:42:11 +00:00
2019-09-07 10:42:11 +00:00
2021-10-31 12:10:43 -07:00
2019-02-06 01:00:49 +00:00
2021-10-31 12:10:43 -07:00