From 00d087c629185f8237488aaa992ebbf491841a68 Mon Sep 17 00:00:00 2001 From: Evgenii Stepanov Date: Fri, 31 Aug 2018 14:27:32 -0700 Subject: [PATCH] (arm64) Extend branch range in __memcpy_chk. Conditional branch has limited range (1MB) and can not be extended by the linker. The current distance (in walleye build) is 500KB, about half of the maximum. HWASan pushes it over the limit. Replace conditional branch with regular branch, which has longer range (26 vs 19 bits offset) and can be extended in the linker if needed. Bug: 112437884 Bug: 12231437 Test: SANITIZE_TARGET=hwaddress Change-Id: Idc083fb557ab3a859541beb009809992406a6703 --- libc/arch-arm64/generic/bionic/__memcpy_chk.S | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libc/arch-arm64/generic/bionic/__memcpy_chk.S b/libc/arch-arm64/generic/bionic/__memcpy_chk.S index 42177758b..a6eeca477 100644 --- a/libc/arch-arm64/generic/bionic/__memcpy_chk.S +++ b/libc/arch-arm64/generic/bionic/__memcpy_chk.S @@ -30,8 +30,11 @@ ENTRY(__memcpy_chk) cmp x2, x3 - bls memcpy + // Direct b.ls memcpy may not have enough range + b.hi .L_memcpy_chk_fail + b memcpy +.L_memcpy_chk_fail: // Preserve for accurate backtrace. stp x29, x30, [sp, -16]! .cfi_def_cfa_offset 16