• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Writes out all of the exported symbols to a file.
3# This is needed on AIX as symbols are not exported
4# by an executable by default and need to be listed
5# specifically for export so that they can be used
6# by native add-ons.
7#
8# The raw symbol data is obtained by using nm on
9# the .a files which make up the node executable.
10#
11# -Xany processes symbols for both 32-bit and
12# 64-bit (the default is for 32-bit only).
13#
14# -g selects only exported symbols.
15#
16# -C, -B and -p ensure that the output is in a
17# format that can be easily parsed and converted
18# into the required symbol.
19#
20# -C suppresses the demangling of C++ names.
21# -B writes the output in BSD format.
22# -p displays the info in a standard portable
23#    output format.
24#
25# Only include symbols if they are of the following
26# types and don't start with a dot.
27#
28# T - Global text symbol.
29# D - Global data symbol.
30# B - Global bss symbol.
31#
32# The final sort allows removal of any duplicates.
33#
34# Symbols for the gtest libraries are excluded as
35# they are not linked into the node executable.
36#
37echo "Searching $1 to write out expfile to $2"
38
39# This special sequence must be at the start of the exp file.
40echo "#!." > "$2.tmp"
41
42# Pull the symbols from the .a files.
43find "$1" -name "*.a" | grep -v gtest \
44  | xargs nm -Xany -BCpg \
45  | awk '{
46      if ((($2 == "T") || ($2 == "D") || ($2 == "B")) &&
47          (substr($3,1,1) != ".")) { print $3 }
48    }' \
49  | sort -u >> "$2.tmp"
50
51mv -f "$2.tmp" "$2"
52