summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:37:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:37:14 +0000
commitea648e70a989cca190cd7403fe892fd2dcc290b4 (patch)
treee2b6b1c647da68b0d4d66082835e256eb30970e8 /util
parentInitial commit. (diff)
downloadbind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.tar.xz
bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.zip
Adding upstream version 1:9.11.5.P4+dfsg.upstream/1%9.11.5.P4+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/bindkeys.pl37
-rwxr-xr-xutil/mksymtbl.pl120
2 files changed, 157 insertions, 0 deletions
diff --git a/util/bindkeys.pl b/util/bindkeys.pl
new file mode 100755
index 0000000..0fd5856
--- /dev/null
+++ b/util/bindkeys.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+#
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+use strict;
+use warnings;
+
+my $lines;
+while (<>) {
+ chomp;
+ if (/\/\* .Id:.* \*\//) {
+ next;
+ }
+ s/\"/\\\"/g;
+ s/$/\\n\\/;
+ $lines .= $_ . "\n";
+}
+
+my $mkey = '#define MANAGED_KEYS "\\' . "\n" . $lines . "\"\n";
+
+$lines =~ s/managed-keys/trusted-keys/;
+$lines =~ s/\s+initial-key//g;
+my $tkey = '#define TRUSTED_KEYS "\\' . "\n" . $lines . "\"\n";
+
+print "#ifndef BIND_KEYS_H\n";
+print "#define BIND_KEYS_H 1\n";
+print $tkey;
+print "\n";
+print $mkey;
+print "#endif /* BIND_KEYS_H */\n";
diff --git a/util/mksymtbl.pl b/util/mksymtbl.pl
new file mode 100755
index 0000000..47941da
--- /dev/null
+++ b/util/mksymtbl.pl
@@ -0,0 +1,120 @@
+#!/usr/bin/env perl
+#
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+use strict;
+use diagnostics;
+$^W = 1;
+
+my $rev = '$Id$';
+$rev =~ s/\$//g;
+$rev =~ s/,v//g;
+$rev =~ s/Id: //;
+
+use Getopt::Std;
+my %options;
+getopts('i:o:', \%options);
+
+my ($binname, $need_uscorefix, $outputfile, $nsyms, $ostype, $nm_prog);
+my %symmap;
+
+$binname = $ARGV[0];
+$need_uscorefix = 0;
+if ($options{'o'}) {
+ $outputfile = $options{'o'};
+} else {
+ $outputfile = "symtbl.c";
+}
+
+# OS-depending configuration
+$nm_prog = "nm";
+$ostype = `uname -s`;
+chop($ostype);
+if ($ostype eq "SunOS" || $ostype eq "HP-UX") {
+ $nm_prog = "/usr/ccs/bin/nm -x"
+}
+
+if ($options{'i'}) {
+ open(SYMBOLS, $options{'i'}) || die "failed to open $options{'i'}";
+} else {
+ open(SYMBOLS, "$nm_prog $binname |") ||
+ die "failed to invoke utility to get symbols";
+}
+open(TBLFILE, ">$outputfile") || die "failed to open output file: $outputfile";
+
+$nsyms = 0;
+while (<SYMBOLS>) {
+ my ($addr, $symbol) = (0, "");
+ if ($ostype eq "SunOS") {
+ if (/\[\d*\]\s*\|\s*0x([0-9a-f]*)\|\s*0x[0-9a-f]*\|FUNC\s*(.*)\|([^|]+)$/) {
+ next if ($2 =~ /UNDEF/); # skip undefined symbols
+ $addr = $1;
+ $symbol = $3;
+ chop($symbol);
+ }
+ } elsif ($ostype eq "HP-UX") {
+ if (/(\S*)\s*\|0x([0-9a-f]*)\|([^|]*\|entry|extern\|code)/) {
+ $addr = $2;
+ $symbol = $1;
+ # this filter catches a massive number of awkward
+ # symbols such as "$START$". we are not interested in
+ # those and ignore them.
+ next if ($symbol =~ /\$/);
+ }
+ } else {
+ # *BSDs, Linux, etc.
+ if (/([0-9a-f]*)\s[tT]\s(.*)/) {
+ ($addr, $symbol) = ($1, $2);
+ # heuristics: some compilers add a "_" to all program
+ # defined symbols. Detect and fix it for a well known
+ # symbol of "main".
+ $need_uscorefix = 1 if ($symbol eq "_main");
+ }
+ }
+ if ($symbol ne "") {
+ # XXX: HP-UX's nm can produce a duplicate entry for the same
+ # address. Ignore duplicate entries except the first one.
+ next if ($symmap{$addr});
+
+ $symmap{$addr} = $symbol;
+ $nsyms++;
+ }
+}
+
+sub lhex {
+ my $la = substr($a, -8);
+ my $lb = substr($b, -8);
+ my $ha = substr($a, 0, length($a) - length($la));
+ my $hb = substr($b, 0, length($b) - length($lb));
+ $ha = "0" if ($ha eq "");
+ $ha = "0" if ($hb eq "");
+ if (hex($ha) != hex($hb)) {
+ $la = $ha;
+ $lb = $hb;
+ }
+ hex($la) <=> hex($lb)
+}
+
+print TBLFILE "/*\n * Generated by $rev \n */\n";
+print TBLFILE "#include <isc/backtrace.h>\n";
+print TBLFILE "const int isc__backtrace_nsymbols = $nsyms;\n";
+print TBLFILE "const isc_backtrace_symmap_t isc__backtrace_symtable[] = {\n";
+foreach (sort lhex keys(%symmap)) {
+ my ($addr, $symbol) = ($_, $symmap{$_});
+ if ($need_uscorefix && $symbol =~ /^_(.*)/) {
+ $symbol = $1;
+ }
+ print TBLFILE "\t{ (void *)0x$addr, \"$symbol\" },\n";
+}
+print TBLFILE "\t{ (void *)0x0, \"\" },\n";
+print TBLFILE "};\n";
+
+close(TBLFILE);
+close(SYMBOLS);