It seems like a better approach here is to use the same caching approach you use for dlsym above, but with the user supplied expression in place of `dlsym`.