• chadversary's avatar
    util: Query build-id by symbol address, not library name · 5c98d382
    chadversary authored
    This patch renames build_id_find_nhdr() to
    build_id_find_nhdr_for_addr(), and changes it to never examine the
    library name.
    
    Tested on Fedora by confirming that build_id_get_data() returns the same
    build-id as the file(1) tool. For BSD, I confirmed that the API used
    (dladdr() and struct Dl_info) is documented in FreeBSD's manpages.
    
    This solves two problems:
    
        - We can now the query the build-id without knowing the installed library's
          filename.
    
          This matters because Android requires specific filenames for HAL
          modules, such as "/vendor/lib/hw/vulkan.${board}.so". The HAL
          filenames do not follow the Unix convention of "libfoo.so".  In
          other words, the same query code will now work on Linux and Android.
    
        - Querying the build-id now works correctly when the process
          contains multiple shared objects with the same basename.
          (Admittedly, this is a highly unlikely scenario).
    
    Cc: Jonathan Gray <jsg@jsg.id.au>
    Reviewed-by: Matt Turner's avatarMatt Turner <mattst88@gmail.com>
    Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
    5c98d382
build_id.h 1.45 KB