Commit 46bd1da6 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: [PATCH] put genksyms in scripts dir

This puts genksyms into scripts/genksyms/.

genksyms used to be maintained externally, though the only possible user
was the kernel build. Moving it into the kernel sources makes it easier to
keep it uptodate, like for example updating it to generate linker scripts
directly instead of postprocessing the generated header file fragments 
with sed, as we do currently.

Also, genksyms does not handle __typeof__, which needs to be fixed since
some of the exported symbol in the kernel are defined using __typeof__. 

(Rusty Russell/me)
parent 8e19dec4
...@@ -159,7 +159,7 @@ STRIP = $(CROSS_COMPILE)strip ...@@ -159,7 +159,7 @@ STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump OBJDUMP = $(CROSS_COMPILE)objdump
AWK = awk AWK = awk
GENKSYMS = /sbin/genksyms GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod DEPMOD = /sbin/depmod
KALLSYMS = scripts/kallsyms KALLSYMS = scripts/kallsyms
PERL = perl PERL = perl
......
...@@ -14,11 +14,13 @@ build-targets := $(host-progs) empty.o ...@@ -14,11 +14,13 @@ build-targets := $(host-progs) empty.o
modpost-objs := modpost.o file2alias.o modpost-objs := modpost.o file2alias.o
subdir-$(CONFIG_MODVERSIONS) += genksyms
# Let clean descend into subdirs # Let clean descend into subdirs
subdir- := lxdialog kconfig subdir- += lxdialog kconfig
# fixdep is needed to compile other host programs # fixdep is needed to compile other host programs
$(addprefix $(obj)/,$(filter-out fixdep,$(build-targets))): $(obj)/fixdep $(addprefix $(obj)/,$(filter-out fixdep,$(build-targets)) $(subdir-y)): $(obj)/fixdep
# dependencies on generated files need to be listed explicitly # dependencies on generated files need to be listed explicitly
......
host-progs := genksyms
build-targets := $(host-progs)
genksyms-objs := genksyms.o parse.o lex.o
HOSTCFLAGS_parse.o := -Wno-uninitialized
# dependencies on generated files need to be listed explicitly
$(obj)/lex.o: $(obj)/parse.h $(obj)/keywords.c
ifdef GENERATE_PARSER
# gperf
quiet_cmd_keywords.c = GPERF $@
cmd_keywords.c = gperf -L ANSI-C -a -C -E -g -H is_reserved_hash \
-k 1,3,$$ -N is_reserved_word -p -t $< > $@
$(obj)/keywords.c: $(obj)/keywords.gperf FORCE
$(call if_changed,keywords.c)
# flex
quiet_cmd_lex.c = FLEX $@
cmd_lex.c = flex -o$@ -d $(filter-out FORCE,$^)
$(obj)/lex.c: $(obj)/lex.l $(obj)/parse.h FORCE
$(call if_changed,lex.c)
# bison
quiet_cmd_parse.c = BISON $@
cmd_parse.c = bison -o$@ -dtv $(filter-out FORCE,$^)
$(obj)/parse.c: $(obj)/parse.y FORCE
$(call if_changed,parse.c)
$(obj)/parse.h: $(obj)/parse.c ;
clean-files += parse.output
endif
targets += $(obj)/keywords.c $(obj)/lex.c $(obj)/parse.c $(obj)/parse.h
This diff is collapsed.
/* Generate kernel symbol version hashes.
Copyright 1996, 1997 Linux International.
New implementation contributed by Richard Henderson <rth@tamu.edu>
Based on original work by Bjorn Ekwall <bj0rn@blox.se>
This file is part of the Linux modutils.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef MODUTILS_GENKSYMS_H
#define MODUTILS_GENKSYMS_H 1
#include <stdio.h>
#include <assert.h>
enum symbol_type
{
SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
};
struct string_list
{
struct string_list *next;
enum symbol_type tag;
char *string;
};
struct symbol
{
struct symbol *hash_next;
const char *name;
enum symbol_type type;
struct string_list *defn;
struct symbol *expansion_trail;
int is_extern;
};
typedef struct string_list **yystype;
#define YYSTYPE yystype
extern FILE *outfile, *debugfile;
extern int cur_line;
extern char *cur_filename, *output_directory;
extern int flag_debug, flag_dump_defs, flag_warnings;
extern int checksum_version, kernel_version;
extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
extern struct string_list *current_list, *next_list;
struct symbol *find_symbol(const char *name, enum symbol_type ns);
struct symbol *add_symbol(const char *name, enum symbol_type type,
struct string_list *defn, int is_extern);
void export_symbol(const char *);
struct string_list *reset_list(void);
void free_list(struct string_list *s, struct string_list *e);
void free_node(struct string_list *list);
struct string_list *copy_node(struct string_list *);
struct string_list *copy_list(struct string_list *s, struct string_list *e);
int equal_list(struct string_list *a, struct string_list *b);
void print_list(FILE *, struct string_list *list);
int yylex(void);
int yyparse(void);
void error_with_pos(const char *, ...);
#define version(a,b,c) ((a << 16) | (b << 8) | (c))
/*----------------------------------------------------------------------*/
#define MODUTILS_VERSION "<in-kernel>"
#define xmalloc(size) ({ void *__ptr = malloc(size); assert(__ptr || size == 0); __ptr; })
#define xstrdup(str) ({ char *__str = strdup(str); assert(__str); __str; })
#endif /* genksyms.h */
/* ANSI-C code produced by gperf version 2.7.2 */
/* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */
struct resword { const char *name; int token; };
/* maximum key range = 101, duplicates = 0 */
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
is_reserved_hash (register const char *str, register unsigned int len)
{
static const unsigned char asso_values[] =
{
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 5,
105, 105, 105, 105, 105, 105, 0, 105, 105, 105,
0, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 0, 105, 0, 105, 20,
25, 0, 35, 30, 105, 20, 105, 105, 40, 30,
30, 0, 0, 105, 0, 0, 0, 15, 5, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 105, 105
};
return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]];
}
#ifdef __GNUC__
__inline
#endif
const struct resword *
is_reserved_word (register const char *str, register unsigned int len)
{
enum
{
TOTAL_KEYWORDS = 39,
MIN_WORD_LENGTH = 3,
MAX_WORD_LENGTH = 17,
MIN_HASH_VALUE = 4,
MAX_HASH_VALUE = 104
};
static const struct resword wordlist[] =
{
{""}, {""}, {""}, {""},
{"auto", AUTO_KEYW},
{"short", SHORT_KEYW},
{"struct", STRUCT_KEYW},
{"__asm__", ASM_KEYW},
{"restrict", RESTRICT_KEYW},
{"_restrict", RESTRICT_KEYW},
{"__signed__", SIGNED_KEYW},
{"__attribute", ATTRIBUTE_KEYW},
{"__restrict__", RESTRICT_KEYW},
{"__attribute__", ATTRIBUTE_KEYW},
{""},
{"__volatile", VOLATILE_KEYW},
{""},
{"__volatile__", VOLATILE_KEYW},
{"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW},
{""}, {""}, {""},
{"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
{"int", INT_KEYW},
{"char", CHAR_KEYW},
{""},
{"static", STATIC_KEYW},
{"__const", CONST_KEYW},
{"__inline", INLINE_KEYW},
{"__const__", CONST_KEYW},
{"__inline__", INLINE_KEYW},
{""}, {""},
{"__signed", SIGNED_KEYW},
{""},
{"__asm", ASM_KEYW},
{"extern", EXTERN_KEYW},
{""},
{"register", REGISTER_KEYW},
{""},
{"float", FLOAT_KEYW},
{""},
{"typedef", TYPEDEF_KEYW},
{""}, {""},
{"_Bool", BOOL_KEYW},
{"double", DOUBLE_KEYW},
{""},
{"unsigned", UNSIGNED_KEYW},
{"enum", ENUM_KEYW},
{""}, {""}, {""},
{"volatile", VOLATILE_KEYW},
{"void", VOID_KEYW},
{"const", CONST_KEYW},
{""}, {""}, {""}, {""}, {""},
{"signed", SIGNED_KEYW},
{""},
{"asm", ASM_KEYW},
{""}, {""},
{"inline", INLINE_KEYW},
{""}, {""}, {""},
{"union", UNION_KEYW},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
{"long", LONG_KEYW}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = is_reserved_hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (*str == *s && !strcmp (str + 1, s + 1))
return &wordlist[key];
}
}
return 0;
}
%{
%}
struct resword { const char *name; int token; }
%%
EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW
EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW
__asm, ASM_KEYW
__asm__, ASM_KEYW
__attribute, ATTRIBUTE_KEYW
__attribute__, ATTRIBUTE_KEYW
__const, CONST_KEYW
__const__, CONST_KEYW
__inline, INLINE_KEYW
__inline__, INLINE_KEYW
__signed, SIGNED_KEYW
__signed__, SIGNED_KEYW
__volatile, VOLATILE_KEYW
__volatile__, VOLATILE_KEYW
# According to rth, c99 defines _Bool, __restrict, __restrict__, restrict. KAO
_Bool, BOOL_KEYW
_restrict, RESTRICT_KEYW
__restrict__, RESTRICT_KEYW
restrict, RESTRICT_KEYW
asm, ASM_KEYW
# attribute commented out in modutils 2.4.2. People are using 'attribute' as a
# field name which breaks the genksyms parser. It is not a gcc keyword anyway.
# KAO.
# attribute, ATTRIBUTE_KEYW
auto, AUTO_KEYW
char, CHAR_KEYW
const, CONST_KEYW
double, DOUBLE_KEYW
enum, ENUM_KEYW
extern, EXTERN_KEYW
float, FLOAT_KEYW
inline, INLINE_KEYW
int, INT_KEYW
long, LONG_KEYW
register, REGISTER_KEYW
short, SHORT_KEYW
signed, SIGNED_KEYW
static, STATIC_KEYW
struct, STRUCT_KEYW
typedef, TYPEDEF_KEYW
union, UNION_KEYW
unsigned, UNSIGNED_KEYW
void, VOID_KEYW
volatile, VOLATILE_KEYW
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef YYSTYPE
#define YYSTYPE int
#endif
#define ASM_KEYW 257
#define ATTRIBUTE_KEYW 258
#define AUTO_KEYW 259
#define BOOL_KEYW 260
#define CHAR_KEYW 261
#define CONST_KEYW 262
#define DOUBLE_KEYW 263
#define ENUM_KEYW 264
#define EXTERN_KEYW 265
#define FLOAT_KEYW 266
#define INLINE_KEYW 267
#define INT_KEYW 268
#define LONG_KEYW 269
#define REGISTER_KEYW 270
#define RESTRICT_KEYW 271
#define SHORT_KEYW 272
#define SIGNED_KEYW 273
#define STATIC_KEYW 274
#define STRUCT_KEYW 275
#define TYPEDEF_KEYW 276
#define UNION_KEYW 277
#define UNSIGNED_KEYW 278
#define VOID_KEYW 279
#define VOLATILE_KEYW 280
#define EXPORT_SYMBOL_KEYW 281
#define ASM_PHRASE 282
#define ATTRIBUTE_PHRASE 283
#define BRACE_PHRASE 284
#define BRACKET_PHRASE 285
#define EXPRESSION_PHRASE 286
#define CHAR 287
#define DOTS 288
#define IDENT 289
#define INT 290
#define REAL 291
#define STRING 292
#define TYPE 293
#define OTHER 294
#define FILENAME 295
extern YYSTYPE yylval;
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment