diff options
author | Martin Schlemmer <azarah@gentoo.org> | 2005-11-30 22:54:36 +0000 |
---|---|---|
committer | Martin Schlemmer <azarah@gentoo.org> | 2005-11-30 22:54:36 +0000 |
commit | da7c507a3ea1eda35b9b0b9c765737691faa8c0b (patch) | |
tree | 5744037dd2abe6d6599765d8b17c9716c3133a5f /scripts | |
parent | Move dlvsym define. Add symbol_version macros. (diff) | |
download | sandbox-da7c507a3ea1eda35b9b0b9c765737691faa8c0b.tar.gz sandbox-da7c507a3ea1eda35b9b0b9c765737691faa8c0b.tar.bz2 sandbox-da7c507a3ea1eda35b9b0b9c765737691faa8c0b.zip |
Use versioned symbols on supported libc's for functions we wrap, as well as
provide all versions of specific functions. Some syntax cleanups.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 3 | ||||
-rw-r--r-- | scripts/gen_symbol_header.awk | 64 | ||||
-rw-r--r-- | scripts/gen_symbol_version_map.awk | 62 |
3 files changed, 129 insertions, 0 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am new file mode 100644 index 0000000..faf1df2 --- /dev/null +++ b/scripts/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = \ + gen_symbol_version_map.awk \ + gen_symbol_header.awk diff --git a/scripts/gen_symbol_header.awk b/scripts/gen_symbol_header.awk new file mode 100644 index 0000000..0426106 --- /dev/null +++ b/scripts/gen_symbol_header.awk @@ -0,0 +1,64 @@ +BEGIN { + COUNT = split(ENVIRON["SYMBOLS"], SYMBOLS); +} + +{ + for (x in SYMBOLS) { + sym_regex = "^" SYMBOLS[x] "(@|$)" + if ($8 ~ sym_regex) { + split($8, symbol_array, /@|@@/); + + SYMBOL_LIST[symbol_array[1]] = SYMBOL_LIST[symbol_array[1]] " " $8; + } + } +} + +END { + printf("#ifndef __symbols_h\n"); + printf("#define __symbols_h\n\n"); + + for (i = 1; i <= COUNT; i++) { + sym_index = SYMBOLS[i]; + split(SYMBOL_LIST[sym_index], sym_full_names); + + for (x in sym_full_names) { + split(sym_full_names[x], symbol_array, /@|@@/); + + # Defualt symbol have '@@' and not '@', so name it by + # prepending '__' rather than the symbol version so + # that we know what the name is in libsandbox.c ... + if (sym_full_names[x] ~ /@@/) { + sym_real_name = "__" sym_index; + } else { + sym_real_name = sym_full_names[x]; + gsub(/@|\./, "_", sym_real_name); + } + + printf("#define symname_%s \"%s\"\n", sym_real_name, sym_index); + + # We handle non-versioned libc's by setting symver_* + # to NULL ... + if (!symbol_array[2]) + printf("#define symver_%s NULL\n", sym_real_name); + else + printf("#define symver_%s \"%s\"\n", sym_real_name, + symbol_array[2]); + + printf("%s_decl(%s);\n", sym_index, sym_real_name); + + # Only add symbol versions for versioned libc's + if (symbol_array[2]) { + if (sym_full_names[x] ~ /@@/) + printf("default_symbol_version(%s, %s, %s);\n", + sym_real_name, sym_index, symbol_array[2]); + else + printf("symbol_version(%s, %s, %s);\n", + sym_real_name, sym_index, symbol_array[2]); + } + + printf("\n"); + } + } + + printf("#endif /* __symbols_h */\n"); +} diff --git a/scripts/gen_symbol_version_map.awk b/scripts/gen_symbol_version_map.awk new file mode 100644 index 0000000..5feb44f --- /dev/null +++ b/scripts/gen_symbol_version_map.awk @@ -0,0 +1,62 @@ +BEGIN { + split(ENVIRON["SYMBOLS"], SYMBOLS); +} + +{ + for (x in SYMBOLS) { + sym_regex = "^" SYMBOLS[x] "(@|$)" + if ($8 ~ sym_regex) { + split($8, symbol_array, /@|@@/); + + # Handle non-versioned libc's like uClibc ... + if (!symbol_array[2]) + symbol_array[2] = ""; + + SYMBOL_LIST[symbol_array[2]] = SYMBOL_LIST[symbol_array[2]] " " symbol_array[1]; + } + } +} + +END { + for (sym_version in SYMBOL_LIST) { + if (sym_version) + VERSIONS = VERSIONS " " sym_version; + } + + # We need the symbol versions sorted alphabetically ... + if (VERSIONS) { + split(VERSIONS, VERSION_LIST); + COUNT = asort(VERSION_LIST); + } else { + # Handle non-versioned libc's like uClibc ... + COUNT = 1; + } + + for (i = 1; i <= COUNT; i++) { + if (VERSION_LIST[i]) { + sym_version = VERSION_LIST[i]; + printf("%s {\n", sym_version); + } else { + # Handle non-versioned libc's like uClibc ... + sym_version = ""; + printf("{\n"); + } + + printf(" global:\n"); + + split(SYMBOL_LIST[sym_version], sym_names); + + for (x in sym_names) + printf(" %s;\n", sym_names[x]); + + if (!old_sym_version) { + printf(" local:\n"); + printf(" *;\n"); + printf("};\n"); + } else { + printf("} %s;\n", old_sym_version); + } + + old_sym_version = sym_version; + } +} |