forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts/utils: Build a list of "excluded" libc APIs
This script generates a list of exported symbols (functions, global variables, static inlines and CPP names) which are present in picolibc but not present in the minimal C library. These symbols shall not be used by the "core Zephyr kernel"; the construction of a script that detects use of the is left as an exercise to the reader. Signed-off-by: Keith Packard <[email protected]>
- Loading branch information
1 parent
2b4fdd1
commit 310e7ed
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
virtual patch | ||
virtual report | ||
|
||
@initialize:python@ | ||
@@ | ||
@find_id@ | ||
identifier id; | ||
type ty; | ||
parameter list[nb_params] params; | ||
position p; | ||
@@ | ||
( | ||
ty id@p(params); | ||
| | ||
extern ty id@p; | ||
) | ||
|
||
@script:python@ | ||
id << find_id.id; | ||
p << find_id.p; | ||
@@ | ||
print("identifier %s %s %s" % (id, p[0].file, p[0].line)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
HERE=`dirname "$0"` | ||
|
||
if [ -z "$ZEPHYR_SDK_INSTALL_DIR" ]; then | ||
echo 'Must define ZEPHYR_SDK_INSTALL_DIR' 1>&2 | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$ZEPHYR_BASE" ]; then | ||
echo 'Must define ZEPHYR_BASE' 1>&2 | ||
exit 1 | ||
fi | ||
|
||
gen_syms() { | ||
while read i; do | ||
spatch --macro-file "$HERE"/libc-macros.h -sp-file "$HERE"/find_id.cocci "$i" 2>/dev/null | | ||
awk '/identifier/ { if ($2 !~ "_.*") print $2; }' | ||
grep '^[ \t]*#[ \t]*\(define\|undef\)[ \t][ \t]*[A-Za-z]' "$i" | | ||
sed 's/^[ \t]*#[ \t]*\(define\|undef\)[ \t][ \t]*\([_A-Za-z][_A-Za-z0-9]*\).*$/\1 \2/' | | ||
awk '{ if ($1 == "define") defs[$2] = 1; else defs[$2] = 0; } END { for (id in defs) if (defs[id]) print id; }' | ||
done | (LANG=C sort -u) | ||
} | ||
|
||
TMPDIR=`mktemp -d $PWD/gen-libc.XXXXXXXX` | ||
trap "rm -r $TMPDIR" EXIT | ||
|
||
MINIMAL_LIBC_INCLUDE="$ZEPHYR_BASE"/lib/libc/minimal/include | ||
POSIX_INCLUDE="$ZEPHYR_BASE"/include/zephyr/posix | ||
MINIMAL_LIBC_SYMS="$TMPDIR"/minimal-names | ||
|
||
find "$MINIMAL_LIBC_INCLUDE" "$POSIX_INCLUDE" -type f | gen_syms > "$MINIMAL_LIBC_SYMS" | ||
|
||
PICOLIBC_INCLUDE="$ZEPHYR_SDK_INSTALL_DIR"/arm-zephyr-eabi/picolibc/include | ||
PICOLIBC_LIBC_SYMS="$TMPDIR"/picolibc-names | ||
|
||
find "$PICOLIBC_INCLUDE" -type f | gen_syms > "$PICOLIBC_LIBC_SYMS" | ||
|
||
LANG=C comm -23 "$PICOLIBC_LIBC_SYMS" "$MINIMAL_LIBC_SYMS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#define __printf_like(a,b) |