diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-15 11:07:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-15 11:07:59 -0700 |
commit | c7089d15344e963397e9c58864f476729caeb225 (patch) | |
tree | 889b5ba3f4797bc7827d15331d00fc2762bf9629 /genprotsym.txr | |
parent | c8efb29a3575304ed22e7e240885265e0e93ea3d (diff) | |
download | txr-c7089d15344e963397e9c58864f476729caeb225.tar.gz txr-c7089d15344e963397e9c58864f476729caeb225.tar.bz2 txr-c7089d15344e963397e9c58864f476729caeb225.zip |
Protect internal symbols from uninterning.
Issue: TXR holds numerous symbol references in global
variables, like list_s. These variables are not registered as
root pointers with the garbage collector. This is normally
okay because symbols are reachable via packages. However,
if such a symbol is uninterned, that causes an integrity problem.
Solution: protect those symbols from being removed from their
packages.
* Makefile (OBJS): Add protsym.o.
* genprotsym.txr, protsym.c: New files.
* lib.c (prot_sym_check): New static function.
(use_sym, uintern, rehome_sym): Use prot_sym_check to
implement a defense against internal symbols being booted
out of their package.
Diffstat (limited to 'genprotsym.txr')
-rw-r--r-- | genprotsym.txr | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/genprotsym.txr b/genprotsym.txr new file mode 100644 index 00000000..7d9f8c2a --- /dev/null +++ b/genprotsym.txr @@ -0,0 +1,32 @@ +@(next (open-files (glob "*.c"))) +@(collect :vars (sym)) +val @(coll)@{sym /[A-Za-z0-9_]+_[sk]/}@/[,;]/@(end) +@(end) +@(next "lib.c") +@(collect) +@copyright +@(until) + +@(end) +@(flatten sym) +@(bind gsym @(tuples 5 (sort sym))) +@(output "protsym.c") +/* This file is generated by genprotsym.txr */ + +@{copyright "\n"} + +#include <stddef.h> +#include "config.h" +#include "lib.h" + +@ (repeat) +extern val @(rep)@gsym, @(last)@gsym;@(end) +@ (end) + +val *protected_sym[] = { +@ (repeat) + @(rep)&@gsym, @(last)&@gsym,@(end) +@ (end) + convert(val *, 0) +}; +@(end) |