diff options
Diffstat (limited to 'scripts/link-vmlinux.sh')
| -rwxr-xr-x | scripts/link-vmlinux.sh | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index c8cf45362bd6..bc7f1fc1f55b 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh | |||
| @@ -3,22 +3,17 @@ | |||
| 3 | # | 3 | # |
| 4 | # link vmlinux | 4 | # link vmlinux |
| 5 | # | 5 | # |
| 6 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and | 6 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and |
| 7 | # $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files | 7 | # $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories |
| 8 | # from top-level directories in the kernel tree, others are specified in | 8 | # in the kernel tree, others are specified in arch/$(ARCH)/Makefile. |
| 9 | # arch/$(ARCH)/Makefile. Ordering when linking is important, and | 9 | # $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally |
| 10 | # $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives | 10 | # (not within --whole-archive), and do not require symbol indexes added. |
| 11 | # which are linked conditionally (not within --whole-archive), and do not | ||
| 12 | # require symbol indexes added. | ||
| 13 | # | 11 | # |
| 14 | # vmlinux | 12 | # vmlinux |
| 15 | # ^ | 13 | # ^ |
| 16 | # | | 14 | # | |
| 17 | # +-< $(KBUILD_VMLINUX_INIT) | 15 | # +--< $(KBUILD_VMLINUX_OBJS) |
| 18 | # | +--< init/version.o + more | 16 | # | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more |
| 19 | # | | ||
| 20 | # +--< $(KBUILD_VMLINUX_MAIN) | ||
| 21 | # | +--< drivers/built-in.a mm/built-in.a + more | ||
| 22 | # | | 17 | # | |
| 23 | # +--< $(KBUILD_VMLINUX_LIBS) | 18 | # +--< $(KBUILD_VMLINUX_LIBS) |
| 24 | # | +--< lib/lib.a + more | 19 | # | +--< lib/lib.a + more |
| @@ -44,24 +39,6 @@ info() | |||
| 44 | fi | 39 | fi |
| 45 | } | 40 | } |
| 46 | 41 | ||
| 47 | # Thin archive build here makes a final archive with symbol table and indexes | ||
| 48 | # from vmlinux objects INIT and MAIN, which can be used as input to linker. | ||
| 49 | # KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes | ||
| 50 | # added. | ||
| 51 | # | ||
| 52 | # Traditional incremental style of link does not require this step | ||
| 53 | # | ||
| 54 | # built-in.a output file | ||
| 55 | # | ||
| 56 | archive_builtin() | ||
| 57 | { | ||
| 58 | info AR built-in.a | ||
| 59 | rm -f built-in.a; | ||
| 60 | ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \ | ||
| 61 | ${KBUILD_VMLINUX_INIT} \ | ||
| 62 | ${KBUILD_VMLINUX_MAIN} | ||
| 63 | } | ||
| 64 | |||
| 65 | # Link of vmlinux.o used for section mismatch analysis | 42 | # Link of vmlinux.o used for section mismatch analysis |
| 66 | # ${1} output file | 43 | # ${1} output file |
| 67 | modpost_link() | 44 | modpost_link() |
| @@ -69,7 +46,7 @@ modpost_link() | |||
| 69 | local objects | 46 | local objects |
| 70 | 47 | ||
| 71 | objects="--whole-archive \ | 48 | objects="--whole-archive \ |
| 72 | built-in.a \ | 49 | ${KBUILD_VMLINUX_OBJS} \ |
| 73 | --no-whole-archive \ | 50 | --no-whole-archive \ |
| 74 | --start-group \ | 51 | --start-group \ |
| 75 | ${KBUILD_VMLINUX_LIBS} \ | 52 | ${KBUILD_VMLINUX_LIBS} \ |
| @@ -88,7 +65,7 @@ vmlinux_link() | |||
| 88 | 65 | ||
| 89 | if [ "${SRCARCH}" != "um" ]; then | 66 | if [ "${SRCARCH}" != "um" ]; then |
| 90 | objects="--whole-archive \ | 67 | objects="--whole-archive \ |
| 91 | built-in.a \ | 68 | ${KBUILD_VMLINUX_OBJS} \ |
| 92 | --no-whole-archive \ | 69 | --no-whole-archive \ |
| 93 | --start-group \ | 70 | --start-group \ |
| 94 | ${KBUILD_VMLINUX_LIBS} \ | 71 | ${KBUILD_VMLINUX_LIBS} \ |
| @@ -99,7 +76,7 @@ vmlinux_link() | |||
| 99 | -T ${lds} ${objects} | 76 | -T ${lds} ${objects} |
| 100 | else | 77 | else |
| 101 | objects="-Wl,--whole-archive \ | 78 | objects="-Wl,--whole-archive \ |
| 102 | built-in.a \ | 79 | ${KBUILD_VMLINUX_OBJS} \ |
| 103 | -Wl,--no-whole-archive \ | 80 | -Wl,--no-whole-archive \ |
| 104 | -Wl,--start-group \ | 81 | -Wl,--start-group \ |
| 105 | ${KBUILD_VMLINUX_LIBS} \ | 82 | ${KBUILD_VMLINUX_LIBS} \ |
| @@ -160,7 +137,6 @@ cleanup() | |||
| 160 | rm -f .tmp_System.map | 137 | rm -f .tmp_System.map |
| 161 | rm -f .tmp_kallsyms* | 138 | rm -f .tmp_kallsyms* |
| 162 | rm -f .tmp_vmlinux* | 139 | rm -f .tmp_vmlinux* |
| 163 | rm -f built-in.a | ||
| 164 | rm -f System.map | 140 | rm -f System.map |
| 165 | rm -f vmlinux | 141 | rm -f vmlinux |
| 166 | rm -f vmlinux.o | 142 | rm -f vmlinux.o |
| @@ -217,8 +193,6 @@ fi; | |||
| 217 | # final build of init/ | 193 | # final build of init/ |
| 218 | ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init | 194 | ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init |
| 219 | 195 | ||
| 220 | archive_builtin | ||
| 221 | |||
| 222 | #link vmlinux.o | 196 | #link vmlinux.o |
| 223 | info LD vmlinux.o | 197 | info LD vmlinux.o |
| 224 | modpost_link vmlinux.o | 198 | modpost_link vmlinux.o |
