Skip to content

Commit c9223af

Browse files
JianyuWang0623pkarashchenko
authored andcommitted
tools/mksymtab.sh: Support multiple additional symbols` file
Test ``` $ cat basic.txt test_a test_b test_c $ cat math.txt acosf asinf atan2f ceilf cosf expf $ ./mksymtab.sh ./ g_TEST basic.txt #include <nuttx/compiler.h> #include <nuttx/symtab.h> extern void *test_a; extern void *test_b; extern void *test_c; const struct symtab_s g_TEST_exports[] = { {"test_a", &test_a}, {"test_b", &test_b}, {"test_c", &test_c}, }; const int g_TEST_nexports = sizeof(g_TEST_exports) / sizeof(struct symtab_s); $ ./mksymtab.sh ./ g_TEST basic.txt math.txt #include <nuttx/compiler.h> #include <nuttx/symtab.h> extern void *acosf; extern void *asinf; extern void *atan2f; extern void *ceilf; extern void *cosf; extern void *expf; extern void *test_a; extern void *test_b; extern void *test_c; const struct symtab_s g_TEST_exports[] = { {"acosf", &acosf}, {"asinf", &asinf}, {"atan2f", &atan2f}, {"ceilf", &ceilf}, {"cosf", &cosf}, {"expf", &expf}, {"test_a", &test_a}, {"test_b", &test_b}, {"test_c", &test_c}, }; const int g_TEST_nexports = sizeof(g_TEST_exports) / sizeof(struct symtab_s); ``` Signed-off-by: wangjianyu3 <[email protected]>
1 parent c6f00c0 commit c9223af

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tools/mksymtab.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fi
3636
# Get the symbol table prefix
3737

3838
prefix=$2
39-
add_sym=$3
4039

4140
# Extract all of the undefined symbols from the ELF files and create a
4241
# list of sorted, unique undefined variable names.
@@ -60,16 +59,19 @@ if [ -z "$varlist" ]; then
6059
fi
6160
fi
6261

63-
if [ "x$add_sym" != "x" ]; then
64-
if [ -f $add_sym ]; then
65-
varlist="${varlist}\n$(cat $add_sym | grep -v "^,.*")"
66-
elif [ -d $add_sym ]; then
67-
varlist="${varlist}\n$(find $add_sym -type f | xargs cat | grep -v "^,.*")"
68-
else
69-
echo $usage
70-
exit 1
71-
fi
72-
varlist=$(echo -e "${varlist}" | sort -u)
62+
if [ $# -gt 2 ]; then
63+
shift 2
64+
for add_sym in $@; do
65+
if [ -f $add_sym ]; then
66+
varlist="${varlist}\n$(cat $add_sym | grep -v "^,.*")"
67+
elif [ -d $add_sym ]; then
68+
varlist="${varlist}\n$(find $add_sym -type f | xargs cat | grep -v "^,.*")"
69+
else
70+
echo $usage
71+
exit 1
72+
fi
73+
varlist=$(echo -e "${varlist}" | sort -u)
74+
done
7375
fi
7476

7577
# Now output the symbol table as a structure in a C source file. All

0 commit comments

Comments
 (0)