2006-12-20 14:50:15 +01:00
|
|
|
function sort(V, N, tmp, i, j) {
|
|
|
|
V[-1] = ""; # Used as a sentinel before V[0].
|
2008-01-08 09:22:51 +01:00
|
|
|
for (i = 1; i < N; i++)
|
|
|
|
for (j = i; V[j - 1] > V[j]; j--) {
|
2006-12-20 14:50:15 +01:00
|
|
|
tmp = V[j];
|
|
|
|
V[j] = V[j - 1];
|
|
|
|
V[j - 1] = tmp;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-23 13:32:52 +01:00
|
|
|
BEGIN {
|
|
|
|
nname = 0;
|
|
|
|
builtin["printf"] = "int printf(const char *, ...)";
|
|
|
|
builtin["sprintf"] = "int sprintf(char *, const char *, ...)";
|
|
|
|
builtin["malloc"] = "void *malloc()";
|
2008-01-08 09:22:51 +01:00
|
|
|
builtin["calloc"] = "void *calloc()";
|
2007-01-23 13:32:52 +01:00
|
|
|
builtin["memcpy"] = "void *memcpy()";
|
|
|
|
builtin["memset"] = "void *memset()";
|
2007-08-22 12:57:31 +02:00
|
|
|
builtin["memmove"] = "void *memmove()";
|
2007-01-23 13:32:52 +01:00
|
|
|
builtin["strcpy"] = "char *strcpy()";
|
2008-01-08 09:22:51 +01:00
|
|
|
builtin["strchr"] = "char *strchr()";
|
2007-01-23 13:32:52 +01:00
|
|
|
builtin[""] = "";
|
|
|
|
}
|
2006-12-20 14:50:15 +01:00
|
|
|
|
2013-07-28 16:25:23 +02:00
|
|
|
/^[0123456789abcdef]+ [ABCDGRSTUVW] [^__]/ {
|
2007-01-02 13:39:48 +01:00
|
|
|
if ($3 != "symbols" && $3 != "symbols_nelts") {
|
2006-12-20 14:50:15 +01:00
|
|
|
name[nname] = $3;
|
|
|
|
nname++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
2007-01-02 13:39:48 +01:00
|
|
|
sort(name, nname);
|
|
|
|
|
2007-01-24 17:11:48 +01:00
|
|
|
print "#include \"loader/symbols.h\"\n";
|
2006-12-20 14:50:15 +01:00
|
|
|
|
|
|
|
# Must deal with compiler builtins etc.
|
|
|
|
for (x = 0; x < nname; x++) {
|
2007-01-23 13:32:52 +01:00
|
|
|
if (builtin[name[x]] != "")
|
|
|
|
print builtin[name[x]] ";";
|
2006-12-20 14:50:15 +01:00
|
|
|
else
|
|
|
|
print "extern int " name[x]"();";
|
|
|
|
}
|
2007-01-02 13:39:48 +01:00
|
|
|
print "\n";
|
2006-12-20 14:50:15 +01:00
|
|
|
|
|
|
|
# nname++: An { 0, 0 } entry is added at the end of the vector.
|
|
|
|
print "const int symbols_nelts = " nname+1 ";";
|
|
|
|
print "const struct symbols symbols[" nname+1 "] = {";
|
|
|
|
for (x = 0; x < nname; x++)
|
|
|
|
print "{ \"" name[x] "\", (void *)&"name[x]" },";
|
|
|
|
print "{ (const char *)0, (void *)0} };";
|
|
|
|
}
|