|
| 1 | +#!/bin/sh |
| 2 | +# This script writes out all the exported symbols to a file |
| 3 | +# AIX needs this as sybmols are not exported by an |
| 4 | +# executable by default and we need to list |
| 5 | +# them specifically in order to export them |
| 6 | +# so that they can be used by native add-ons |
| 7 | +# |
| 8 | +# The raw symbol data is objtained by using nm on |
| 9 | +# the .a files which make up the node executable |
| 10 | +# |
| 11 | +# -Xany makes sure we get symbols on both |
| 12 | +# 32 bit and 64 bit as by default we'd only get those |
| 13 | +# for 32 bit |
| 14 | +# |
| 15 | +# -g selects only exported symbols |
| 16 | +# |
| 17 | +# -C, -B and -p ensure the output is in a format we |
| 18 | +# can easily parse and convert into the symbol we need |
| 19 | +# |
| 20 | +# -C suppresses the demangling of C++ names |
| 21 | +# -B gives us output in BSD format |
| 22 | +# -p displays the info in a standard portable output format |
| 23 | +# |
| 24 | +# We only include symbols if they are of the |
| 25 | +# following types and don't start with a dot. |
| 26 | +# |
| 27 | +# T - Global text symbol |
| 28 | +# D - Global data symbol |
| 29 | +# B - Gobal bss symbol. |
| 30 | +# |
| 31 | +# the final sort allows us to remove any duplicates |
| 32 | +# |
| 33 | +# We need to exclude gtest libraries as they are not |
| 34 | +# linked into the node executable |
| 35 | +# |
| 36 | +echo "Searching $1 to write out expfile to $2" |
| 37 | + |
| 38 | +# this special sequence must be at the start of the exp file |
| 39 | +echo "#!." > $2 |
| 40 | + |
| 41 | +# pull the symbols from the .a files |
| 42 | +find $1 -name "*.a" | grep -v gtest \ |
| 43 | + | xargs nm -Xany -BCpg \ |
| 44 | + | awk '{ |
| 45 | + if ((($2 == "T") || ($2 == "D") || ($2 == "B")) && |
| 46 | + (substr($3,1,1) != ".")) { print $3 } |
| 47 | + }' \ |
| 48 | + | sort -u >> $2 |
0 commit comments