2020-09-06 18:08:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
2020-09-06 22:00:12 +00:00
|
|
|
cd "$script_path/.." || exit 1
|
2020-09-06 18:08:18 +00:00
|
|
|
|
2020-10-02 21:14:37 +00:00
|
|
|
# The __cxa_guard_* calls are generated for (non trivial) initialization of local static objects.
|
2020-09-06 18:08:18 +00:00
|
|
|
# These symbols are OK to use within serenity code, but they are problematic in LibC because their
|
|
|
|
# existence breaks ports (the implementation of these symbols resides in libstdc++.a which we do not link against in ports).
|
|
|
|
# To eliminate the need for these symbols, avoid doing non-trivial construction of local statics in LibC.
|
|
|
|
|
|
|
|
FORBIDDEN_SYMBOLS="__cxa_guard_acquire __cxa_guard_release"
|
2022-10-02 17:55:22 +00:00
|
|
|
TARGET="${SERENITY_ARCH:-"x86_64"}"
|
2022-01-14 12:26:23 +00:00
|
|
|
LIBC_PATH="Build/${TARGET}/Userland/Libraries/LibC/libc.a"
|
2020-09-06 18:08:18 +00:00
|
|
|
for forbidden_symbol in $FORBIDDEN_SYMBOLS; do
|
2021-03-17 21:23:13 +00:00
|
|
|
# check if there's an undefined reference to the symbol & it is not defined anywhere else in the library
|
2022-01-14 12:26:23 +00:00
|
|
|
nm "$LIBC_PATH" | grep "U $forbidden_symbol"
|
2021-03-17 21:23:13 +00:00
|
|
|
APPEARS_AS_UNDEFINED=$?
|
2022-01-14 12:26:23 +00:00
|
|
|
nm "$LIBC_PATH" | grep "T $forbidden_symbol"
|
2021-03-17 21:23:13 +00:00
|
|
|
APPEARS_AS_DEFINED=$?
|
|
|
|
if [ $APPEARS_AS_UNDEFINED -eq 0 ] && [ ! $APPEARS_AS_DEFINED -eq 0 ]; then
|
2020-09-06 18:08:18 +00:00
|
|
|
echo "Forbidden undefined symbol in LibC: $forbidden_symbol"
|
|
|
|
echo "See comment in Meta/check-symbols.sh for more info"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|