1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# $OpenBSD: symbols.awk,v 1.9 2024/03/29 02:30:25 jsing Exp $
# Copyright (c) 2018,2020 Theo Buehler <tb@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# usage: awk -f symbols.awk < Symbols.list > symbols.c
BEGIN {
printf("#include \"include_headers.c\"\n\n")
}
/^DHparams_it$/ ||
/^DSA_SIG_it$/ ||
/^ECDSA_SIG_it$/ ||
/^ECPARAMETERS_it$/ ||
/^ECPKPARAMETERS_it$/ ||
/^EC_PRIVATEKEY_it$/ ||
/^ESS_CERT_ID_it$/ ||
/^ESS_ISSUER_SERIAL_it$/ ||
/^ESS_SIGNING_CERT_it$/ ||
/^NETSCAPE_ENCRYPTED_PKEY_it$/ ||
/^NETSCAPE_PKEY_it$/ ||
/^TS_ACCURACY_it$/ ||
/^TS_MSG_IMPRINT_it$/ ||
/^TS_REQ_it$/ ||
/^TS_RESP_it$/ ||
/^TS_STATUS_INFO_it$/ ||
/^TS_TST_INFO_it$/ ||
/^X509_ATTRIBUTE_SET_it$/ ||
/^X509_NAME_ENTRIES_it$/ ||
/^X509_NAME_INTERNAL_it$/ ||
/^X9_62_CHARACTERISTIC_TWO_it$/ ||
/^X9_62_CURVE_it$/ ||
/^X9_62_FIELDID_it$/ ||
/^X9_62_PENTANOMIAL_it$/ {
printf("extern ASN1_ITEM %s;\n", $0)
}
# internal function used in libtls
/^ASN1_time_tm_clamp_notafter$/ {
printf("extern int ASN1_time_tm_clamp_notafter(struct tm *);\n")
}
/^OBJ_bsearch_$/ {
printf("const void *OBJ_bsearch_(const void *key, const void *base, int num,\n")
printf(" int size, int (*cmp)(const void *, const void *));\n")
}
# These are machdep (at least cpuid_setup and ia32cap_P are internal on amd64).
/^OPENSSL_cpuid_setup$/ ||
/^OPENSSL_cpu_caps$/ ||
/^OPENSSL_ia32cap_P$/ {
printf("/* skipped %s */\n", $0)
next
}
/^OPENSSL_strcasecmp$/ {
printf("extern int %s(const char *, const char *);\n", $0)
}
/^OPENSSL_strncasecmp$/ {
printf("extern int %s(const char *, const char *, size_t);\n", $0)
}
/^BIO_CONNECT_free$/ ||
/^ECPARAMETERS_free$/ ||
/^ECPKPARAMETERS_free$/ ||
/^EC_PRIVATEKEY_free$/ ||
/^NETSCAPE_ENCRYPTED_PKEY_free$/ ||
/^NETSCAPE_PKEY_free$/ ||
/^X9_62_CHARACTERISTIC_TWO_free$/ ||
/^X9_62_PENTANOMIAL_free$/ {
printf("extern void %s(void *);\n", $0)
}
/^BIO_CONNECT_new$/ ||
/^ECPARAMETERS_new$/ ||
/^ECPKPARAMETERS_new$/ ||
/^EC_PRIVATEKEY_new$/ ||
/^NETSCAPE_ENCRYPTED_PKEY_new$/ ||
/^NETSCAPE_PKEY_new$/ ||
/^X9_62_CHARACTERISTIC_TWO_new$/ ||
/^X9_62_PENTANOMIAL_new$/ {
printf("extern void *%s(void);\n", $0)
}
/^d2i_ECPKPARAMETERS$/ ||
/^d2i_EC_PRIVATEKEY$/ ||
/^d2i_NETSCAPE_ENCRYPTED_PKEY$/ ||
/^d2i_NETSCAPE_PKEY$/ {
printf("extern void *%s", $0)
printf("(void *, const unsigned char *, const unsigned char *);\n")
}
/^i2d_ECPKPARAMETERS$/ ||
/^i2d_EC_PRIVATEKEY$/ ||
/^i2d_NETSCAPE_ENCRYPTED_PKEY$/ ||
/^i2d_NETSCAPE_PKEY$/ {
printf("extern int %s", $0)
printf("(const void *, unsigned char **);\n")
}
{
symbols[$0] = $0
# Undefine aliases, so we don't accidentally leave them in Symbols.list.
printf("#ifdef %s\n#undef %s\n#endif\n", $0, $0)
}
END {
printf("\nint\nmain(void)\n{\n")
printf("\tsize_t i;\n");
printf("\tstruct {\n")
printf("\t\tconst char *const name;\n")
printf("\t\tconst void *addr;\n")
printf("\t} symbols[] = {\n")
for (symbol in symbols) {
printf("\t\t{\n")
printf("\t\t\t.name = \"%s\",\n", symbol)
printf("\t\t\t.addr = &%s,\n", symbol)
printf("\t\t},\n")
}
printf("\t\};\n\n")
printf("\tfor (i = 0; i < sizeof(symbols) / sizeof(symbols[0]); i++)\n")
printf("\t\tfprintf(stderr, \"%%s: %%p\\n\", symbols[i].name, symbols[i].addr);\n")
printf("\n\tprintf(\"OK\\n\");\n")
printf("\n\treturn 0;\n}\n")
}
|