| .. | .. |
|---|
| 2 | 2 | # SPDX-License-Identifier: GPL-2.0-only |
|---|
| 3 | 3 | |
|---|
| 4 | 4 | # Create an autoksyms.h header file from the list of all module's needed symbols |
|---|
| 5 | | -# as recorded on the third line of *.mod files and the user-provided symbol |
|---|
| 5 | +# as recorded on the second line of *.mod files and the user-provided symbol |
|---|
| 6 | 6 | # whitelist. |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | set -e |
|---|
| .. | .. |
|---|
| 19 | 19 | # We need access to CONFIG_ symbols |
|---|
| 20 | 20 | . include/config/auto.conf |
|---|
| 21 | 21 | |
|---|
| 22 | | -ksym_wl=/dev/null |
|---|
| 22 | +needed_symbols= |
|---|
| 23 | + |
|---|
| 24 | +# Special case for modversions (see modpost.c) |
|---|
| 25 | +if [ -n "$CONFIG_MODVERSIONS" ]; then |
|---|
| 26 | + needed_symbols="$needed_symbols module_layout" |
|---|
| 27 | +fi |
|---|
| 28 | + |
|---|
| 29 | +# With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a binary |
|---|
| 30 | +# when the .mod files are generated, which means they don't yet contain |
|---|
| 31 | +# references to certain symbols that will be present in the final binaries. |
|---|
| 32 | +if [ -n "$CONFIG_LTO_CLANG" ]; then |
|---|
| 33 | + # intrinsic functions |
|---|
| 34 | + needed_symbols="$needed_symbols memcpy memmove memset" |
|---|
| 35 | + # ftrace |
|---|
| 36 | + needed_symbols="$needed_symbols _mcount" |
|---|
| 37 | + # stack protector symbols |
|---|
| 38 | + needed_symbols="$needed_symbols __stack_chk_fail __stack_chk_guard" |
|---|
| 39 | +fi |
|---|
| 40 | + |
|---|
| 41 | +ksym_wl= |
|---|
| 23 | 42 | if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then |
|---|
| 24 | 43 | # Use 'eval' to expand the whitelist path and check if it is relative |
|---|
| 25 | 44 | eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST" |
|---|
| .. | .. |
|---|
| 39 | 58 | |
|---|
| 40 | 59 | EOT |
|---|
| 41 | 60 | |
|---|
| 42 | | -for mod in "$MODVERDIR"/*.mod; do |
|---|
| 43 | | - [ -f "$mod" ] && sed -n -e '3{s/ /\n/g;/^$/!p;}' "$mod" |
|---|
| 44 | | -done | cat - "$ksym_wl" | sort -u | |
|---|
| 45 | | -while read sym; do |
|---|
| 46 | | - echo "#define __KSYM_${sym} 1" |
|---|
| 47 | | -done >> "$output_file" |
|---|
| 61 | +[ -f modules.order ] && modlist=modules.order || modlist=/dev/null |
|---|
| 48 | 62 | |
|---|
| 49 | | -# Special case for modversions (see modpost.c) |
|---|
| 50 | | -if [ -n "$CONFIG_MODVERSIONS" ]; then |
|---|
| 51 | | - echo "#define __KSYM_module_layout 1" >> "$output_file" |
|---|
| 52 | | -fi |
|---|
| 63 | +{ |
|---|
| 64 | + sed 's/ko$/mod/' $modlist | xargs -n1 sed -n -e '2p' |
|---|
| 65 | + echo "$needed_symbols" |
|---|
| 66 | + [ -n "$ksym_wl" ] && cat "$ksym_wl" |
|---|
| 67 | +} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' | |
|---|
| 68 | +# Remove the dot prefix for ppc64; symbol names with a dot (.) hold entry |
|---|
| 69 | +# point addresses. |
|---|
| 70 | +sed -e 's/^\.//' | |
|---|
| 71 | +sort -u | |
|---|
| 72 | +sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file" |
|---|