From: "Ian Lance Taylor via gcc-patches" <gcc-patches@gcc.gnu.org>
To: Tom de Vries <tdevries@suse.de>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 1/9] [libbacktrace] Read .gnu_debugaltlink
Date: Wed, 16 Jan 2019 00:56:00 -0000 [thread overview]
Message-ID: <CAKOQZ8yv1UOB6Na1P-3nFDcNv9AHkTGjN-m+Q3CsYJzzynpRWA@mail.gmail.com> (raw)
In-Reply-To: <20181211101411.7067-2-tdevries@suse.de>
On Tue, Dec 11, 2018 at 2:14 AM Tom de Vries <tdevries@suse.de> wrote:
>
> Read the elf file pointed at by the .gnu_debugaltlink section, and verify that
> the build id matches.
>
> 2018-11-11 Tom de Vries <tdevries@suse.de>
>
> * elf.c (elf_add): Add and handle with_buildid_data and
> with_buildid_size parameters. Handle .gnu_debugaltlink section.
> (phdr_callback, backtrace_initialize): Add arguments to elf_add calls.
> ---
@@ -2899,6 +2918,27 @@ elf_add (struct backtrace_state *state, const
char *filename, int descriptor,
> }
> }
>
> + if (!debugaltlink_view_valid
> + && strcmp (name, ".gnu_debugaltlink") == 0)
> + {
> + const char *debugaltlink_data;
> + size_t debugaltlink_name_len;
> +
> + if (!backtrace_get_view (state, descriptor, shdr->sh_offset,
> + shdr->sh_size, error_callback, data,
> + &debugaltlink_view))
> + goto fail;
> +
> + debugaltlink_view_valid = 1;
> + debugaltlink_data = (const char *) debugaltlink_view.data;
> + debugaltlink_name = debugaltlink_data;
> + debugaltlink_name_len = strnlen (debugaltlink_data, shdr->sh_size);
> + debugaltlink_buildid_data = (debugaltlink_data
> + + debugaltlink_name_len
> + + 1);
> + debugaltlink_buildid_size = shdr->sh_size - debugaltlink_name_len - 1;
> + }
> +
This doesn't look quite right. debugaltlink_buildid_size is unsigned.
If there is some misunderstanding of the format it's possible for
strnlen to return shdr->sh_size. If it does,
debugaltlink_buildid_size will be set to a very large value.
> + if (debugaltlink_name != NULL)
> + {
> + int d;
> +
> + d = elf_open_debugfile_by_debuglink (state, filename, debugaltlink_name,
> + 0, error_callback, data);
> + if (d >= 0)
> + {
> + int ret;
> +
> + ret = elf_add (state, filename, d, base_address, error_callback, data,
> + fileline_fn, found_sym, found_dwarf, 0, 1,
> + debugaltlink_buildid_data, debugaltlink_buildid_size);
> + backtrace_release_view (state, &debugaltlink_view, error_callback,
> + data);
> + debugaltlink_view_valid = 0;
> + if (ret < 0)
> + {
> + backtrace_close (d, error_callback, data);
> + return ret;
> + }
> + }
> + else
> + {
> + error_callback (data,
> + "Could not open .gnu_debugaltlink", 0);
> + /* Don't goto fail, but try continue without the info in the
> + .gnu_debugaltlink. */
> + }
> + }
The strings passed to error_callback always start with a lowercase
letter (unless they start with something like ELF) because the
callback will most likely print them with some prefix.
More seriously, we don't call error_callback in any cases that
correspond to this. We just carry on. Is there any reason to call
error_callback here?
Ian
next prev parent reply other threads:[~2019-01-16 0:56 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-11 10:14 [PATCH 0/9] [libbacktrace] Handle .gnu_debugaltlink Tom de Vries
2018-12-11 10:14 ` [PATCH 4/9] [libbacktrace] Handle DW_FORM_GNU_strp_alt Tom de Vries
2019-01-16 1:07 ` Ian Lance Taylor via gcc-patches
2018-12-11 10:14 ` [PATCH 9/9] [libbacktrace] Add printdwarftest_dwz_cmp.sh test-case Tom de Vries
2019-01-17 13:58 ` Tom de Vries
2019-01-18 14:24 ` Ian Lance Taylor via gcc-patches
2019-01-19 0:45 ` Tom de Vries
2019-01-19 0:54 ` Ian Lance Taylor via gcc-patches
2019-01-22 22:03 ` Tom de Vries
2019-01-29 15:31 ` Ian Lance Taylor
2018-12-11 10:14 ` [PATCH 2/9] [libbacktrace] Add altlink field to struct dwarf_data Tom de Vries
2019-01-16 1:02 ` Ian Lance Taylor
2019-01-16 16:33 ` Tom de Vries
2019-01-16 16:34 ` Tom de Vries
2019-01-16 22:20 ` Tom de Vries
2019-01-16 22:25 ` Ian Lance Taylor
2019-01-16 17:17 ` Ian Lance Taylor
2019-01-16 22:18 ` Tom de Vries
2019-01-16 22:40 ` Ian Lance Taylor
2018-12-11 10:14 ` [PATCH 5/9] [libbacktrace] Unify function name preference handling Tom de Vries
2019-01-16 1:10 ` Ian Lance Taylor via gcc-patches
2018-12-11 10:14 ` [PATCH 3/9] [libbacktrace] Handle alt FORMS without .gnu_debugaltlink Tom de Vries
2019-01-16 1:06 ` Ian Lance Taylor
2019-01-16 16:34 ` Tom de Vries
2019-01-16 18:24 ` Ian Lance Taylor
2018-12-11 10:14 ` [PATCH 6/9] [libbacktrace] Factor out read_referenced_name_1 Tom de Vries
2019-01-16 1:15 ` Ian Lance Taylor via gcc-patches
2019-01-16 16:37 ` Tom de Vries
2019-01-16 18:26 ` Ian Lance Taylor
2018-12-11 10:14 ` [PATCH 1/9] [libbacktrace] Read .gnu_debugaltlink Tom de Vries
2019-01-16 0:56 ` Ian Lance Taylor via gcc-patches [this message]
2019-01-16 16:26 ` Tom de Vries
2019-01-16 17:15 ` Ian Lance Taylor via gcc-patches
2019-01-16 22:48 ` Tom de Vries
2019-01-16 23:21 ` Ian Lance Taylor
2018-12-11 10:14 ` [PATCH 8/9] [libbacktrace] Add btest_dwz test-case Tom de Vries
2019-01-16 1:19 ` Ian Lance Taylor
2019-01-16 16:39 ` Tom de Vries
2019-01-16 18:30 ` Ian Lance Taylor
2018-12-11 10:14 ` [PATCH 7/9] [libbacktrace] Handle DW_FORM_GNU_ref_alt Tom de Vries
2019-01-17 0:17 ` Tom de Vries
2019-01-17 0:36 ` Ian Lance Taylor
2019-01-17 14:14 ` Tom de Vries
2019-01-17 14:16 ` Tom de Vries
2019-01-18 14:26 ` Ian Lance Taylor
2019-01-22 22:17 ` [libbacktrace] Use size_t for low_offset/high_offset fields of struct unit Tom de Vries
2019-01-22 23:05 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKOQZ8yv1UOB6Na1P-3nFDcNv9AHkTGjN-m+Q3CsYJzzynpRWA@mail.gmail.com \
--to=gcc-patches@gcc.gnu.org \
--cc=iant@google.com \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).