diff options
Diffstat (limited to 'checklink/ELF_utils.ml')
-rw-r--r-- | checklink/ELF_utils.ml | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/checklink/ELF_utils.ml b/checklink/ELF_utils.ml index d5c205a8..5244dc83 100644 --- a/checklink/ELF_utils.ml +++ b/checklink/ELF_utils.ml @@ -65,19 +65,16 @@ let strip_mangling (s: string): string = with Not_found -> s (** - Returns the index of the first symbol matching the specified name, if it - exists. + Returns the list of all symbols matching the specified name. *) -let ndx_of_sym_name (e: elf) (name: string): int option = - array_exists - (fun x -> strip_versioning x.st_name = strip_mangling name) - e.e_symtab +let ndxes_of_sym_name (e: elf) (name: string): int list = + try StringMap.find (strip_mangling name) e.e_syms_by_name with Not_found -> [] (** - Returns the list of all symbols matching the specified name. + Returns the index of the first symbol matching the specified name, if it + exists. *) -let ndxes_of_sym_name (e: elf) (name: string): int list = - List.map fst - (List.filter - (fun (_, x) -> strip_versioning x.st_name = strip_mangling name) - (Array.to_list (Array.mapi (fun a b -> (a, b)) e.e_symtab))) +let ndx_of_sym_name (e: elf) (name: string): int option = + match ndxes_of_sym_name e name with + | [] -> None + | h::_ -> Some(h) |