Commit f8825490 authored by Ludovico de Nittis's avatar Ludovico de Nittis
Browse files

utils: Add public/private knowledge about symbol versions and symbols



We are now able to list the symbol versions and/or symbols that are
known to be public/private.

This is especially useful for comparing libraries that removed symbol
versions, or symbols, from one release to another. As this already
happened multiple times in the past, like for example with
`libdrm_nouveau.so.2` or `libedit.so.2`.
Signed-off-by: Ludovico de Nittis's avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent 497702e7
......@@ -474,29 +474,30 @@ capture_one( const char *soname, const capture_options *options,
{
const char *needed_path_in_container = container.needed[0].path;
int decision;
const library_cmp_function *comparators = options->comparators;
const library_details *details = NULL;
library_details details = {};
const library_details *known = NULL;
details = library_knowledge_lookup( &options->knowledge,
needed_name );
known = library_knowledge_lookup( &options->knowledge,
needed_name );
if( details != NULL )
DEBUG( DEBUG_TOOL, "Found library-specific details for \"%s\"",
needed_name );
if( details != NULL && details->comparators != NULL)
if( known != NULL )
{
DEBUG( DEBUG_TOOL, "Found library-specific comparators for \"%s\"",
DEBUG( DEBUG_TOOL, "Found library-specific details for \"%s\"",
needed_name );
comparators = details->comparators;
details = *known;
}
decision = library_cmp_list_iterate( comparators,
needed_name,
/* Not const-correct, but we don't actually modify or free it */
details.name = (char *) needed_name;
if( details.comparators == NULL )
details.comparators = options->comparators;
decision = library_cmp_list_iterate( &details,
needed_path_in_container,
option_container,
needed_path_in_provider,
option_provider);
option_provider );
if( decision > 0 )
{
......
This diff is collapsed.
......@@ -20,9 +20,12 @@
#include <stdbool.h>
#include <stdio.h>
typedef struct _library_details library_details;
/*
* library_cmp_function:
* @soname: The name under which we searched for the library
* @details: The details about the library we are interested in and how
* to compare it
* @container_path: The path to the library in the container
* @container_root: The path to the top-level directory of the container
* @provider_path: The path to the library in the provider
......@@ -36,18 +39,35 @@
* appear the same or we cannot tell, or positive if the provider version
* appears newer.
*/
typedef int ( *library_cmp_function ) ( const char *soname,
typedef int ( *library_cmp_function ) ( const library_details *details,
const char *container_path,
const char *container_root,
const char *provider_path,
const char *provider_root );
/*
* library_details:
* @name: The name we look for the library under, normally a SONAME
* @comparators: Functions to use to compare versions, or %NULL for
* default behaviour
* @public_symbol_versions: An array of patterns to discriminate public
* versions from private versions
* @public_symbols: An array of patterns to discriminate public
* symbols from private symbols
*/
struct _library_details
{
char *name;
library_cmp_function *comparators;
char **public_symbol_versions;
char **public_symbols;
};
library_cmp_function *library_cmp_list_from_string( const char *spec,
const char *delimiters,
int *code,
char **message );
int library_cmp_list_iterate( const library_cmp_function *comparators,
const char *soname,
int library_cmp_list_iterate( const library_details *details,
const char *container_path,
const char *container_root,
const char *provider_path,
......@@ -67,18 +87,6 @@ typedef struct
#define LIBRARY_KNOWLEDGE_INIT { NULL }
/*
* library_details:
* @name: The name we look for the library under, normally a SONAME
* @comparators: Functions to use to compare versions, or %NULL for
* default behaviour
*/
typedef struct
{
char *name;
library_cmp_function *comparators;
} library_details;
bool library_knowledge_load_from_stream( library_knowledge *self,
FILE *stream, const char *name,
int *code, char **message );
......
......@@ -629,6 +629,25 @@ xasprintf( char **dest, const char *format, ...)
return ret;
}
/**
* free_strv_full:
* @strings_array: (nullable) (array zero-terminated=1): array of strings
* to free
*
* Completely frees the given @strings_array.
* If @strings_array is %NULL, this function simply returns.
*/
void
free_strv_full( char **strings_array )
{
if( strings_array )
{
for( size_t i = 0; strings_array[i] != NULL; i++ )
free( strings_array[i] );
free( strings_array );
}
}
/*
* _capsule_set_error_literal:
* @code_dest: (out) (optional): used to return an errno value
......
......@@ -108,6 +108,7 @@ char *xstrdup( const char *s );
void *xrealloc( void *ptr, size_t size ) __attribute__((alloc_size(2)));
void *xcalloc( size_t n, size_t size ) __attribute__((alloc_size(1, 2), malloc));
int xasprintf( char **s, const char *format, ...) __attribute__((format(printf, 2, 3)));
void free_strv_full( char **strings_array );
/*
* _capsule_steal_pointer:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment