blob: 31dd8b2f1f91cf84d28499b118a0a2ea807b3d50 [file] [log] [blame]
Reid Spencer2fee2352006-03-23 23:04:50 +00001#!/usr/bin/perl -w
2#
3# Program: findsym.pl
4#
5# Synopsis: Generate a list of the libraries in which a symbol is defined or
6# referenced.
7#
8# Syntax: GenLibDeps.pl <directory_with_libraries_in_it> <symbol>
9#
10
11# Give first option a name.
12my $Directory = $ARGV[0];
13my $Symbol = $ARGV[1];
14
15
16# Open the directory and read its contents, sorting by name and differentiating
17# by whether its a library (.a) or an object file (.o)
18opendir DIR,$Directory;
19my @files = readdir DIR;
20closedir DIR;
21@objects = grep(/l?i?b?LLVM.*\.[oa]$/,sort(@files));
22
23# Gather definitions from the libraries
24foreach $lib (@objects) {
25 my $head = 0;
26 open SYMS,
27 "nm $Directory/$lib | grep '$Symbol' | sort --key=3 | uniq |";
28 while (<SYMS>) {
29 if (!$head) { print "$lib:\n"; $head = 1; }
30 chomp($_);
31 print " $_\n";
32 }
33 close SYMS;
34}