From: Ross Lagerwall <ross.lagerwall@citrix.com>
To: xen-devel@lists.xen.org
Subject: Re: [PATCH LP-BUILD-TOOLS] Allow patching files compiled multiple times
Date: Mon, 5 Mar 2018 10:32:51 +0000 [thread overview]
Message-ID: <773fc51c-6bfb-6f27-a8fa-11b080c19447@citrix.com> (raw)
In-Reply-To: <20180223170828.9355-1-ross.lagerwall@citrix.com>
On 02/23/2018 05:08 PM, Ross Lagerwall wrote:
> gas prior to binutils commit fbdf9406b0 (appears in 2.27) outputs symbol
> table entries resulting from .file in reverse order. If we get two
> consecutive file symbols, prefer the first one if that names an object
> file or has a directory component (to cover multiply compiled files).
>
> This is the same workaround that was applied in Xen commit d37d63d4b548
> ("symbols: prefix static symbols with their source file names") for
> Xen's internal symbol table.
>
> This fixes building a livepatch for XSA-243.
> ---
> lookup.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/lookup.c b/lookup.c
> index 39125c6..645b91a 100644
> --- a/lookup.c
> +++ b/lookup.c
> @@ -149,16 +149,34 @@ int lookup_local_symbol(struct lookup_table *table, char *name, char *hint,
> struct symbol *sym, *match = NULL;
> int i;
> char *curfile = NULL;
> + enum { other, multi_source } last_type = other;
>
> memset(result, 0, sizeof(*result));
> for_each_symbol(i, sym, table) {
> if (sym->type == STT_FILE) {
> + const char *ext = strrchr(sym->name, '.');
> + int multi = strchr(sym->name, '/') ||
> + (ext && ext[1] == 'o');
> +
> + /*
> + * gas prior to binutils commit fbdf9406b0 (appears in
> + * 2.27) outputs symbol table entries resulting from
> + * .file in reverse order. If we get two consecutive
> + * file symbols, prefer the first one if that names an
> + * object file or has a directory component (to cover
> + * multiply compiled files).
> + */
> + if (last_type == multi_source)
> + continue;
> +
> if (!strcmp(sym->name, hint)) {
> curfile = sym->name;
> + last_type = multi ? multi_source : other;
> continue; /* begin hint file symbols */
> } else if (curfile)
> curfile = NULL; /* end hint file symbols */
> }
> + last_type = other;
> if (!curfile)
> continue;
> if (sym->bind == STB_LOCAL && !strcmp(sym->name, name)) {
>
Ping, Konrad?
--
Ross Lagerwall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-03-05 10:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 17:08 [PATCH LP-BUILD-TOOLS] Allow patching files compiled multiple times Ross Lagerwall
2018-03-05 10:32 ` Ross Lagerwall [this message]
2018-03-05 20:01 ` Konrad Rzeszutek Wilk
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=773fc51c-6bfb-6f27-a8fa-11b080c19447@citrix.com \
--to=ross.lagerwall@citrix.com \
--cc=xen-devel@lists.xen.org \
/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 NNTP newsgroup(s).