summaryrefslogtreecommitdiff
path: root/lib_ppc/extable.c
diff options
context:
space:
mode:
authorZang Roy-r61911 <tie-fei.zang@freescale.com>2007-05-09 08:10:57 +0800
committerWolfgang Denk <wd@denx.de>2007-05-15 22:19:41 +0200
commit1b305bdc754c8468e1d5d858f5dcf8a7a0a4bb7a (patch)
treea97ee001de370eab8b26124bdc6ab3fcbfb934ef /lib_ppc/extable.c
parent5dfaa50eb819686bfba1927e8c5b8a70a4d65fd3 (diff)
Search the exception table with linear algorithm
Search the exception table with linear algorithm instead of bisecting algorithm. Because the exception table might be unsorted. Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
Diffstat (limited to 'lib_ppc/extable.c')
-rw-r--r--lib_ppc/extable.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/lib_ppc/extable.c b/lib_ppc/extable.c
index b14d661bb..8354411f0 100644
--- a/lib_ppc/extable.c
+++ b/lib_ppc/extable.c
@@ -52,30 +52,27 @@ search_one_table(const struct exception_table_entry *first,
const struct exception_table_entry *last,
unsigned long value)
{
- while (first <= last) {
- const struct exception_table_entry *mid;
- long diff;
-
- mid = (last - first) / 2 + first;
- if ((ulong) mid > CFG_MONITOR_BASE) {
- /* exception occurs in FLASH, before u-boot relocation.
- * No relocation offset is needed.
- */
- diff = mid->insn - value;
+ long diff;
+ if ((ulong) first > CFG_MONITOR_BASE) {
+ /* exception occurs in FLASH, before u-boot relocation.
+ * No relocation offset is needed.
+ */
+ while (first <= last) {
+ diff = first->insn - value;
if (diff == 0)
- return mid->fixup;
- } else {
- /* exception occurs in RAM, after u-boot relocation.
- * A relocation offset should be added.
- */
- diff = (mid->insn + gd->reloc_off) - value;
+ return first->fixup;
+ first++;
+ }
+ } else {
+ /* exception occurs in RAM, after u-boot relocation.
+ * A relocation offset should be added.
+ */
+ while (first <= last) {
+ diff = (first->insn + gd->reloc_off) - value;
if (diff == 0)
- return (mid->fixup + gd->reloc_off);
+ return (first->fixup + gd->reloc_off);
+ first++;
}
- if (diff < 0)
- first = mid + 1;
- else
- last = mid - 1;
}
return 0;
}