Re: [PATCH v5 7/8] Validate symbol file using build-id

Aleksandar Ristovski
2014-03-20T13:13:13Z

On 14-03-19 06:31 PM, Jan Kratochvil wrote:
> Hi,
>
> consumer part of the "build-id" attribute.
>
>
> Jan
>
>
> gdb/
> 2014-02-26 Aleksandar Ristovski <aristovski@qnx.com
> Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Validate symbol file using build-id.
> * NEWS (Changes since GDB 7.7): Add 'set solib-build-id-force'
> and 'show solib-build-id-force'. Add build-id attribute.
> * solib-darwin.c (_initialize_darwin_solib): Assign validate value.
> * solib-dsbt.c (_initialize_dsbt_solib): Ditto.
> * solib-frv.c (_initialize_frv_solib): Ditto.
> * solib-ia64-hpux.c (ia64_hpux_target_so_ops): Ditto.
> * solib-irix.c (_initialize_irix_solib): Ditto.
> * solib-osf.c (_initialize_osf_solib): Ditto.
> * solib-pa64.c (_initialize_pa64_solib): Ditto.
> * solib-som.c (_initialize_som_solib): Ditto.
> * solib-spu.c (set_spu_solib_ops): Ditto.
> * solib-svr4.c: Include rsp-low.h.
> (NOTE_GNU_BUILD_ID_NAME): New define.
> (svr4_validate): New function.
> (library_list_start_library): Parse 'build-id' attribute.
> (svr4_library_attributes): Add 'build-id' attribute.
> (_initialize_svr4_solib): Assign validate value.
> * solib-target.c (solib.h): Include.
> (_initialize_solib_target): Assign validate value.
> * solib.c (solib_build_id_force, show_solib_build_id_force): New.
> (solib_map_sections): Use ops->validate.
> (clear_so): Free build_id.
> (default_solib_validate): New function.
> (_initialize_solib): Add "solib-build-id-force".
> * solib.h (default_solib_validate): New declaration.
> * solist.h (struct so_list): New fields 'build_idsz' and 'build_id'.
> (target_so_ops): New field 'validate'.
>
> gdb/doc/
> 2014-03-02 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.texinfo (Files): Add 'set solib-build-id-force'
> and 'show solib-build-id-force'.
> ---
> gdb/NEWS | 10 ++++++
> gdb/doc/gdb.texinfo | 38 ++++++++++++++++++++++
> gdb/solib-darwin.c | 1 +
> gdb/solib-dsbt.c | 1 +
> gdb/solib-frv.c | 1 +
> gdb/solib-ia64-hpux.c | 1 +
> gdb/solib-irix.c | 1 +
> gdb/solib-osf.c | 1 +
> gdb/solib-pa64.c | 1 +
> gdb/solib-som.c | 1 +
> gdb/solib-spu.c | 1 +
> gdb/solib-svr4.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++
> gdb/solib-target.c | 2 +
> gdb/solib.c | 62 +++++++++++++++++++++++++++++++++++-
> gdb/solib.h | 4 ++
> gdb/solist.h | 21 ++++++++++++
> 16 files changed, 230 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 2a384ba..629cc13 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -43,6 +43,12 @@ maint ada show ignore-descriptive-types
> the user manual for more details on descriptive types and the intended
> usage of this option.
>
> +set solib-build-id-force (on|off)
> +show solib-build-id-force
> + Inferior shared library and symbol file may contain unique build-id.
> + If both build-ids are present but they do not match then this setting
> + enables (on) or disables (off) loading of such symbol file.
> +
> * New features in the GDB remote stub, GDBserver
>
> ** New option --debug-format=option1[,option2,...] allows one to add
> @@ -51,6 +57,10 @@ maint ada show ignore-descriptive-types
> Timestamps can also be turned on with the
> "monitor set debug-format timestamps" command from GDB.
>
> + ** library-list-svr4 contains also optional attribute 'build-id' for
> + each library. GDB does not load library with build-id that
> + does not match such attribute.
> +
> * The 'record instruction-history' command now starts counting instructions
> at one. This also affects the instruction ranges reported by the
> 'record function-call-history' command when given the /i modifier.
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index b1b29bd..a4af3ec 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -17114,6 +17114,44 @@ libraries that were loaded by explicit user requests are not
> discarded.
> @end table
>
> +@table @code
> +@kindex set solib-build-id-force
> +@cindex override @value{GDBN} build-id check
> +@item set solib-build-id-force @var{mode}
> +Setting to override @value{GDBN} build-id check.
> +
> +Inferior shared libraries and symbol files may contain unique build-id.
> +By default @value{GDBN} will ignore symbol files with non-matching build-id
> +while printing:
> +
> +@smallexample
> + warning: Shared object "libfoo.so.1" could not be validated (remote
> + build ID 2bc1745e does not match local build ID a08f8767) and will be

I am not sure 'remote' adds any clarity here, on-contrary, I think it
will confuse. This could all be happening in local scenario as well. The
gist should be: inferior so build-id (i.e. build-id of the shared object
loaded in the inferior memory) does not match build-id of the so gdb
loaded to get symbols.

> + ignored; or use 'set solib-build-id-force'.
> +@end smallexample
> +
> +Turning on this setting would load such symbol file while still printing:
> +
> +@smallexample
> + warning: Shared object "libfoo.so.1" could not be validated (remote
> + build ID 2bc1745e does not match local build ID a08f8767) but it is
> + being loaded due to 'set solib-build-id-force'.
> +@end smallexample

The same here

> +
> +If remote build-id is present but it does not match local build-id (or local
> +build-id is not present) then this setting enables (@var{mode} is @code{on}) or
> +disables (@var{mode} is @code{off}) loading of such symbol file. On systems
> +where build-id is not present in the remote system this setting has no effect.
> +The default value is @code{off}.

and here. I think 'inferior' would be a lot more suitable reference than
"remote system".

---
Aleksandar Ristovski
QNX Software Systems