mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-27 23:20:26 +09:00
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>
This commit is contained in:
parent
5dfaa50eb8
commit
1b305bdc75
@ -52,30 +52,27 @@ search_one_table(const struct exception_table_entry *first,
|
|||||||
const struct exception_table_entry *last,
|
const struct exception_table_entry *last,
|
||||||
unsigned long value)
|
unsigned long value)
|
||||||
{
|
{
|
||||||
while (first <= last) {
|
|
||||||
const struct exception_table_entry *mid;
|
|
||||||
long diff;
|
long diff;
|
||||||
|
if ((ulong) first > CFG_MONITOR_BASE) {
|
||||||
mid = (last - first) / 2 + first;
|
|
||||||
if ((ulong) mid > CFG_MONITOR_BASE) {
|
|
||||||
/* exception occurs in FLASH, before u-boot relocation.
|
/* exception occurs in FLASH, before u-boot relocation.
|
||||||
* No relocation offset is needed.
|
* No relocation offset is needed.
|
||||||
*/
|
*/
|
||||||
diff = mid->insn - value;
|
while (first <= last) {
|
||||||
|
diff = first->insn - value;
|
||||||
if (diff == 0)
|
if (diff == 0)
|
||||||
return mid->fixup;
|
return first->fixup;
|
||||||
|
first++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* exception occurs in RAM, after u-boot relocation.
|
/* exception occurs in RAM, after u-boot relocation.
|
||||||
* A relocation offset should be added.
|
* A relocation offset should be added.
|
||||||
*/
|
*/
|
||||||
diff = (mid->insn + gd->reloc_off) - value;
|
while (first <= last) {
|
||||||
|
diff = (first->insn + gd->reloc_off) - value;
|
||||||
if (diff == 0)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user