

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 files changed, 9 insertions(+), 7 deletions(-)

diff -puN lib/extable.c~generic-exception-table-sorting-2-fix lib/extable.c
--- 25/lib/extable.c~generic-exception-table-sorting-2-fix	2004-01-19 23:04:55.000000000 -0800
+++ 25-akpm/lib/extable.c	2004-01-19 23:06:11.000000000 -0800
@@ -60,16 +60,18 @@ search_extable(const struct exception_ta
 {
 	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;
 }

_
