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

  ViewVC Help
Powered by ViewVC 1.1.20