chiark / gitweb /
dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / t / Dpkg_Shlibs / spacesyms-c-gen.pl
1 #!/usr/bin/perl
2 #
3 # spacesyms-c-gen.pl
4 #
5 # Output a C file that contains symbols matching the shell glob
6 # sym{defaultver,longver,shortver}{nospace,SPACE}{default,hidden,protected,internal}
7 # with symbol visibility matching the final element and at least one relocation
8 # against each symbol.
9 #
10 # When used together with spacesyms-o-map.pl and spacesyms.map, makes a shared
11 # object that contains symbols that covers all cases of:
12 #
13 # 1) has a short, long or Base version,
14 # 2) has or does not have a space in the symbol name,
15 # 3) default, hidden, protected or internal visibility.
16
17 use strict;
18 use warnings;
19
20 my @symbols;
21
22 foreach my $version (qw(defaultver longver shortver)) {
23     foreach my $space (qw(nospace SPACE)) {
24         foreach my $visibility (qw(default hidden protected internal)) {
25             my $symbol = "sym$version$space$visibility";
26             push @symbols, $symbol;
27             print "void $symbol(void) __attribute__((visibility(\"$visibility\")));\n";
28             print "void $symbol(void) {}\n";
29         }
30     }
31 }
32
33 print "void (*funcs[])(void) = {\n";
34 foreach my $symbol (@symbols) {
35     print "$symbol,\n";
36 }
37 print "};\n";