Skip to content

Commit c0d04b4

Browse files
committed
Fix bash scripts
1 parent 7f2466f commit c0d04b4

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

scripts/check_symbols.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SCRIPT=$(realpath "$0")
66
THIS_DIR=$(dirname "$SCRIPT")
77

88
# get all the symbols our shared library assumes are externally provided
9-
MAYBE_EXTERN=$(nm -u $1 | awk '{print $2}' | sed -e 's/@/@@/' | sed -n -e 's/@@.*$//p')
9+
MAYBE_EXTERN=$(nm -D $1 | grep ' U ' | awk '{print $2}' | sed -e 's/@.*//')
1010

1111
# get all the symbols that are externally provided
1212
EXTERN_PROVIDED=$($THIS_DIR/extern_defined.sh)

scripts/extern_defined.sh

+14-8
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,26 @@ IFS=$'\n\t'
3535

3636
PG_BIN=$(pg_config --bindir)/postgres
3737

38-
nm -D $PG_BIN | grep " T " | awk '{print $3}' | sed -n -e 's/@.*$//p'
38+
# " T " - text symbol
39+
nm -D $PG_BIN | grep " T " | awk '{print $3}' | sed -e 's/@.*$//p'
3940
# global bss symbol in postgres
40-
nm -D $PG_BIN | grep " B " | awk '{print $3}' | sed -n -e 's/@.*$//p'
41+
nm -D $PG_BIN | grep " B " | awk '{print $3}' | sed -e 's/@.*$//p'
4142
# postgres weak symbols
42-
nm -D $PG_BIN | grep " w " | awk '{print $2}' | sed -n -e 's/@.*$//p'
43+
nm -D $PG_BIN | grep " w " | awk '{print $2}' | sed -e 's/@.*$//p'
4344

4445
# Get a list of shared library dependencies using ldd
4546
dependencies=$(ldd "$PG_BIN" | awk '{print $3}' | grep -v "not a dynamic executable")
4647

4748
# Loop through the dependencies and extract symbols
4849
for dependency in $dependencies; do
49-
nm -D "$dependency" | awk '/ U / {print $3}' | sed -n -e 's/@.*$//p'
50-
nm -D "$dependency" | awk '/ i / {print $3}' | sed -n -e 's/@.*$//p'
51-
nm -D "$dependency" | awk '/ T / {print $3}' | sed -n -e 's/@.*$//p'
52-
nm -D "$dependency" | awk '/ V / {print $3}' | sed -n -e 's/@.*$//p'
53-
nm -D "$dependency" | awk '/ W / {print $3}' | sed -n -e 's/@.*$//p'
50+
# " U " - undefined symbol
51+
nm -D "$dependency" | awk '/ U / {print $3}' | sed -e 's/@.*$//p'
52+
# " i " - the symbol is an indirect reference to another symbol. This is often used for compiler-generated code
53+
nm -D "$dependency" | awk '/ i / {print $3}' | sed -e 's/@.*$//p'
54+
# " T " - The symbol is a text (code) symbol, representing a function or code that can be executed
55+
nm -D "$dependency" | awk '/ T / {print $3}' | sed -e 's/@.*$//p'
56+
# " V " - the symbol is a weak object
57+
nm -D "$dependency" | awk '/ V / {print $3}' | sed -e 's/@.*$//p'
58+
# " W " - the symbol is a weak symbol that has not been specifically tagged as weak object symbol
59+
nm -D "$dependency" | awk '/ W / {print $3}' | sed -e 's/@.*$//p'
5460
done

0 commit comments

Comments
 (0)