123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- #!/bin/sh
- set -e
- info()
- {
- if [ "${quiet}" != "silent_" ]; then
- printf " %-7s %s\n" ${1} ${2}
- fi
- }
- archive_builtin()
- {
- if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
- info AR built-in.o
- rm -f built-in.o;
- ${AR} rcsT${KBUILD_ARFLAGS} built-in.o \
- ${KBUILD_VMLINUX_INIT} \
- ${KBUILD_VMLINUX_MAIN}
- if [ -n "${CONFIG_LTO_CLANG}" ]; then
- mv -f built-in.o built-in.o.tmp
- ${LLVM_AR} rcsT${KBUILD_ARFLAGS} built-in.o $(${AR} t built-in.o.tmp)
- rm -f built-in.o.tmp
- fi
- fi
- }
- modversions()
- {
- if [ -z "${CONFIG_LTO_CLANG}" ]; then
- return
- fi
- if [ -z "${CONFIG_MODVERSIONS}" ]; then
- return
- fi
- rm -f .tmp_symversions
- for a in built-in.o ${KBUILD_VMLINUX_LIBS}; do
- for o in $(${AR} t $a); do
- if [ -f ${o}.symversions ]; then
- cat ${o}.symversions >> .tmp_symversions
- fi
- done
- done
- echo "-T .tmp_symversions"
- }
- modpost_link()
- {
- local objects
- if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
- objects="--whole-archive built-in.o"
- else
- objects="${KBUILD_VMLINUX_INIT} \
- --start-group \
- ${KBUILD_VMLINUX_MAIN} \
- --end-group"
- fi
- if [ -n "${CONFIG_LTO_CLANG}" ]; then
-
-
- info LTO vmlinux.o
- else
- info LD vmlinux.o
- fi
- ${LD} ${LDFLAGS} -r -o ${1} $(modversions) ${objects}
- }
- recordmcount()
- {
- if [ -z "${CONFIG_LTO_CLANG}" ]; then
- return
- fi
- if [ -n "${CONFIG_FTRACE_MCOUNT_RECORD}" ]; then
- scripts/recordmcount ${RECORDMCOUNT_FLAGS} $*
- fi
- }
- vmlinux_link()
- {
- local lds="${objtree}/${KBUILD_LDS}"
- local objects
- if [ "${SRCARCH}" != "um" ]; then
- local ld=${LD}
- local ldflags="${LDFLAGS} ${LDFLAGS_vmlinux}"
- if [ -n "${LDFINAL_vmlinux}" ]; then
- ld=${LDFINAL_vmlinux}
- ldflags="${LDFLAGS_FINAL_vmlinux} ${LDFLAGS_vmlinux}"
- fi
- if [[ -n "${CONFIG_THIN_ARCHIVES}" && -z "${CONFIG_LTO_CLANG}" ]]; then
- objects="--whole-archive built-in.o ${1}"
- else
- objects="${KBUILD_VMLINUX_INIT} \
- --start-group \
- ${KBUILD_VMLINUX_MAIN} \
- --end-group \
- ${1}"
- fi
- ${ld} ${ldflags} -o ${2} -T ${lds} ${objects}
- else
- if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
- objects="-Wl,--whole-archive built-in.o ${1}"
- else
- objects="${KBUILD_VMLINUX_INIT} \
- -Wl,--start-group \
- ${KBUILD_VMLINUX_MAIN} \
- -Wl,--end-group \
- ${1}"
- fi
- ${CC} ${CFLAGS_vmlinux} -o ${2} \
- -Wl,-T,${lds} \
- ${objects} \
- -lutil -lrt -lpthread
- rm -f linux
- fi
- }
- kallsyms()
- {
- info KSYM ${2}
- local kallsymopt;
- if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then
- kallsymopt="${kallsymopt} --symbol-prefix=_"
- fi
- if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
- kallsymopt="${kallsymopt} --all-symbols"
- fi
- if [ -n "${CONFIG_KALLSYMS_ABSOLUTE_PERCPU}" ]; then
- kallsymopt="${kallsymopt} --absolute-percpu"
- fi
- if [ -n "${CONFIG_KALLSYMS_BASE_RELATIVE}" ]; then
- kallsymopt="${kallsymopt} --base-relative"
- fi
- local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
- ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
- local afile="`basename ${2} .o`.S"
- ${NM} -n ${1} | scripts/kallsyms ${kallsymopt} > ${afile}
- ${CC} ${aflags} -c -o ${2} ${afile}
- }
- rtic_mp()
- {
-
- RTIC_MP_O=
- ${RTIC_MPGEN} --objcopy="${OBJCOPY}" --objdump="${OBJDUMP}" \
- --binpath='' --vmlinux=${1} --config=${KCONFIG_CONFIG} && \
- cat rtic_mp.c | ${CC} -c -o ${2} -x c - && \
- cp rtic_mp.c ${4} && \
- ${NM} --print-size --size-sort ${2} > ${3} && \
- RTIC_MP_O=${2}
-
-
- }
- mksysmap()
- {
- ${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
- }
- sortextable()
- {
- ${objtree}/scripts/sortextable ${1}
- }
- cleanup()
- {
- rm -f .old_version
- rm -f .tmp_System.map
- rm -f .tmp_kallsyms*
- rm -f .tmp_version
- rm -f .tmp_symversions
- rm -f .tmp_vmlinux*
- rm -f built-in.o
- rm -f System.map
- rm -f vmlinux
- rm -f vmlinux.o
- rm -f .tmp_rtic_mp_sz*
- rm -f rtic_mp.*
- }
- on_exit()
- {
- if [ $? -ne 0 ]; then
- cleanup
- fi
- }
- trap on_exit EXIT
- on_signals()
- {
- exit 1
- }
- trap on_signals HUP INT QUIT TERM
- case "${KBUILD_VERBOSE}" in
- *1*)
- set -x
- ;;
- esac
- if [ "$1" = "clean" ]; then
- cleanup
- exit 0
- fi
- case "${KCONFIG_CONFIG}" in
- */*)
- . "${KCONFIG_CONFIG}"
- ;;
- *)
-
- . "./${KCONFIG_CONFIG}"
- esac
- info GEN .version
- if [ ! -r .version ]; then
- rm -f .version;
- echo 1 >.version;
- else
- mv .version .old_version;
- expr 0$(cat .old_version) + 1 >.version;
- fi;
- archive_builtin
- modpost_link vmlinux.o
- ${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o
- ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
- if [ -n "${CONFIG_LTO_CLANG}" ]; then
-
-
- KBUILD_VMLINUX_INIT=
- KBUILD_VMLINUX_MAIN=vmlinux.o
-
- recordmcount vmlinux.o
- fi
- if [ ! -z ${RTIC_MPGEN+x} ]; then
- rtic_mp vmlinux.o rtic_mp.o .tmp_rtic_mp_sz1 .tmp_rtic_mp1.c
- KBUILD_VMLINUX_MAIN+=" "
- KBUILD_VMLINUX_MAIN+=$RTIC_MP_O
- fi
- kallsymso=""
- kallsyms_vmlinux=""
- if [ -n "${CONFIG_KALLSYMS}" ]; then
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- kallsymso=.tmp_kallsyms2.o
- kallsyms_vmlinux=.tmp_vmlinux2
-
- vmlinux_link "" .tmp_vmlinux1
- kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
-
- vmlinux_link .tmp_kallsyms1.o .tmp_vmlinux2
- kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
-
- if [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
- kallsymso=.tmp_kallsyms3.o
- kallsyms_vmlinux=.tmp_vmlinux3
- vmlinux_link .tmp_kallsyms2.o .tmp_vmlinux3
- kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o
- fi
- fi
- if [ ! -z ${RTIC_MPGEN+x} ]; then
- rtic_mp "${kallsyms_vmlinux}" rtic_mp.o .tmp_rtic_mp_sz2 \
- .tmp_rtic_mp2.c
- if ! cmp -s .tmp_rtic_mp_sz1 .tmp_rtic_mp_sz2; then
- echo >&2 'ERROR: RTIC MP object files size mismatch'
- exit 1
- fi
- fi
- info LD vmlinux
- vmlinux_link "${kallsymso}" vmlinux
- if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then
- info SORTEX vmlinux
- sortextable vmlinux
- fi
- info SYSMAP System.map
- mksysmap vmlinux System.map
- if [ -n "${CONFIG_KALLSYMS}" ]; then
- mksysmap ${kallsyms_vmlinux} .tmp_System.map
- if ! cmp -s System.map .tmp_System.map; then
- echo >&2 Inconsistent kallsyms data
- echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
- exit 1
- fi
- fi
- rm -f .old_version
|