aboutsummaryrefslogtreecommitdiffstats
path: root/checklink/Library.ml
diff options
context:
space:
mode:
authorvarobert <varobert@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-05-10 07:53:57 +0000
committervarobert <varobert@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-05-10 07:53:57 +0000
commit521dac4e0d950e6128b266b27eac1875d79200f1 (patch)
treef8b73847a64c769264065c88a31a413f3c3511e4 /checklink/Library.ml
parenta6044b4a4d38354411cbf535472776f4d5bb30d5 (diff)
downloadcompcert-521dac4e0d950e6128b266b27eac1875d79200f1.tar.gz
compcert-521dac4e0d950e6128b266b27eac1875d79200f1.zip
cchecklink now reads segments instead of sections
cchecklink is now using program header information to figure out the initial address space of the program, rather than the information in the parent section of each symbol. This decouples the resolution of symbols from inaccurate section information, reflecting more the actual program loading. Additionally, a -relaxed option has been added to deal with some strange ELFs, for instance when symbols data is dynamically bootstrapped from another place by boot code different than the program loader. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1893 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'checklink/Library.ml')
-rw-r--r--checklink/Library.ml14
1 files changed, 14 insertions, 0 deletions
diff --git a/checklink/Library.ml b/checklink/Library.ml
index 02590391..f55d9dea 100644
--- a/checklink/Library.ml
+++ b/checklink/Library.ml
@@ -134,3 +134,17 @@ let string_of_int32i = Int32.to_string
let string_of_positive p = string_of_int32i (positive_int32 p)
let string_of_z z = string_of_int32 (z_int32 z)
+
+let sorted_lookup (compare: 'a -> 'b -> int) (arr: 'a array) (v: 'b): 'a option =
+ let rec sorted_lookup_aux (i_from: int) (i_to: int): 'a option =
+ if i_from > i_to
+ then None
+ else
+ let i_mid = (i_from + i_to) / 2 in
+ let comp = compare arr.(i_mid) v in
+ if comp < 0 (* v_mid < v *)
+ then sorted_lookup_aux (i_mid + 1) i_to
+ else if comp > 0
+ then sorted_lookup_aux i_from (i_mid - 1)
+ else Some(arr.(i_mid))
+ in sorted_lookup_aux 0 (Array.length arr - 1)