/[path-sandbox]/trunk/scripts/gen_symbol_header.awk
Gentoo

Contents of /trunk/scripts/gen_symbol_header.awk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 211 - (show annotations) (download)
Sat Dec 3 11:42:38 2005 UTC (8 years, 9 months ago) by azarah
File size: 2341 byte(s)
Change default prefix '__' to '_DEFAULT' suffix to avoid confusion
some people seem to have.

1 BEGIN {
2 COUNT = split(ENVIRON["SYMBOLS"], SYMBOLS);
3 }
4
5 {
6 for (x in SYMBOLS) {
7 sym_regex = "^" SYMBOLS[x] "(@|$)"
8 if ($8 ~ sym_regex) {
9 split($8, symbol_array, /@|@@/);
10
11 # Don't add local symbols of versioned libc's
12 if (VERSIONED_LIBC && !symbol_array[2])
13 continue;
14
15 # We have a versioned libc
16 if (symbol_array[2] && !VERSIONED_LIBC)
17 VERSIONED_LIBC = 1;
18
19 ADD = 1;
20 # Check that we do not add duplicates
21 for (x in PROCESSED_SYMBOLS) {
22 if (x == $8) {
23 ADD = 0;
24 break;
25 }
26 }
27
28 if (ADD) {
29 SYMBOL_LIST[symbol_array[1]] = SYMBOL_LIST[symbol_array[1]] " " $8;
30 PROCESSED_SYMBOLS[$8] = $8;
31 }
32 }
33 }
34 }
35
36 END {
37 printf("#ifndef __symbols_h\n");
38 printf("#define __symbols_h\n\n");
39
40 # We use the order in SYMBOLS, as some wrappers depends on others ...
41 for (i = 1; i <= COUNT; i++) {
42 sym_index = SYMBOLS[i];
43 split(SYMBOL_LIST[sym_index], sym_full_names);
44
45 for (x in sym_full_names) {
46 split(sym_full_names[x], symbol_array, /@|@@/);
47
48 # Defualt symbol have '@@' and not '@', so name it by
49 # prepending '__' rather than the symbol version so
50 # that we know what the name is in libsandbox.c ...
51 # Also do this for non-versioned libc's ...
52 if (sym_full_names[x] ~ /@@/ || !symbol_array[2]) {
53 sym_real_name = sym_index "_DEFAULT";
54 } else {
55 sym_real_name = sym_full_names[x];
56 gsub(/@|\./, "_", sym_real_name);
57 }
58
59 printf("#define symname_%s \"%s\"\n", sym_real_name, sym_index);
60
61 # We handle non-versioned libc's by setting symver_*
62 # to NULL ...
63 if (!symbol_array[2])
64 printf("#define symver_%s NULL\n", sym_real_name);
65 else
66 printf("#define symver_%s \"%s\"\n", sym_real_name,
67 symbol_array[2]);
68
69 printf("%s_decl(%s);\n", sym_index, sym_real_name);
70
71 if (symbol_array[2]) {
72 # Only add symbol versions for versioned libc's
73 if (sym_full_names[x] ~ /@@/)
74 printf("default_symbol_version(%s, %s, %s);\n",
75 sym_real_name, sym_index, symbol_array[2]);
76 else
77 printf("symbol_version(%s, %s, %s);\n",
78 sym_real_name, sym_index, symbol_array[2]);
79 } else {
80 # For non-versioned libc's we use strong aliases
81 printf("strong_alias(%s, %s);\n", sym_real_name,
82 sym_index);
83 }
84
85 printf("\n");
86 }
87 }
88
89 printf("#endif /* __symbols_h */\n");
90 }

  ViewVC Help
Powered by ViewVC 1.1.20