summaryrefslogtreecommitdiffstats
path: root/scripts/genksyms/parse.y
Commit message (Collapse)AuthorAgeFilesLines
* genksyms: Fix segfault with invalid declarationsMichal Marek2017-01-051-2/+0
| | | | | | | | | | | | | | | Do not try to recover too early and segfault when parsing invalid declarations such as echo 'int (int);' | scripts/genksyms/genksyms echo 'int a, (int);' | scripts/genksyms/genksyms echo 'extern void *__inline_memcpy((void *), (const void *), (__kernel_size_t));' | scripts/genksyms/genksyms The last one was a real-life bug with include/asm-generic/asm-prototypes.h on x86_64. Reported-and-tested-by: Borislav Petkov <bp@alien8.de> Signed-off-by: Michal Marek <mmarek@suse.com>
* kbuild/genksyms: handle va_list typeNicholas Piggin2016-11-291-0/+2
| | | | | | | | | | | | genksyms currently does not handle va_list. Add the __builtin_va_list keyword as a type. This reduces the amount of syntax errors thrown, but so far no export symbol has a type with a va_list argument, so there is currently no bug in the end result. Note: this patch does not regenerate shipped parser files. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.com>
* genksyms: Duplicate function pointer type definitions segfaultRichard Yao2015-08-201-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that genksyms will segfault when it sees duplicate function pointer type declaration when I placed the same function pointer definition in two separate headers in a local branch as an intermediate step of some refactoring. This can be reproduced by piping the following minimal test case into `genksyms -r /dev/null` or alternatively, putting it into a C file attempting a build: typedef int (*f)(); typedef int (*f)(); Attaching gdb to genksyms to understand this failure is useless without changing CFLAGS to emit debuginfo. Once you have debuginfo, you will find that the failure is that `char *s` was NULL and the program executed `while(*s)`. At which point, further debugging requires familiarity with compiler front end / parser development. What happens is that flex identifies the first instance of the token "f" as IDENT and the yacc parser adds it to the symbol table. On the second instance, flex will identify "f" as TYPE, which triggers an error case in the yacc parser. Given that TYPE would have been IDENT had it not been in the symbol table, the the segmentaion fault could be avoided by treating TYPE as IDENT in the affected rule. Some might consider placing identical function pointer type declarations in different headers to be poor style might consider a failure to be beneficial. However, failing through a segmentation fault makes the cause non-obvious and can waste the time of anyone who encounters it. Signed-off-by: Richard Yao <richard.yao@clusterhq.com> Acked-by: Madhuri Yechuri <madhuriyechuri@clusterhq.com> Signed-off-by: Michal Marek <mmarek@suse.com>
* genksyms: fix typeof() handlingJan Beulich2014-04-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Recent increased use of typeof() throughout the tree resulted in a number of symbols (25 in a typical distro config of ours) not getting a proper CRC calculated for them anymore, due to the parser in genksyms not coping with several of these uses (interestingly in the majority of [if not all] cases the problem is due to the use of typeof() in code preceding a certain export, not in the declaration/definition of the exported function/object itself; I wasn't able to find a way to address this more general parser shortcoming). The use of parameter_declaration is a little more relaxed than would be ideal (permitting not just a bare type specification, but also one with identifier), but since the same code is being passed through an actual compiler, there's no apparent risk of allowing through any broken code. Otoh using parameter_declaration instead of the ad hoc "decl_specifier_seq '*'" / "decl_specifier_seq" pair allows all types to be handled rather than just plain ones and pointers to plain ones. Signed-off-by: Jan Beulich <jbeulich@suse.com> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* genksyms: Do not expand internal typesMichal Marek2011-10-111-0/+7
| | | | | | | Consider structures, unions and enums defined in the source file as internal and do not expand them. This way, changes to e.g. struct serial_private in drivers/tty/serial/8250_pci.c will not affect the checksum of the pciserial_* exports.
* genksyms: Minor parser cleanupMichal Marek2011-10-111-18/+15
| | | | | Move the identical logic for recording a struct/union/enum definition to a function.
* genksyms: Track changes to enum constantsMichal Marek2011-03-171-4/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enum constants can be used as array sizes; if the enum itself does not appear in the symbol expansion, a change in the enum constant will go unnoticed. Example patch that changes the ABI but does not change the checksum with current genksyms: | enum e { | E1, | E2, |+ E3, | E_MAX | }; | | struct s { | int a[E_MAX]; | } | | int f(struct s *s) { ... } | EXPORT_SYMBOL(f) Therefore, remember the value of each enum constant and expand each occurence to <constant> <value>. The value is not actually computed, but instead an expression in the form (last explicitly assigned value) + N is used. This avoids having to parse and semantically understand whole of C. Note: The changes won't take effect until the lexer and parser are rebuilt by the next patch. Signed-off-by: Michal Marek <mmarek@suse.cz> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* scripts/genksyms: fix header usageArnaud Lacombe2010-11-251-1/+1
| | | | | | | | FreeBSD does not like <malloc.h> when __STDC__ is defined, use the standard <stdlib.h> instead. Signed-off-by: Arnaud Lacombe <lacombar@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* kbuild: genksyms parser: fix the __attribute__ ruleAndreas Gruenbacher2008-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Cc: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
* kbuild: __extension__ support in genksyms (fix unknown CRC warning)Sam Ravnborg2007-10-121-1/+4
| | | | | | | | | | | | | | | | | | | Recently the __extension__ keyword has been introduced in the kernel. Teach genksyms about this keyword so it can generate correct CRC for exported symbols that uses a symbol marked __extension__. For now only the typedef variant: __extension__ typedef ... is supported. Later we may add more variants as needed. This patch contains the actual source file changes. The following patch will hold modifications to the generated files (*_shipped) and only after the second patch the fix has effect. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
* kbuild: Fix genksyms handling of DEFINE_PER_CPU(struct foo_s *, bar);Robin Holt2005-12-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is a one-line change to parse.y. To take advantage of this the scripts/genksyms/*_shipped files needs to be rebuild - this is the next patch. When a .c file contains: DEFINE_PER_CPU(struct foo_s *, bar); the .cpp output looks like: __attribute__((__section__(".data.percpu"))) __typeof__(struct foo_s *) per_cpu__bar; With the existing parse.y, the value inside the paranthesis of __typeof__() does not evaluate as a type_specifier and therefore per_cpu__bar does not get assigned a type for genksyms which results in the EXPORT_PER_CPU_SYMBOL() not generating a CRC value. I have compared the Modules.symvers with and without this patch and for ia64's defconfig, the only change is: Before 0x00000000 per_cpu____sn_nodepda vmlinux After 0x9d3f3faa per_cpu____sn_nodepda vmlinux per_cpu____sn_nodepda was the original source of my problems. Signed-off-by: Robin Holt <holt@sgi.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
* Linux-2.6.12-rc2v2.6.12-rc2Linus Torvalds2005-04-161-0/+469
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
OpenPOWER on IntegriCloud