Skip to content
Snippets Groups Projects

Add inspect-library helper

Merged Ludovico de Nittis requested to merge wip/denittis/inspect-library into master
1 file
+ 4
11
Compare changes
  • Side-by-side
  • Inline
+ 4
11
@@ -45,8 +45,6 @@ main (int argc,
const char *version;
const char *symbol;
void *handle = NULL;
/* 4096 should be the standard PATH_MAX */
char library_path[4096];
struct link_map *dep_map = NULL;
const int SYMBOL_START = 2;
@@ -66,13 +64,15 @@ main (int argc,
clean_exit (handle);
return 1;
}
if (dlinfo (handle, RTLD_DI_ORIGIN, library_path) != 0)
/* Using RTLD_DI_LINKMAP insted of RTLD_DI_ORIGIN we don't need to worry
* about allocating a big enough array for the path. */
if (dlinfo (handle, RTLD_DI_LINKMAP, &dep_map) != 0 || dep_map == NULL)
{
fprintf (stderr, "Unable to obtain the path: %s\n", dlerror ());
clean_exit (handle);
return 1;
}
printf ("\n \"path\": \"%s\",\n", library_path);
printf ("\n \"path\": \"%s\",\n", dep_map->l_name);
printf (" \"missing_symbols\": [");
for (int i = SYMBOL_START; i < argc; i++)
@@ -112,13 +112,6 @@ main (int argc,
printf ("\n ]");
if (dlinfo (handle, RTLD_DI_LINKMAP, &dep_map) != 0)
{
fprintf (stderr, "Unable to obtain the dependencies list: %s\n", dlerror ());
clean_exit (handle);
return 1;
}
printf (",\n \"dependencies\": [");
if (dep_map != NULL)
{
Loading