Allow patching files compiled multiple times
PATCH 1/1 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(+)
lookup.c +18 -0
@@ -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)) {
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 44 lines · Ross Lagerwall
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(+)lookup.c +16
-0@@ -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)) {
lookup.c int lookup_local_symbol(struct lookup_table *table, char *name, char *hint, · line 182
Quoted 10 lines
lookup.c +2
-0curfile = 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?
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 38 lines · Ross Lagerwall
Quoted 37 lines · Ross Lagerwall
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(+)lookup.c +12
-0@@ -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).
Quoted 8 lines
lookup.c int lookup_local_symbol(struct lookup_table *table, char *name, char *hint, · line 175
Quoted 8 lines
lookup.c +5
-0+*/ +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 */
Perhaps add some logging as well?
Quoted 10 lines
lookup.c int lookup_local_symbol(struct lookup_table *table, char *name, char *hint,
Quoted 8 lines
lookup.c +1
-0}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?
This looks familiar, but how come it has no SoB?
Quoted 3 lines
Signature · 2 lines
-- Ross Lagerwall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel