diff options
Diffstat (limited to 'scripts/link-vmlinux.sh')
-rwxr-xr-x | scripts/link-vmlinux.sh | 126 |
1 files changed, 9 insertions, 117 deletions
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index a7f6196c7e41..eecc1863e556 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -45,115 +45,6 @@ info() printf " %-7s %s\n" "${1}" "${2}" } -# Generate a linker script to ensure correct ordering of initcalls. -gen_initcalls() -{ - info GEN .tmp_initcalls.lds - - ${PYTHON3} ${srctree}/scripts/jobserver-exec \ - ${PERL} ${srctree}/scripts/generate_initcall_order.pl \ - ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS} \ - > .tmp_initcalls.lds -} - -# Link of vmlinux.o used for section mismatch analysis -# ${1} output file -modpost_link() -{ - local objects - local lds="" - - objects="--whole-archive \ - ${KBUILD_VMLINUX_OBJS} \ - --no-whole-archive \ - --start-group \ - ${KBUILD_VMLINUX_LIBS} \ - --end-group" - - if is_enabled CONFIG_LTO_CLANG; then - gen_initcalls - lds="-T .tmp_initcalls.lds" - - # This might take a while, so indicate that we're doing - # an LTO link - info LTO ${1} - else - info LD ${1} - fi - - ${LD} ${KBUILD_LDFLAGS} -r -o ${1} ${lds} ${objects} -} - -objtool_link() -{ - local objtoolcmd; - local objtoolopt; - - if ! is_enabled CONFIG_OBJTOOL; then - return; - fi - - if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then - - # For LTO and IBT, objtool doesn't run on individual - # translation units. Run everything on vmlinux instead. - - if is_enabled CONFIG_HAVE_JUMP_LABEL_HACK; then - objtoolopt="${objtoolopt} --hacks=jump_label" - fi - - if is_enabled CONFIG_HAVE_NOINSTR_HACK; then - objtoolopt="${objtoolopt} --hacks=noinstr" - fi - - if is_enabled CONFIG_X86_KERNEL_IBT; then - objtoolopt="${objtoolopt} --ibt" - fi - - if is_enabled CONFIG_FTRACE_MCOUNT_USE_OBJTOOL; then - objtoolopt="${objtoolopt} --mcount" - fi - - if is_enabled CONFIG_UNWINDER_ORC; then - objtoolopt="${objtoolopt} --orc" - fi - - if is_enabled CONFIG_RETPOLINE; then - objtoolopt="${objtoolopt} --retpoline" - fi - - if is_enabled CONFIG_SLS; then - objtoolopt="${objtoolopt} --sls" - fi - - if is_enabled CONFIG_STACK_VALIDATION; then - objtoolopt="${objtoolopt} --stackval" - fi - - if is_enabled CONFIG_HAVE_STATIC_CALL_INLINE; then - objtoolopt="${objtoolopt} --static-call" - fi - - objtoolopt="${objtoolopt} --uaccess" - fi - - if is_enabled CONFIG_NOINSTR_VALIDATION; then - objtoolopt="${objtoolopt} --noinstr" - fi - - if [ -n "${objtoolopt}" ]; then - - if is_enabled CONFIG_GCOV_KERNEL; then - objtoolopt="${objtoolopt} --no-unreachable" - fi - - objtoolopt="${objtoolopt} --link" - - info OBJTOOL ${1} - tools/objtool/objtool ${objtoolopt} ${1} - fi -} - # Link of vmlinux # ${1} - output file # ${2}, ${3}, ... - optional extra .o files @@ -303,14 +194,9 @@ sorttable() cleanup() { rm -f .btf.* - rm -f .tmp_System.map - rm -f .tmp_initcalls.lds - rm -f .tmp_vmlinux* rm -f System.map rm -f vmlinux rm -f vmlinux.map - rm -f vmlinux.o - rm -f .vmlinux.d rm -f .vmlinux.objs rm -f .vmlinux.export.c } @@ -341,12 +227,18 @@ fi; ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1 #link vmlinux.o -modpost_link vmlinux.o -objtool_link vmlinux.o +${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o" -# Generate the list of objects in vmlinux +# Generate the list of in-tree objects in vmlinux +# +# This is used to retrieve symbol versions generated by genksyms. for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do case ${f} in + *libgcc.a) + # Some architectures do '$(CC) --print-libgcc-file-name' to + # borrow libgcc.a from the toolchain. + # There is no EXPORT_SYMBOL in external objects. Ignore this. + ;; *.a) ${AR} t ${f} ;; *) |