Hooks: Use binary search for looking up functions

This requires a qsort() at initialization time, but makes function
lookups cheaper (especially when a function is not hooked).

We could even get rid of the qsort() by sorting the array of hooks
at or before compile-time (we don't add new hooks at runtime yet).