Skip to content
This repository was archived by the owner on Jul 18, 2019. It is now read-only.

Commit c9e2a72

Browse files
committed
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: initramfs: Fix build break on symbol-prefixed archs initramfs: fix initramfs size calculation initramfs: generalize initramfs_data.xxx.S variants scripts/kallsyms: Enable error messages while hush up unnecessary warnings scripts/setlocalversion: update comment kbuild: Use a single clean rule for kernel and external modules kbuild: Do not run make clean in $(srctree) scripts/mod/modpost.c: fix commentary accordingly to last changes kbuild: Really don't clean bounds.h and asm-offsets.h
2 parents 9aca0e7 + d63f6d1 commit c9e2a72

16 files changed

+61
-163
lines changed

Documentation/kbuild/makefiles.txt

+7
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,13 @@ This will delete the directory debian, including all subdirectories.
776776
Kbuild will assume the directories to be in the same relative path as the
777777
Makefile if no absolute path is specified (path does not start with '/').
778778

779+
To exclude certain files from make clean, use the $(no-clean-files) variable.
780+
This is only a special case used in the top level Kbuild file:
781+
782+
Example:
783+
#Kbuild
784+
no-clean-files := $(bounds-file) $(offsets-file)
785+
779786
Usually kbuild descends down in subdirectories due to "obj-* := dir/",
780787
but in the architecture makefiles where the kbuild infrastructure
781788
is not sufficient this sometimes needs to be explicit.

Kbuild

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ PHONY += missing-syscalls
9595
missing-syscalls: scripts/checksyscalls.sh FORCE
9696
$(call cmd,syscalls)
9797

98-
# Delete all targets during make clean
99-
clean-files := $(addprefix $(objtree)/,$(filter-out $(bounds-file) $(offsets-file),$(targets)))
98+
# Keep these two files during make clean
99+
no-clean-files := $(bounds-file) $(offsets-file)

Makefile

+13-20
Original file line numberDiff line numberDiff line change
@@ -1137,21 +1137,13 @@ MRPROPER_FILES += .config .config.old .version .old_version \
11371137
#
11381138
clean: rm-dirs := $(CLEAN_DIRS)
11391139
clean: rm-files := $(CLEAN_FILES)
1140-
clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation)
1140+
clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
11411141

11421142
PHONY += $(clean-dirs) clean archclean
11431143
$(clean-dirs):
11441144
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
11451145

1146-
clean: archclean $(clean-dirs)
1147-
$(call cmd,rmdirs)
1148-
$(call cmd,rmfiles)
1149-
@find . $(RCS_FIND_IGNORE) \
1150-
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1151-
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1152-
-o -name '*.symtypes' -o -name 'modules.order' \
1153-
-o -name modules.builtin -o -name '.tmp_*.o.*' \
1154-
-o -name '*.gcno' \) -type f -print | xargs rm -f
1146+
clean: archclean
11551147

11561148
# mrproper - Delete all generated files, including .config
11571149
#
@@ -1352,16 +1344,7 @@ $(clean-dirs):
13521344
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
13531345

13541346
clean: rm-dirs := $(MODVERDIR)
1355-
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \
1356-
$(KBUILD_EXTMOD)/modules.order \
1357-
$(KBUILD_EXTMOD)/modules.builtin
1358-
clean: $(clean-dirs)
1359-
$(call cmd,rmdirs)
1360-
$(call cmd,rmfiles)
1361-
@find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
1362-
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1363-
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1364-
-o -name '*.gcno' \) -type f -print | xargs rm -f
1347+
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
13651348

13661349
help:
13671350
@echo ' Building external modules.'
@@ -1378,6 +1361,16 @@ prepare: ;
13781361
scripts: ;
13791362
endif # KBUILD_EXTMOD
13801363

1364+
clean: $(clean-dirs)
1365+
$(call cmd,rmdirs)
1366+
$(call cmd,rmfiles)
1367+
@find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
1368+
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1369+
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1370+
-o -name '*.symtypes' -o -name 'modules.order' \
1371+
-o -name modules.builtin -o -name '.tmp_*.o.*' \
1372+
-o -name '*.gcno' \) -type f -print | xargs rm -f
1373+
13811374
# Generate tags for editors
13821375
# ---------------------------------------------------------------------------
13831376
quiet_cmd_tags = GEN $@

include/asm-generic/vmlinux.lds.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@
640640
. = ALIGN(4); \
641641
VMLINUX_SYMBOL(__initramfs_start) = .; \
642642
*(.init.ramfs) \
643-
VMLINUX_SYMBOL(__initramfs_end) = .;
643+
. = ALIGN(8); \
644+
*(.init.ramfs.info)
644645
#else
645646
#define INIT_RAM_FS
646647
#endif

init/initramfs.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ static int __init retain_initrd_param(char *str)
483483
}
484484
__setup("retain_initrd", retain_initrd_param);
485485

486-
extern char __initramfs_start[], __initramfs_end[];
486+
extern char __initramfs_start[];
487+
extern unsigned long __initramfs_size;
487488
#include <linux/initrd.h>
488489
#include <linux/kexec.h>
489490

@@ -570,8 +571,7 @@ static void __init clean_rootfs(void)
570571

571572
static int __init populate_rootfs(void)
572573
{
573-
char *err = unpack_to_rootfs(__initramfs_start,
574-
__initramfs_end - __initramfs_start);
574+
char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
575575
if (err)
576576
panic(err); /* Failed to decompress INTERNAL initramfs */
577577
if (initrd_start) {
@@ -585,8 +585,7 @@ static int __init populate_rootfs(void)
585585
return 0;
586586
} else {
587587
clean_rootfs();
588-
unpack_to_rootfs(__initramfs_start,
589-
__initramfs_end - __initramfs_start);
588+
unpack_to_rootfs(__initramfs_start, __initramfs_size);
590589
}
591590
printk(KERN_INFO "rootfs image is not initramfs (%s)"
592591
"; looks like an initrd\n", err);

scripts/Makefile.clean

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ __clean-files := $(extra-y) $(always) \
4545
$(host-progs) \
4646
$(hostprogs-y) $(hostprogs-m) $(hostprogs-)
4747

48+
__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
49+
4850
# as clean-files is given relative to the current directory, this adds
4951
# a $(obj) prefix, except for absolute paths
5052

scripts/Makefile.lib

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ _c_flags += $(if $(patsubst n%,, \
120120
endif
121121

122122
ifdef CONFIG_SYMBOL_PREFIX
123-
_cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
123+
_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
124+
_cpp_flags += $(_sym_flags)
125+
_a_flags += $(_sym_flags)
124126
endif
125127

126128

scripts/kallsyms.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,8 @@ static int read_symbol(FILE *in, struct sym_entry *s)
107107

108108
rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
109109
if (rc != 3) {
110-
if (rc != EOF) {
111-
/* skip line. sym is used as dummy to
112-
* shut of "warn_unused_result" warning.
113-
*/
114-
sym = fgets(str, 500, in);
115-
}
110+
if (rc != EOF && fgets(str, 500, in) == NULL)
111+
fprintf(stderr, "Read error or end of file.\n");
116112
return -1;
117113
}
118114

scripts/mod/modpost.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
12081208
* .cpuinit.data => __cpudata
12091209
* .memexitconst => __memconst
12101210
* etc.
1211+
*
1212+
* The memory of returned value has been allocated on a heap. The user of this
1213+
* method should free it after usage.
12111214
*/
12121215
static char *sec2annotation(const char *s)
12131216
{
@@ -1230,7 +1233,7 @@ static char *sec2annotation(const char *s)
12301233
strcat(p, "data ");
12311234
else
12321235
strcat(p, " ");
1233-
return r; /* we leak her but we do not care */
1236+
return r;
12341237
} else {
12351238
return strdup("");
12361239
}

scripts/setlocalversion

+4-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
160160
# full scm version string
161161
res="$res$(scm_version)"
162162
else
163-
# apped a plus sign if the repository is not in a clean tagged
164-
# state and LOCALVERSION= is not specified
163+
# append a plus sign if the repository is not in a clean
164+
# annotated or signed tagged state (as git describe only
165+
# looks at signed or annotated tags - git tag -a/-s) and
166+
# LOCALVERSION= is not specified
165167
if test "${LOCALVERSION+set}" != "set"; then
166168
scm=$(scm_version --short)
167169
res="$res${scm:++}"

usr/Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
1818
# Lzo
1919
suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo
2020

21+
AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
22+
2123
# Generate builtin.o based on initramfs_data.o
22-
obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o
24+
obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
2325

2426
# initramfs_data.o contains the compressed initramfs_data.cpio image.
2527
# The image is included using .incbin, a dependency which is not
2628
# tracked automatically.
27-
$(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
29+
$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
2830

2931
#####
3032
# Generate the initramfs cpio archive

usr/initramfs_data.S

+14-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
-T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o
1212
ld -m elf_i386 -r -o built-in.o initramfs_data.o
1313
14-
initramfs_data.scr looks like this:
15-
SECTIONS
16-
{
17-
.init.ramfs : { *(.data) }
18-
}
14+
For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds.
1915
2016
The above example is for i386 - the parameters vary from architectures.
2117
Eventually look up LDFLAGS_BLOB in an older version of the
@@ -25,6 +21,17 @@ SECTIONS
2521
in the ELF header, as required by certain architectures.
2622
*/
2723

28-
.section .init.ramfs,"a"
29-
.incbin "usr/initramfs_data.cpio"
24+
#include <linux/stringify.h>
3025

26+
.section .init.ramfs,"a"
27+
__irf_start:
28+
.incbin __stringify(INITRAMFS_IMAGE)
29+
__irf_end:
30+
.section .init.ramfs.info,"a"
31+
.globl __initramfs_size
32+
__initramfs_size:
33+
#ifdef CONFIG_32BIT
34+
.long __irf_end - __irf_start
35+
#else
36+
.quad __irf_end - __irf_start
37+
#endif

usr/initramfs_data.bz2.S

-29
This file was deleted.

usr/initramfs_data.gz.S

-29
This file was deleted.

usr/initramfs_data.lzma.S

-29
This file was deleted.

usr/initramfs_data.lzo.S

-29
This file was deleted.

0 commit comments

Comments
 (0)