On Wed, Jun 14, 2017 at 9:09 PM, Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> wrote: > On Wed, Jun 14, 2017 at 10:25:59PM +0100, Dibyendu Majumdar wrote: >> Hi, >> >> I am trying to understand what happens when multiple input files are >> given to sparse. Are the symbols from previous files dropped when >> sparse moves on to the next file? >> >> I see a call to remove_symbol_scope() in end_scope() implying that >> symbols are dropped - but then I am not sure I am understanding this >> correctly. Yes, remove_symbol_scope() just remove symbol from the hash table link list. After removal, the symbol will not be able to found by lookup_symbol() again. > > I never yet looked what's happening exactly but I also had seen > a problem when using multiple files, at least a difference > between sparse & gcc. The difference can quickly be seen > with an input file like: > int a = 1; > int foo(void) {} > and then call sparse or gcc with twice the same file, like > 'sparse $file.c $file.c' or 'gcc -c $file.c $file.c'. > > gcc seems to process the files independently and it will simply > overwrite the first $file.o when processing the second one and > this without giving a warning about 'a' or 'foo()' being redefined. > > sparse seems to process the files more as if being concatenated > (even if the file scope is respected) or like it would use > a "super-scope" above the file scope of the input files and > will complain that 'a' and 'foo()' are redefined. The problem you are seeing is that, sparse remove the file scope symbols. It does not remove extern symbols. It does have a difference compare to gcc. I think the effect is that, currently sparse does not have a linker, if you give more than one file to sparse. Those file will be as if they are link together (more or less). Chris -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html