blob: 92346572fe01670167297427bafdee003e38af4d [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#
Reid Spencera7465ca2006-08-09 19:40:13 +00008# Syntax: findsym.pl <directory_with_libraries_in_it> <symbol>
Reid Spencer2fee2352006-03-23 23:04:50 +00009#
10
11# Give first option a name.
12my $Directory = $ARGV[0];
13my $Symbol = $ARGV[1];
14
Reid Spencer2fee2352006-03-23 23:04:50 +000015# Open the directory and read its contents, sorting by name and differentiating
16# by whether its a library (.a) or an object file (.o)
17opendir DIR,$Directory;
18my @files = readdir DIR;
19closedir DIR;
20@objects = grep(/l?i?b?LLVM.*\.[oa]$/,sort(@files));
21
22# Gather definitions from the libraries
23foreach $lib (@objects) {
24 my $head = 0;
25 open SYMS,
26 "nm $Directory/$lib | grep '$Symbol' | sort --key=3 | uniq |";
27 while (<SYMS>) {
28 if (!$head) { print "$lib:\n"; $head = 1; }
29 chomp($_);
30 print " $_\n";
31 }
32 close SYMS;
33}