[PATCHv1 1/2] libdwfl: specify optional sysroot to search for shared libraries

Dmitry V. Levin ldv@altlinux.org
Sun Jan 20 22:08:00 GMT 2019


On Sun, Jan 20, 2019 at 03:00:45PM +0000, Luke Diamand wrote:
> When searching the list of modules in a core file, if the core was
> generated on a different system to the current one, we need to look
> in a sysroot for the various shared objects.
> 
> For example, we might be looking at a core file from an ARM system
> using elfutils running on an x86 host.
> 
> This change adds a new function, dwfl_set_sysroot(), which then
> gets used when searching for libraries.
[...]
> --- a/libdwfl/link_map.c
> +++ b/libdwfl/link_map.c
> @@ -388,8 +388,21 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
>        if (name != NULL)
>  	{
>  	  /* This code is mostly inlined dwfl_report_elf.  */
> -	  // XXX hook for sysroot
> -	  int fd = open (name, O_RDONLY);
> +	  char *path_name;
> +	  const char *sysroot = dwfl->sysroot;
> +	  int rc;
> +
> +	  /* don't look in the sysroot if the path is already inside the sysroot */
> +	  bool name_in_sysroot = strncmp(name, sysroot, strlen(sysroot)) == 0;

Is sysroot guaranteed to be non-NULL at this point?
If yes, is sysroot guaranteed to end with "/"?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/elfutils-devel/attachments/20190120/7b7fc8b5/attachment.sig>


More information about the Elfutils-devel mailing list