From 8283a979b1bd0c92a4713ccb6f79f18dae2d7e93 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 20 Jan 2004 03:16:20 -0800 Subject: [PATCH] [PATCH] exception table search fix The exception table search code currently fails if addresses differ by more than 2G. This is only a problem when using the 4g/4g address space split, but it's more robust this way. Also, shuffle the comparison order n there so the least likely case comes last. --- lib/extable.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/extable.c b/lib/extable.c index a4b26ce3844f2..f95c5b0987722 100644 --- a/lib/extable.c +++ b/lib/extable.c @@ -60,16 +60,18 @@ search_extable(const struct exception_table_entry *first, { while (first <= last) { const struct exception_table_entry *mid; - long diff; mid = (last - first) / 2 + first; - diff = mid->insn - value; - if (diff == 0) - return mid; - if (diff < 0) - first = mid+1; + /* + * careful, the distance between entries can be + * larger than 2GB: + */ + if (mid->insn < value) + first = mid + 1; + else if (mid->insn > value) + last = mid - 1; else - last = mid-1; + return mid; } return NULL; } -- 2.53.0