Checksum tracking and tweaking
cover Checksum tracking and tweaking
Sam and all,
we are having two kinds of problems with genksyms today: fake checksum changes without actual ABI changes, and changes which we would rather like to ignore (such as an additional field at the end of a structure that modules are not supposed to touch, for example).
I have thought about ways to improve genksyms and compute checksums differently to avoid those problems, but in the end I don't see a fundamentally better way. So here are some genksyms patches for at least making the checksums more easily manageable, if we cannot fully fix them.
In addition to the bugfixes (the first two patches), this allows genksyms to track checksum changes and report why a checksum changed (third patch), and to selectively ignore changes (fourth patch).
Any thoughts?
Thanks,
Andreas
PATCH 1/4 parser: fix the __attribute__ rule
Gcc __attribute__ definitions may occur repeatedly, e.g.,
static int foo __attribute__((__used__)) __attribute__((aligned (16)));
The genksyms parser does not understand this, and generates a syntax error. Fix this case.
--- scripts/genksyms/parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/genksyms/parse.y +1 -1
@@ -446,7 +446,7 @@ member_bitfield_declarator: attribute_opt: /* empty */ { $$ = NULL; } - | ATTRIBUTE_PHRASE + | attribute_opt ATTRIBUTE_PHRASE ; asm_definition:
Re: [genksyms patch 1/4] parser: fix the __attribute__ rule
Quoted 9 lines · Andreas Gruenbacher
Gcc
__attribute__definitions may occur repeatedly, e.g.,static int foo __attribute__((__used__)) __attribute__((aligned (16)));The genksyms parser does not understand this, and generates a syntax error. Fix this case.
Signed-off-by Andreas Gruenbacher <[email protected]>
Can I ask you to update the _shipped files and resend the patch. I have only bison 2.1 available on my box and
I do not want to downgrade when regenerating the bison files.
To do it just do a:
make clean
make allmodconfig
make GENERATE_PARSER=1 modules
Drop the other _shipped files that are not relevant (keywords.c and lex.c).
Sam
Re: [genksyms patch 1/4] parser: fix the __attribute__ rule
Quoted 1 line · Sam Ravnborg
Can I ask you to update the
_shippedfiles and resend the patch.
Sure, here is the version from Andrew's tree, with parse.c_shipped added.
Thanks,
Andreas
---------------------------
From: Andreas Gruenbacher <[email protected]>
We are having two kinds of problems with genksyms today: fake checksum changes without actual ABI changes, and changes which we would rather like to ignore (such as an additional field at the end of a structure that modules are not supposed to touch, for example).
I have thought about ways to improve genksyms and compute checksums differently to avoid those problems, but in the end I don't see a fundamentally better way. So here are some genksyms patches for at least making the checksums more easily manageable, if we cannot fully fix them.
In addition to the bugfixes (the first two patches), this allows genksyms to track checksum changes and report why a checksum changed (third patch), and to selectively ignore changes (fourth patch).
This patch:
Gcc __attribute__ definitions may occur repeatedly, e.g.,
static int foo __attribute__((__used__)) __attribute__((aligned (16)));
The genksyms parser does not understand this, and generates a syntax error. Fix this case.
---
scripts/genksyms/parse.c_shipped | 144 +++++++++++++++++++-------------------- scripts/genksyms/parse.y | 2 2 files changed, 73 insertions(+), 73 deletions(-)
scripts/genksyms/parse.y +1 -1
@@ -446,7 +446,7 @@ member_bitfield_declarator: attribute_opt: /* empty */ { $$ = NULL; } - | ATTRIBUTE_PHRASE + | attribute_opt ATTRIBUTE_PHRASE ; asm_definition:
scripts/genksyms/parse.c_shipped +72 -72
209 lines not on this page · raw message
_
Re: [genksyms patch 1/4] parser: fix the __attribute__ rule
Quoted 4 lines · Andreas Gruenbacher
Quoted 1 line · Sam Ravnborg
Can I ask you to update the
_shippedfiles and resend the patch.Sure, here is the version from Andrew's tree, with parse.c_shipped added.
Applied to kbuild-fixes.
Sam
PATCH 2/4 Include extern information in dumps
In reply to Andreas GruenbacherThe extern flag currently is not included in type dump files (genksyms --dump-types). Include that flag there for completeness.
--- scripts/genksyms/genksyms.c | 2 ++ 1 file changed, 2 insertions(+)
scripts/genksyms/genksyms.c +2 -0
@@ -546,6 +546,8 @@ int main(int argc, char **argv) }fputs (sym->name, dumpfile);putc (' ' , dumpfile); +if (sym->is_extern) +fputs ("extern " , dumpfile);print_list (dumpfile, sym->defn);putc ('\n' , dumpfile);
Re: [genksyms patch 2/4] Include extern information in dumps
Quoted 4 lines · Andreas Gruenbacher
The extern flag currently is not included in type dump files (genksyms --dump-types). Include that flag there for completeness.
Signed-off-by Andreas Gruenbacher <[email protected]>
Applied to kbuild-fixes.
The reamining two patches will wait until I get a closer look at them.
Sam
PATCH 3/4 Track symbol checksum changes
In reply to Andreas GruenbacherSometimes it is preferable to avoid changes of exported symbol checksums (to avoid breaking externally provided modules). When a checksum change occurs, it can be hard to figure out what caused this change: underlying types may have changed, or additional type information may simply have become available at the point where a symbol is exported.
Add a new --reference option to genksyms which allows it to report why checksums change, based on the type information dumps it creates with the --dump-types flag. Genksyms will read in such a dump from a previous run, and report which symbols have changed (and why).
The behavior can be controlled for an entire build as follows: If KBUILD_SYMTYPES is set, genksyms uses --dump-types to produce *.symtypes dump files. If any *.symref files exist, those will be used as the reference to check against. If KBUILD_PRESERVE is set, checksum changes will fail the build.
--- scripts/Makefile.build | 16 ++ scripts/genksyms/genksyms.c | 236 +++++++++++++++++++++++++++++++++++++++++--- scripts/genksyms/genksyms.h | 6 + 3 files changed, 239 insertions(+), 19 deletions(-)
scripts/genksyms/genksyms.c +220 -16
@@ -42,7 +42,8 @@ static FILE *debugfile;int cur_line =1 ;char *cur_filename; -static int flag_debug, flag_dump_defs, flag_dump_types, flag_warnings; +static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, + flag_preserve, flag_warnings;static const char *arch ="" ;static const char *mod_prefix ="" ;
@@ -58,6 +59,8 @@ static const char *const symbol_type_namstatic int equal_list (struct string_list *a,struct string_list *b);static void print_list (FILE * f,struct string_list *list); +static void print_location (void ); +static void print_type_name (enum symbol_type type,const char *name);/*----------------------------------------------------------------------*/
@@ -151,25 +154,66 @@ struct symbol *find_symbol(const char *nfor (sym = symtab[h]; sym; sym = sym->hash_next)if (map_to_ns (sym->type) ==map_to_ns (ns) && -strcmp (name, sym->name) ==0 ) +strcmp (name, sym->name) ==0 && + sym->is_declared)break ;return sym; } -struct symbol *add_symbol (const char *name,enum symbol_type type, -struct string_list *defn,int is_extern) +static int is_unknown_symbol (struct symbol *sym) +{ +struct string_list *defn; + +return ((sym->type ==SYM_STRUCT || + sym->type ==SYM_UNION || + sym->type ==SYM_ENUM ) && + (defn = sym->defn) && defn->tag ==SYM_NORMAL && +strcmp (defn->string,"}" ) ==0 && + (defn = defn->next) && defn->tag ==SYM_NORMAL && +strcmp (defn->string,"UNKNOWN" ) ==0 && + (defn = defn->next) && defn->tag ==SYM_NORMAL && +strcmp (defn->string,"{" ) ==0 ); +} + +struct symbol *__add_symbol (const char *name,enum symbol_type type, +struct string_list *defn,int is_extern, +int is_reference) {unsigned long h =crc32 (name) %HASH_BUCKETS ;struct symbol *sym; +enum symbol_status status =STATUS_UNCHANGED ;for (sym = symtab[h]; sym; sym = sym->hash_next) { -if (map_to_ns (sym->type) ==map_to_ns (type) - &&strcmp (name, sym->name) ==0 ) { -if (!equal_list (sym->defn, defn)) +if (map_to_ns (sym->type) ==map_to_ns (type) && +strcmp (name, sym->name) ==0 ) { +if (is_reference) +/* fall through */ ; +else if (sym->type == type && +equal_list (sym->defn, defn)) { + sym->is_declared =1 ; +return sym; + }else if (!sym->is_declared) { + status =is_unknown_symbol (sym) ? +STATUS_DEFINED :STATUS_MODIFIED ; + }else {error_with_pos ("redefinition of %s" , name); -return sym; +return sym; + } +break ; + } + } + +if (sym) { +struct symbol **psym; + +for (psym = &symtab[h]; *psym; psym = &(*psym)->hash_next) { +if (*psym == sym) { + *psym = sym->hash_next; +break ; + } } + --nsyms; } sym =xmalloc (sizeof (*sym));
@@ -183,6 +227,9 @@ struct symbol *add_symbol(const char *na sym->hash_next = symtab[h]; symtab[h] = sym; + sym->is_declared = !is_reference; + sym->status = status; +if (flag_debug) {fprintf (debugfile,"Defn for %s %s == <" , symbol_type_name[type], name);
@@ -196,6 +243,18 @@ struct symbol *add_symbol(const char *nareturn sym; } +struct symbol *add_symbol (const char *name,enum symbol_type type, +struct string_list *defn,int is_extern) +{ +return __add_symbol (name, type, defn, is_extern,0 ); +} + +struct symbol *add_reference_symbol (const char *name,enum symbol_type type, +struct string_list *defn,int is_extern) +{ +return __add_symbol (name, type, defn, is_extern,1 ); +} +/*----------------------------------------------------------------------*/ void free_node (struct string_list *node)
@@ -236,6 +295,82 @@ static int equal_list(struct string_listreturn !a && !b; } +#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0])) + +struct string_list *read_node (FILE *f) +{ +char buffer[256 ]; +struct string_list node = { + .string = buffer, + .tag =SYM_NORMAL }; +int c; + +while ((c =fgetc (f)) !=EOF ) { +if (c ==' ' ) { +if (node.string == buffer) +continue ; +break ; + }else if (c =='\n' ) { +if (node.string == buffer) +return NULL ; +ungetc (c, f); +break ; + } +if (node.string >= buffer +sizeof (buffer) -1 ) { +fprintf (stderr,"Token too long\n" ); +exit (1 ); + } + *node.string++ = c; + } +if (node.string == buffer) +return NULL ; + *node.string =0 ; + node.string = buffer; + +if (node.string[1 ] =='#' ) { +int n; + +for (n =0 ; n <ARRAY_SIZE (symbol_type_name); n++) { +if (node.string[0 ] == symbol_type_name[n][0 ]) { + node.tag = n; + node.string +=2 ; +return copy_node (&node); + } + } +fprintf (stderr,"Unknown type %c\n" , node.string[0 ]); +exit (1 ); + } +return copy_node (&node); +} + +static void read_reference (FILE *f) +{ +while (!feof (f)) { +struct string_list *defn =NULL ; +struct string_list *sym, *def; +int is_extern =0 ; + + sym =read_node (f); +if (!sym) +continue ; + def =read_node (f); +if (def && def->tag ==SYM_NORMAL && + !strcmp (def->string,"extern" )) { + is_extern =1 ; +free_node (def); + def =read_node (f); + } +while (def) { + def->next = defn; + defn = def; + def =read_node (f); + } +add_reference_symbol (xstrdup (sym->string), sym->tag, + defn, is_extern); +free_node (sym); + } +} +static void print_node (FILE * f,struct string_list *list) {if (list->tag !=SYM_NORMAL ) {
@@ -311,6 +446,7 @@ static unsigned long expand_and_crc_sym(case SYM_TYPEDEF : subsym =find_symbol (cur->string, cur->tag); +/* FIXME: Bad reference files can segfault here. */ if (subsym->expansion_trail) {if (flag_dump_defs)fprintf (debugfile,"%s " , cur->string);
@@ -347,9 +483,22 @@ static unsigned long expand_and_crc_sym( t = n; n =xmalloc (sizeof (*n)); - n->string =xstrdup ("{ UNKNOWN }" ); + n->string =xstrdup ("{" ); + n->tag =SYM_NORMAL ; + n->next = t; + t = n; + + n =xmalloc (sizeof (*n)); + n->string =xstrdup ("UNKNOWN" ); + n->tag =SYM_NORMAL ; + n->next = t; + t = n; + + n =xmalloc (sizeof (*n)); + n->string =xstrdup ("}" ); n->tag =SYM_NORMAL ; n->next = t; + t = n; subsym =add_symbol (cur->string, cur->tag, n,0 );
@@ -397,20 +546,42 @@ void export_symbol(const char *name)error_with_pos ("export undefined symbol %s" , name); else {unsigned long crc; +int has_changed =0 ;if (flag_dump_defs)fprintf (debugfile,"Export %s == <" , name); expansion_trail = (struct symbol *)-1L ; + sym->expansion_trail = expansion_trail; + expansion_trail = sym; crc =expand_and_crc_sym (sym,0xffffffff ) ^0xffffffff ; sym = expansion_trail;while (sym != (struct symbol *)-1L ) {struct symbol *n = sym->expansion_trail; + +if (sym->status !=STATUS_UNCHANGED ) { +if (!has_changed) { +print_location (); +fprintf (stderr,"%s: %s: modversion " +"changed because of changes " +"in " , flag_preserve ?"error" : +"warning" , name); + }else +fprintf (stderr,", " ); +print_type_name (sym->type, sym->name); +if (sym->status ==STATUS_DEFINED ) +fprintf (stderr," (became defined)" ); + has_changed =1 ; +if (flag_preserve) + errors++; + } sym->expansion_trail =0 ; sym = n; } +if (has_changed) +fprintf (stderr,"\n" );if (flag_dump_defs)fputs (">\n" , debugfile);
@@ -421,13 +592,26 @@ void export_symbol(const char *name) }/*----------------------------------------------------------------------*/ + +static void print_location (void ) +{ +fprintf (stderr,"%s:%d: " , cur_filename ? :"<stdin>" , cur_line); +} + +static void print_type_name (enum symbol_type type,const char *name) +{ +if (type !=SYM_NORMAL ) +fprintf (stderr,"%s %s" , symbol_type_name[type], name); +else +fprintf (stderr,"%s" , name); +} +void error_with_pos (const char *fmt, ...) {va_list args;if (flag_warnings) { -fprintf (stderr,"%s:%d: " , cur_filename ? :"<stdin>" , - cur_line); +print_location ();va_start (args, fmt);vfprintf (stderr, fmt, args);
@@ -445,7 +629,9 @@ static void genksyms_usage(void)" -a, --arch Select architecture\n" " -d, --debug Increment the debug level (repeatable)\n" " -D, --dump Dump expanded symbol defs (for debugging only)\n" -" -T, --dump-types file Dump expanded types into file (for debugging only)\n" +" -r, --reference file Read reference symbols from a file\n" +" -T, --dump-types file Dump expanded types into file\n" +" -p, --preserve Preserve reference modversions or fail\n" " -w, --warnings Enable warnings\n" " -q, --quiet Disable warnings (default)\n" " -h, --help Print this message\n"
@@ -454,7 +640,9 @@ static void genksyms_usage(void)" -a Select architecture\n" " -d Increment the debug level (repeatable)\n" " -D Dump expanded symbol defs (for debugging only)\n" -" -T file Dump expanded types into file (for debugging only)\n" +" -r file Read reference symbols from a file\n" +" -T file Dump expanded types into file\n" +" -p Preserve reference modversions or fail\n" " -w Enable warnings\n" " -q Disable warnings (default)\n" " -h Print this message\n"
@@ -465,7 +653,7 @@ static void genksyms_usage(void)int main (int argc,char **argv) { -FILE *dumpfile =NULL ; +FILE *dumpfile =NULL , *ref_file =NULL ;int o;#ifdef __GNU_LIBRARY__
@@ -475,16 +663,18 @@ int main(int argc, char **argv) {"warnings", 0, 0, 'w'}, {"quiet", 0, 0, 'q'}, {"dump", 0, 0, 'D'}, + {"reference", 1, 0, 'r'}, {"dump-types", 1, 0, 'T'}, + {"preserve", 0, 0, 'p'}, {"version", 0, 0, 'V'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0} }; - while ((o = getopt_long(argc, argv, "a:dwqVDT:h", + while ((o = getopt_long(argc, argv, "a:dwqVDr:T:ph", &long_opts[0], NULL)) != EOF) #else /* __GNU_LIBRARY__ */ - while ((o = getopt(argc, argv, "a:dwqVDT:h")) != EOF) + while ((o = getopt(argc, argv, "a:dwqVDr:T:ph")) != EOF) #endif /* __GNU_LIBRARY__ */ switch (o) { case 'a':
@@ -505,6 +695,14 @@ int main(int argc, char **argv)case 'D' : flag_dump_defs =1 ;break ; +case 'r' : + flag_reference =1 ; + ref_file =fopen (optarg,"r" ); +if (!ref_file) { +perror (optarg); +return 1 ; + } +break ;case 'T' : flag_dump_types =1 ; dumpfile =fopen (optarg,"w" );
@@ -513,6 +711,9 @@ int main(int argc, char **argv)return 1 ; }break ; +case 'p' : + flag_preserve =1 ; +break ;case 'h' :genksyms_usage ();return 0 ;
@@ -534,6 +735,9 @@ int main(int argc, char **argv)/* setlinebuf(debugfile); */ } +if (flag_reference) +read_reference (ref_file); +yyparse ();if (flag_dump_types && visited_symbols) {
scripts/genksyms/genksyms.h +6 -0
@@ -29,6 +29,10 @@ enum symbol_type {SYM_NORMAL ,SYM_TYPEDEF ,SYM_ENUM ,SYM_STRUCT ,SYM_UNION }; +enum symbol_status { +STATUS_UNCHANGED ,STATUS_DEFINED ,STATUS_MODIFIED +}; +struct string_list {struct string_list *next;enum symbol_type tag;
@@ -43,6 +47,8 @@ struct symbol {struct symbol *expansion_trail;struct symbol *visited;int is_extern; +int is_declared; +enum symbol_status status; };typedef struct string_list **yystype ;
scripts/Makefile.build +13 -3
@@ -153,12 +153,18 @@ $(obj)/%.i: $(src)/%.c FORCE quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \ + set -e; \ $(CPP) -D__GENKSYMS__ $(c_flags) $< \ - | $(GENKSYMS) -T $@ >/dev/null; \ + | $(GENKSYMS) -T $@ \ + -r $(firstword $(wildcard \ + $(@:.symtypes=.symref) /dev/null)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -a $(ARCH) \ + >/dev/null; \ test -s $@ || rm -f $@ $(obj)/%.symtypes : $(src)/%.c FORCE - $(call if_changed_dep,cc_symtypes_c) + $(call cmd,cc_symtypes_c) # C (.c) files # The C file is compiled and updated dependency information is generated.
@@ -187,7 +193,11 @@ cmd_modversions = \ if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ $(CPP) -D__GENKSYMS__ $(c_flags) $< \ | $(GENKSYMS) $(if $(KBUILD_SYMTYPES), \ - -T $(@D)/$(@F:.o=.symtypes)) -a $(ARCH) \ + -T $(@:.o=.symtypes)) \ + -r $(firstword $(wildcard \ + $(@:.o=.symref) /dev/null)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -a $(ARCH) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
Re: [genksyms patch 3/4] Track symbol checksum changes
Quoted 11 lines · On Mon, 21 Jul 2008 04:28:26 +0200 Andreas Gruenbacher <[email protected]> wrote:
Sometimes it is preferable to avoid changes of exported symbol checksums (to avoid breaking externally provided modules). When a checksum change occurs, it can be hard to figure out what caused this change: underlying types may have changed, or additional type information may simply have become available at the point where a symbol is exported.
Add a new --reference option to genksyms which allows it to report why checksums change, based on the type information dumps it creates with the --dump-types flag. Genksyms will read in such a dump from a previous run, and report which symbols have changed (and why).
Quoted 5 lines
The behavior can be controlled for an entire build as follows: If
KBUILD_SYMTYPESis set, genksyms uses --dump-types to produce *.symtypes dump files. If any *.symref files exist, those will be used as the reference to check against. IfKBUILD_PRESERVEis set, checksum changes will fail the build.
This breaks `make M=...'
With i386 allmodconfig,
akpm2:/usr/src/25> make M=drivers/rtc
WARNING: Symbol version dump /usr/src/devel/Module.symvers
is missing; modules will have no dependencies and modversions.
LD drivers/rtc/built-in.o
CC [M] drivers/rtc/rtc-lib.oscripts/genksyms/genksyms: invalid option -- r
Usage:
genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver
-a, --arch Select architecture -d, --debug Increment the debug level (repeatable) -D, --dump Dump expanded symbol defs (for debugging only) -T, --dump-types file Dump expanded types into file (for debugging only) -w, --warnings Enable warnings -q, --quiet Disable warnings (default) -h, --help Print this message -V, --version Print the release version
make[1]: *** [drivers/rtc/rtc-lib.o] Error 1
make: *** [_module_drivers/rtc] Error 2
Re: [genksyms patch 3/4] Track symbol checksum changes
Quoted 1 line · On Wednesday 03 September 2008 07:02:31 Andrew Morton wrote:
On Mon, 21 Jul 2008 04:28:26 +0200 Andreas Gruenbacher <[email protected]>
Quoted 41 lines · wrote:
Quoted 11 lines
Sometimes it is preferable to avoid changes of exported symbol checksums (to avoid breaking externally provided modules). When a checksum change occurs, it can be hard to figure out what caused this change: underlying types may have changed, or additional type information may simply have become available at the point where a symbol is exported.
Add a new --reference option to genksyms which allows it to report why checksums change, based on the type information dumps it creates with the --dump-types flag. Genksyms will read in such a dump from a previous run, and report which symbols have changed (and why).
Quoted 5 lines
The behavior can be controlled for an entire build as follows: If
KBUILD_SYMTYPESis set, genksyms uses --dump-types to produce *.symtypes dump files. If any *.symref files exist, those will be used as the reference to check against. IfKBUILD_PRESERVEis set, checksum changes will fail the build.This breaks `make M=...'
With i386 allmodconfig,
akpm2:/usr/src/25> make M=drivers/rtc
WARNING: Symbol version dump
/usr/src/devel/Module.symvers
is missing; modules will have no dependencies and modversions.LD
drivers/rtc/built-in.o
CC [M]drivers/rtc/rtc-lib.oscripts/genksyms/genksyms: invalid option -- r
Usage:
genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver-a, --arch Select architecture -d, --debug Increment the debug level (repeatable) -D, --dump Dump expanded symbol defs (for debugging only) -T, --dump-types file Dump expanded types into file (for debugging only) -w, --warnings Enable warnings -q, --quiet Disable warnings (default) -h, --help Print this message -V, --version Print the release version
Quoted 2 lines
make[1]: *** [
drivers/rtc/rtc-lib.o] Error 1
make: *** [_module_drivers/rtc] Error 2
The usage information above is from an unpatched genksyms; a "make scripts" is needed. On a clean tree, this works for me:
make allmodconfig prepare scripts
make M=drivers/rtc
When compiling out-of-tree modules with M=, the O= tree is not rebuilt automatically; it may even be read-only (as when building an external module as a user using the distro kernel packages).
Thanks,
Andreas
PATCH 4/4 Allow to ignore symbol checksum changes
In reply to Andreas GruenbacherThis adds an "override" keyword for use in *.symvers / *.symref files. When a symbol is overridden, the symbol's old definition will be used for computing checksums instead of the new one, preserving the previous checksum. (Genksyms will still warn about the change.)
This is meant to allow distributions to hide minor actual as well as fake ABI changes. (For example, when extra type information becomes available because additional headers are included, this may change checksums even though none of the types used have actully changed.)
This approach also allows to get rid of "#ifdef __GENKSYMS__" hacks in the code, which are currently used in some vendor kernels to work around checksum changes.
--- scripts/genksyms/genksyms.c | 34 ++++++++++++++++++++++++++++++---- scripts/genksyms/genksyms.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-)
scripts/genksyms/genksyms.c +30 -4
@@ -191,11 +191,26 @@ struct symbol *__add_symbol(const char */* fall through */ ; else if (sym->type == type && equal_list(sym->defn, defn)) { +if (!sym->is_declared && sym->is_override) { +print_location (); +print_type_name (type, name); +fprintf (stderr," modversion is " +"unchanged\n" ); + } sym->is_declared =1 ;return sym; } else if (!sym->is_declared) { - status =is_unknown_symbol (sym) ? -STATUS_DEFINED :STATUS_MODIFIED ; +if (sym->is_override && flag_preserve) { +print_location (); +fprintf (stderr,"ignoring " ); +print_type_name (type, name); +fprintf (stderr," modversion change\n" ); + sym->is_declared =1 ; +return sym; + }else { + status =is_unknown_symbol (sym) ? +STATUS_DEFINED :STATUS_MODIFIED ; + } } else {error_with_pos ("redefinition of %s" , name);return sym;
@@ -229,6 +244,7 @@ struct symbol *__add_symbol(const char * sym->is_declared = !is_reference; sym->status = status; + sym->is_override =0 ;if (flag_debug) { fprintf(debugfile, "Defn for %s %s == <",
@@ -348,9 +364,16 @@ static void read_reference(FILE *f)while (!feof (f)) {struct string_list *defn =NULL ;struct string_list *sym, *def; -int is_extern =0 ; +int is_extern =0 , is_override =0 ; +struct symbol *subsym; sym =read_node (f); +if (sym && sym->tag ==SYM_NORMAL && + !strcmp (sym->string,"override" )) { + is_override =1 ; +free_node (sym); + sym =read_node (f); + }if (!sym)continue ; def =read_node (f);
@@ -365,8 +388,9 @@ static void read_reference(FILE *f) defn = def; def =read_node (f); } -add_reference_symbol (xstrdup (sym->string), sym->tag, + subsym =add_reference_symbol (xstrdup (sym->string), sym->tag, defn, is_extern); + subsym->is_override = is_override;free_node (sym); } }
@@ -744,6 +768,8 @@ int main(int argc, char **argv)while (visited_symbols != (struct symbol *)-1L ) {struct symbol *sym = visited_symbols; +if (sym->is_override) +fputs ("override " , dumpfile);if (sym->type !=SYM_NORMAL ) {putc (symbol_type_name[sym->type][0 ], dumpfile);putc ('#' , dumpfile);
scripts/genksyms/genksyms.h +1 -0
@@ -49,6 +49,7 @@ struct symbol {int is_extern;int is_declared;enum symbol_status status; +int is_override; };typedef struct string_list **yystype ;