Skip to content

Commit 6285b67

Browse files
committed
aix: fix export script to filter hidden ...
visibility for symbols. Without these changes we are getting back linker errors AIX with clang builds: ```text ld: 0711-407 ERROR: Symbol [SYMBOL_NAME] Visibility is not allowed on a reference to an imported symbol. ``` Not including hidden symbols in the export files matches the recomendation by XLC documentation: > When using export lists, it is not recommended to put symbols with > hidden visibility in the lists. ref: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.4?topic=libraries-symbol-exports-visibilities
1 parent 24119b8 commit 6285b67

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

tools/create_expfile.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,35 @@
3434
# Symbols for the gtest libraries are excluded as
3535
# they are not linked into the node executable.
3636
#
37+
set -x
3738
echo "Searching $1 to write out expfile to $2"
3839

3940
# This special sequence must be at the start of the exp file.
4041
echo "#!." > "$2.tmp"
4142

4243
# Pull the symbols from the .a files.
43-
find "$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"
44+
# Use dump -tov to get visibility information and exclude HIDDEN symbols
45+
# This prevents AIX linker error 0711-407 when addons try to import symbols
46+
# with visibility attributes.
47+
find "$1" -name "*.a" | grep -v gtest | while read f; do
48+
dump -tov -X 32_64 "$f" 2>/dev/null | \
49+
awk '
50+
BEGIN {
51+
V["EXPORTED"]=" export"
52+
V["PROTECTED"]=" protected"
53+
V["HIDDEN"]=" hidden"
54+
}
55+
/^\[[0-9]+\]\tm +[^ ]+ +\.(text|data|tdata|bss) +[^ ]+ +(extern|weak) +(EXPORTED|PROTECTED|HIDDEN| ) / {
56+
# Exclude symbols starting with dot, __sinit, __sterm, __[0-9]+__
57+
# Also exclude HIDDEN symbols to avoid visibility attribute issues
58+
if (!match($NF,/^(\.|__sinit|__sterm|__[0-9]+__)/)) {
59+
visibility = $(NF-1)
60+
if (visibility != "HIDDEN") {
61+
print $NF
62+
}
63+
}
64+
}
65+
'
66+
done | sort -u >> "$2.tmp"
5067

5168
mv -f "$2.tmp" "$2"

0 commit comments

Comments
 (0)