chiark / gitweb /
dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / Dpkg / Shlibs / SymbolFile.pm
1 # Copyright © 2007 Raphaël Hertzog <hertzog@debian.org>
2 # Copyright © 2009-2010 Modestas Vainius <modax@debian.org>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17 package Dpkg::Shlibs::SymbolFile;
18
19 use strict;
20 use warnings;
21
22 our $VERSION = '0.01';
23
24 use Dpkg::Gettext;
25 use Dpkg::ErrorHandling;
26 use Dpkg::Version;
27 use Dpkg::Control::Fields;
28 use Dpkg::Shlibs::Symbol;
29 use Dpkg::Arch qw(get_host_arch);
30
31 use parent qw(Dpkg::Interface::Storable);
32
33 my %blacklist = (
34     __bss_end__ => 1,                   # arm
35     __bss_end => 1,                     # arm
36     _bss_end__ => 1,                    # arm
37     __bss_start => 1,                   # ALL
38     __bss_start__ => 1,                 # arm
39     __data_start => 1,                  # arm
40     __do_global_ctors_aux => 1,         # ia64
41     __do_global_dtors_aux => 1,         # ia64
42     __do_jv_register_classes => 1,      # ia64
43     _DYNAMIC => 1,                      # ALL
44     _edata => 1,                        # ALL
45     _end => 1,                          # ALL
46     __end__ => 1,                       # arm
47     __exidx_end => 1,                   # armel
48     __exidx_start => 1,                 # armel
49     _fbss => 1,                         # mips, mipsel
50     _fdata => 1,                        # mips, mipsel
51     _fini => 1,                         # ALL
52     _ftext => 1,                        # mips, mipsel
53     _GLOBAL_OFFSET_TABLE_ => 1,         # hppa, mips, mipsel
54     __gmon_start__ => 1,                # hppa
55     __gnu_local_gp => 1,                # mips, mipsel
56     _gp => 1,                           # mips, mipsel
57     _init => 1,                         # ALL
58     _PROCEDURE_LINKAGE_TABLE_ => 1,     # sparc, alpha
59     _SDA2_BASE_ => 1,                   # powerpc
60     _SDA_BASE_ => 1,                    # powerpc
61 );
62
63 for my $i (14 .. 31) {
64     # Many powerpc specific symbols
65     $blacklist{"_restfpr_$i"} = 1;
66     $blacklist{"_restfpr_$i\_x"} = 1;
67     $blacklist{"_restgpr_$i"} = 1;
68     $blacklist{"_restgpr_$i\_x"} = 1;
69     $blacklist{"_savefpr_$i"} = 1;
70     $blacklist{"_savegpr_$i"} = 1;
71 }
72
73 sub symbol_is_blacklisted {
74     my ($symbol, $include_groups) = @_;
75
76     return 1 if exists $blacklist{$symbol};
77
78     # The ARM Embedded ABI spec states symbols under this namespace as
79     # possibly appearing in output objects.
80     return 1 if not ${$include_groups}{aeabi} and $symbol =~ /^__aeabi_/;
81
82     # The GNU implementation of the OpenMP spec, specifies symbols under
83     # this namespace as possibly appearing in output objects.
84     return 1 if not ${$include_groups}{gomp}
85                 and $symbol =~ /^\.gomp_critical_user_/;
86
87     return 0;
88 }
89
90 sub new {
91     my ($this, %opts) = @_;
92     my $class = ref($this) || $this;
93     my $self = \%opts;
94     bless $self, $class;
95     $self->{arch} //= get_host_arch();
96     $self->clear();
97     if (exists $self->{file}) {
98         $self->load($self->{file}) if -e $self->{file};
99     }
100     return $self;
101 }
102
103 sub get_arch {
104     my $self = shift;
105     return $self->{arch};
106 }
107
108 sub clear {
109     my $self = shift;
110     $self->{objects} = {};
111 }
112
113 sub clear_except {
114     my ($self, @ids) = @_;
115
116     my %has = map { $_ => 1 } @ids;
117     foreach my $objid (keys %{$self->{objects}}) {
118         delete $self->{objects}{$objid} unless exists $has{$objid};
119     }
120 }
121
122 sub get_sonames {
123     my $self = shift;
124     return keys %{$self->{objects}};
125 }
126
127 sub get_symbols {
128     my ($self, $soname) = @_;
129     if (defined $soname) {
130         my $obj = $self->get_object($soname);
131         return (defined $obj) ? values %{$obj->{syms}} : ();
132     } else {
133         my @syms;
134         foreach my $soname ($self->get_sonames()) {
135             push @syms, $self->get_symbols($soname);
136         }
137         return @syms;
138     }
139 }
140
141 sub get_patterns {
142     my ($self, $soname) = @_;
143     my @patterns;
144     if (defined $soname) {
145         my $obj = $self->get_object($soname);
146         foreach my $alias (values %{$obj->{patterns}{aliases}}) {
147             push @patterns, values %$alias;
148         }
149         return (@patterns, @{$obj->{patterns}{generic}});
150     } else {
151         foreach my $soname ($self->get_sonames()) {
152             push @patterns, $self->get_patterns($soname);
153         }
154         return @patterns;
155     }
156 }
157
158 # Create a symbol from the supplied string specification.
159 sub create_symbol {
160     my ($self, $spec, %opts) = @_;
161     my $symbol = (exists $opts{base}) ? $opts{base} :
162         Dpkg::Shlibs::Symbol->new();
163
164     my $ret = $opts{dummy} ? $symbol->parse_symbolspec($spec, default_minver => 0) :
165         $symbol->parse_symbolspec($spec);
166     if ($ret) {
167         $symbol->initialize(arch => $self->get_arch());
168         return $symbol;
169     }
170     return;
171 }
172
173 sub add_symbol {
174     my ($self, $symbol, $soname) = @_;
175     my $object = $self->get_object($soname);
176
177     if ($symbol->is_pattern()) {
178         if (my $alias_type = $symbol->get_alias_type()) {
179             $object->{patterns}{aliases}{$alias_type} //= {};
180             # Alias hash for matching.
181             my $aliases = $object->{patterns}{aliases}{$alias_type};
182             $aliases->{$symbol->get_symbolname()} = $symbol;
183         } else {
184             # Otherwise assume this is a generic sequential pattern. This
185             # should be always safe.
186             push @{$object->{patterns}{generic}}, $symbol;
187         }
188         return 'pattern';
189     } else {
190         # invalidate the minimum version cache
191         $object->{minver_cache} = [];
192         $object->{syms}{$symbol->get_symbolname()} = $symbol;
193         return 'sym';
194     }
195 }
196
197 sub _new_symbol {
198     my $base = shift || 'Dpkg::Shlibs::Symbol';
199     return (ref $base) ? $base->clone(@_) : $base->new(@_);
200 }
201
202 # Parameter seen is only used for recursive calls
203 sub parse {
204     my ($self, $fh, $file, $seen, $obj_ref, $base_symbol) = @_;
205
206     if (defined($seen)) {
207         return if exists $seen->{$file}; # Avoid include loops
208     } else {
209         $self->{file} = $file;
210         $seen = {};
211     }
212     $seen->{$file} = 1;
213
214     if (not ref($obj_ref)) { # Init ref to name of current object/lib
215         $$obj_ref = undef;
216     }
217
218     while (<$fh>) {
219         chomp;
220
221         if (/^(?:\s+|#(?:DEPRECATED|MISSING): ([^#]+)#\s*)(.*)/) {
222             if (not defined ($$obj_ref)) {
223                 error(g_('symbol information must be preceded by a header (file %s, line %s)'), $file, $.);
224             }
225             # Symbol specification
226             my $deprecated = ($1) ? $1 : 0;
227             my $sym = _new_symbol($base_symbol, deprecated => $deprecated);
228             if ($self->create_symbol($2, base => $sym)) {
229                 $self->add_symbol($sym, $$obj_ref);
230             } else {
231                 warning(g_('failed to parse line in %s: %s'), $file, $_);
232             }
233         } elsif (/^(\(.*\))?#include\s+"([^"]+)"/) {
234             my $tagspec = $1;
235             my $filename = $2;
236             my $dir = $file;
237             my $new_base_symbol;
238             if (defined $tagspec) {
239                 $new_base_symbol = _new_symbol($base_symbol);
240                 $new_base_symbol->parse_tagspec($tagspec);
241             }
242             $dir =~ s{[^/]+$}{}; # Strip filename
243             $self->load("$dir$filename", $seen, $obj_ref, $new_base_symbol);
244         } elsif (/^#|^$/) {
245             # Skip possible comments and empty lines
246         } elsif (/^\|\s*(.*)$/) {
247             # Alternative dependency template
248             push @{$self->{objects}{$$obj_ref}{deps}}, "$1";
249         } elsif (/^\*\s*([^:]+):\s*(.*\S)\s*$/) {
250             # Add meta-fields
251             $self->{objects}{$$obj_ref}{fields}{field_capitalize($1)} = $2;
252         } elsif (/^(\S+)\s+(.*)$/) {
253             # New object and dependency template
254             $$obj_ref = $1;
255             if (exists $self->{objects}{$$obj_ref}) {
256                 # Update/override infos only
257                 $self->{objects}{$$obj_ref}{deps} = [ "$2" ];
258             } else {
259                 # Create a new object
260                 $self->create_object($$obj_ref, "$2");
261             }
262         } else {
263             warning(g_('failed to parse a line in %s: %s'), $file, $_);
264         }
265     }
266     delete $seen->{$file};
267 }
268
269 # Beware: we reuse the data structure of the provided symfile so make
270 # sure to not modify them after having called this function
271 sub merge_object_from_symfile {
272     my ($self, $src, $objid) = @_;
273     if (not $self->has_object($objid)) {
274         $self->{objects}{$objid} = $src->get_object($objid);
275     } else {
276         warning(g_('tried to merge the same object (%s) twice in a symfile'), $objid);
277     }
278 }
279
280 sub output {
281     my ($self, $fh, %opts) = @_;
282     $opts{template_mode} //= 0;
283     $opts{with_deprecated} //= 1;
284     $opts{with_pattern_matches} //= 0;
285     my $res = '';
286     foreach my $soname (sort $self->get_sonames()) {
287         my @deps = $self->get_dependencies($soname);
288         my $dep_first = shift @deps;
289         if (exists $opts{package} and not $opts{template_mode}) {
290             $dep_first =~ s/#PACKAGE#/$opts{package}/g;
291         }
292         print { $fh } "$soname $dep_first\n" if defined $fh;
293         $res .= "$soname $dep_first\n" if defined wantarray;
294
295         foreach my $dep_next (@deps) {
296             if (exists $opts{package} and not $opts{template_mode}) {
297                 $dep_next =~ s/#PACKAGE#/$opts{package}/g;
298             }
299             print { $fh } "| $dep_next\n" if defined $fh;
300             $res .= "| $dep_next\n" if defined wantarray;
301         }
302         my $f = $self->{objects}{$soname}{fields};
303         foreach my $field (sort keys %{$f}) {
304             my $value = $f->{$field};
305             if (exists $opts{package} and not $opts{template_mode}) {
306                 $value =~ s/#PACKAGE#/$opts{package}/g;
307             }
308             print { $fh } "* $field: $value\n" if defined $fh;
309             $res .= "* $field: $value\n" if defined wantarray;
310         }
311
312         my @symbols;
313         if ($opts{template_mode}) {
314             # Exclude symbols matching a pattern, but include patterns themselves
315             @symbols = grep { not $_->get_pattern() } $self->get_symbols($soname);
316             push @symbols, $self->get_patterns($soname);
317         } else {
318             @symbols = $self->get_symbols($soname);
319         }
320         foreach my $sym (sort { $a->get_symboltempl() cmp
321                                 $b->get_symboltempl() } @symbols) {
322             next if $sym->{deprecated} and not $opts{with_deprecated};
323             # Do not dump symbols from foreign arch unless dumping a template.
324             next if not $opts{template_mode} and
325                     not $sym->arch_is_concerned($self->get_arch());
326             # Dump symbol specification. Dump symbol tags only in template mode.
327             print { $fh } $sym->get_symbolspec($opts{template_mode}), "\n" if defined $fh;
328             $res .= $sym->get_symbolspec($opts{template_mode}) . "\n" if defined wantarray;
329             # Dump pattern matches as comments (if requested)
330             if ($opts{with_pattern_matches} && $sym->is_pattern()) {
331                 for my $match (sort { $a->get_symboltempl() cmp
332                                       $b->get_symboltempl() } $sym->get_pattern_matches())
333                 {
334                     print { $fh } '#MATCH:', $match->get_symbolspec(0), "\n" if defined $fh;
335                     $res .= '#MATCH:' . $match->get_symbolspec(0) . "\n" if defined wantarray;
336                 }
337             }
338         }
339     }
340     return $res;
341 }
342
343 # Tries to match a symbol name and/or version against the patterns defined.
344 # Returns a pattern which matches (if any).
345 sub find_matching_pattern {
346     my ($self, $refsym, $sonames, $inc_deprecated) = @_;
347     $inc_deprecated //= 0;
348     my $name = (ref $refsym) ? $refsym->get_symbolname() : $refsym;
349
350     my $pattern_ok = sub {
351         my $p = shift;
352         return defined $p && ($inc_deprecated || !$p->{deprecated}) &&
353                $p->arch_is_concerned($self->get_arch());
354     };
355
356     foreach my $soname ((ref($sonames) eq 'ARRAY') ? @$sonames : $sonames) {
357         my $obj = $self->get_object($soname);
358         my ($type, $pattern);
359         next unless defined $obj;
360
361         my $all_aliases = $obj->{patterns}{aliases};
362         for my $type (Dpkg::Shlibs::Symbol::ALIAS_TYPES) {
363             if (exists $all_aliases->{$type} && keys(%{$all_aliases->{$type}})) {
364                 my $aliases = $all_aliases->{$type};
365                 my $converter = $aliases->{(keys %$aliases)[0]};
366                 if (my $alias = $converter->convert_to_alias($name)) {
367                     if ($alias && exists $aliases->{$alias}) {
368                         $pattern = $aliases->{$alias};
369                         last if &$pattern_ok($pattern);
370                         $pattern = undef; # otherwise not found yet
371                     }
372                 }
373             }
374         }
375
376         # Now try generic patterns and use the first that matches
377         if (not defined $pattern) {
378             for my $p (@{$obj->{patterns}{generic}}) {
379                 if (&$pattern_ok($p) && $p->matches_rawname($name)) {
380                     $pattern = $p;
381                     last;
382                 }
383             }
384         }
385         if (defined $pattern) {
386             return (wantarray) ?
387                 ( symbol => $pattern, soname => $soname ) : $pattern;
388         }
389     }
390     return;
391 }
392
393 # merge_symbols($object, $minver)
394 # Needs $Objdump->get_object($soname) as parameter
395 # Don't merge blacklisted symbols related to the internal (arch-specific)
396 # machinery
397 sub merge_symbols {
398     my ($self, $object, $minver) = @_;
399
400     my $soname = $object->{SONAME};
401     error(g_('cannot merge symbols from objects without SONAME'))
402         unless $soname;
403
404     my %include_groups = ();
405     my $groups = $self->get_field($soname, 'Ignore-Blacklist-Groups');
406     if (defined $groups) {
407         $include_groups{$_} = 1 foreach (split /\s+/, $groups);
408     }
409
410     my %dynsyms;
411     foreach my $sym ($object->get_exported_dynamic_symbols()) {
412         my $name = $sym->{name} . '@' .
413                    ($sym->{version} ? $sym->{version} : 'Base');
414         my $symobj = $self->lookup_symbol($name, $soname);
415         if (symbol_is_blacklisted($sym->{name}, \%include_groups)) {
416             next unless (defined $symobj and $symobj->has_tag('ignore-blacklist'));
417         }
418         $dynsyms{$name} = $sym;
419     }
420
421     unless ($self->has_object($soname)) {
422         $self->create_object($soname, '');
423     }
424     # Scan all symbols provided by the objects
425     my $obj = $self->get_object($soname);
426     # invalidate the minimum version cache - it is not sufficient to
427     # invalidate in add_symbol, since we might change a minimum
428     # version for a particular symbol without adding it
429     $obj->{minver_cache} = [];
430     foreach my $name (keys %dynsyms) {
431         my $sym;
432         if ($sym = $self->lookup_symbol($name, $obj, 1)) {
433             # If the symbol is already listed in the file
434             $sym->mark_found_in_library($minver, $self->get_arch());
435         } else {
436             # The exact symbol is not present in the file, but it might match a
437             # pattern.
438             my $pattern = $self->find_matching_pattern($name, $obj, 1);
439             if (defined $pattern) {
440                 $pattern->mark_found_in_library($minver, $self->get_arch());
441                 $sym = $pattern->create_pattern_match(symbol => $name);
442             } else {
443                 # Symbol without any special info as no pattern matched
444                 $sym = Dpkg::Shlibs::Symbol->new(symbol => $name,
445                                                  minver => $minver);
446             }
447             $self->add_symbol($sym, $obj);
448         }
449     }
450
451     # Process all symbols which could not be found in the library.
452     foreach my $sym ($self->get_symbols($soname)) {
453         if (not exists $dynsyms{$sym->get_symbolname()}) {
454             $sym->mark_not_found_in_library($minver, $self->get_arch());
455         }
456     }
457
458     # Deprecate patterns which didn't match anything
459     for my $pattern (grep { $_->get_pattern_matches() == 0 }
460                           $self->get_patterns($soname)) {
461         $pattern->mark_not_found_in_library($minver, $self->get_arch());
462     }
463 }
464
465 sub is_empty {
466     my $self = shift;
467     return scalar(keys %{$self->{objects}}) ? 0 : 1;
468 }
469
470 sub has_object {
471     my ($self, $soname) = @_;
472     return exists $self->{objects}{$soname};
473 }
474
475 sub get_object {
476     my ($self, $soname) = @_;
477     return ref($soname) ? $soname : $self->{objects}{$soname};
478 }
479
480 sub create_object {
481     my ($self, $soname, @deps) = @_;
482     $self->{objects}{$soname} = {
483         syms => {},
484         fields => {},
485         patterns => {
486             aliases => {},
487             generic => [],
488         },
489         deps => [ @deps ],
490         minver_cache => []
491     };
492 }
493
494 sub get_dependency {
495     my ($self, $soname, $dep_id) = @_;
496     $dep_id //= 0;
497     return $self->get_object($soname)->{deps}[$dep_id];
498 }
499
500 sub get_smallest_version {
501     my ($self, $soname, $dep_id) = @_;
502     $dep_id //= 0;
503     my $so_object = $self->get_object($soname);
504     return $so_object->{minver_cache}[$dep_id]
505         if defined $so_object->{minver_cache}[$dep_id];
506     my $minver;
507     foreach my $sym ($self->get_symbols($so_object)) {
508         next if $dep_id != $sym->{dep_id};
509         $minver //= $sym->{minver};
510         if (version_compare($minver, $sym->{minver}) > 0) {
511             $minver = $sym->{minver};
512         }
513     }
514     $so_object->{minver_cache}[$dep_id] = $minver;
515     return $minver;
516 }
517
518 sub get_dependencies {
519     my ($self, $soname) = @_;
520     return @{$self->get_object($soname)->{deps}};
521 }
522
523 sub get_field {
524     my ($self, $soname, $name) = @_;
525     if (my $obj = $self->get_object($soname)) {
526         if (exists $obj->{fields}{$name}) {
527             return $obj->{fields}{$name};
528         }
529     }
530     return;
531 }
532
533 # Tries to find a symbol like the $refsym and returns its descriptor.
534 # $refsym may also be a symbol name.
535 sub lookup_symbol {
536     my ($self, $refsym, $sonames, $inc_deprecated) = @_;
537     $inc_deprecated //= 0;
538     my $name = (ref $refsym) ? $refsym->get_symbolname() : $refsym;
539
540     foreach my $so ((ref($sonames) eq 'ARRAY') ? @$sonames : $sonames) {
541         if (my $obj = $self->get_object($so)) {
542             my $sym = $obj->{syms}{$name};
543             if ($sym and ($inc_deprecated or not $sym->{deprecated}))
544             {
545                 return (wantarray) ?
546                     ( symbol => $sym, soname => $so ) : $sym;
547             }
548         }
549     }
550     return;
551 }
552
553 # Tries to find a pattern like the $refpat and returns its descriptor.
554 # $refpat may also be a pattern spec.
555 sub lookup_pattern {
556     my ($self, $refpat, $sonames, $inc_deprecated) = @_;
557     $inc_deprecated //= 0;
558     # If $refsym is a string, we need to create a dummy ref symbol.
559     $refpat = $self->create_symbol($refpat, dummy => 1) if ! ref($refpat);
560
561     if ($refpat && $refpat->is_pattern()) {
562         foreach my $soname ((ref($sonames) eq 'ARRAY') ? @$sonames : $sonames) {
563             if (my $obj = $self->get_object($soname)) {
564                 my $pat;
565                 if (my $type = $refpat->get_alias_type()) {
566                     if (exists $obj->{patterns}{aliases}{$type}) {
567                         $pat = $obj->{patterns}{aliases}{$type}{$refpat->get_symbolname()};
568                     }
569                 } elsif ($refpat->get_pattern_type() eq 'generic') {
570                     for my $p (@{$obj->{patterns}{generic}}) {
571                         if (($inc_deprecated || !$p->{deprecated}) &&
572                             $p->equals($refpat, versioning => 0))
573                         {
574                             $pat = $p;
575                             last;
576                         }
577                     }
578                 }
579                 if ($pat && ($inc_deprecated || !$pat->{deprecated})) {
580                     return (wantarray) ?
581                         (symbol => $pat, soname => $soname) : $pat;
582                 }
583             }
584         }
585     }
586     return;
587 }
588
589 # Get symbol object reference either by symbol name or by a reference object.
590 sub get_symbol_object {
591     my ($self, $refsym, $soname) = @_;
592     my $sym = $self->lookup_symbol($refsym, $soname, 1);
593     if (! defined $sym) {
594         $sym = $self->lookup_pattern($refsym, $soname, 1);
595     }
596     return $sym;
597 }
598
599 sub get_new_symbols {
600     my ($self, $ref, %opts) = @_;
601     my $with_optional = (exists $opts{with_optional}) ?
602         $opts{with_optional} : 0;
603     my @res;
604     foreach my $soname ($self->get_sonames()) {
605         next if not $ref->has_object($soname);
606
607         # Scan raw symbols first.
608         foreach my $sym (grep { ($with_optional || ! $_->is_optional())
609                                 && $_->is_legitimate($self->get_arch()) }
610                               $self->get_symbols($soname))
611         {
612             my $refsym = $ref->lookup_symbol($sym, $soname, 1);
613             my $isnew;
614             if (defined $refsym) {
615                 # If the symbol exists in the $ref symbol file, it might
616                 # still be new if $refsym is not legitimate.
617                 $isnew = not $refsym->is_legitimate($self->get_arch());
618             } else {
619                 # If the symbol does not exist in the $ref symbol file, it does
620                 # not mean that it's new. It might still match a pattern in the
621                 # symbol file. However, due to performance reasons, first check
622                 # if the pattern that the symbol matches (if any) exists in the
623                 # ref symbol file as well.
624                 $isnew = not (
625                     ($sym->get_pattern() and $ref->lookup_pattern($sym->get_pattern(), $soname, 1)) or
626                     $ref->find_matching_pattern($sym, $soname, 1)
627                 );
628             }
629             push @res, { symbol => $sym, soname => $soname } if $isnew;
630         }
631
632         # Now scan patterns
633         foreach my $p (grep { ($with_optional || ! $_->is_optional())
634                               && $_->is_legitimate($self->get_arch()) }
635                             $self->get_patterns($soname))
636         {
637             my $refpat = $ref->lookup_pattern($p, $soname, 0);
638             # If reference pattern was not found or it is not legitimate,
639             # considering current one as new.
640             if (not defined $refpat or
641                 not $refpat->is_legitimate($self->get_arch()))
642             {
643                 push @res, { symbol => $p , soname => $soname };
644             }
645         }
646     }
647     return @res;
648 }
649
650 sub get_lost_symbols {
651     my ($self, $ref, %opts) = @_;
652     return $ref->get_new_symbols($self, %opts);
653 }
654
655
656 sub get_new_libs {
657     my ($self, $ref) = @_;
658     my @res;
659     foreach my $soname ($self->get_sonames()) {
660         push @res, $soname if not $ref->get_object($soname);
661     }
662     return @res;
663 }
664
665 sub get_lost_libs {
666     my ($self, $ref) = @_;
667     return $ref->get_new_libs($self);
668 }
669
670 1;