[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH LP-BUILD-TOOLS] Allow patching files compiled multiple times
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)) { -- 2.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |