Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes:
  kbuild: fix kbuild.txt typos
  kbuild: print usage with no arguments in scripts/config
  Revert "kbuild: strip generated symbols from *.ko"
  • Loading branch information
Linus Torvalds committed Jan 26, 2009
2 parents 924d26d + df291fa commit 2034563
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 251 deletions.
29 changes: 15 additions & 14 deletions Documentation/kbuild/kbuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Environment variables
KCPPFLAGS
--------------------------------------------------
Additional options to pass when preprocessing. The preprocessing options
will be used in all cases where kbuild do preprocessing including
will be used in all cases where kbuild does preprocessing including
building C files and assembler files.

KAFLAGS
Expand All @@ -16,7 +16,7 @@ Additional options to the C compiler.

KBUILD_VERBOSE
--------------------------------------------------
Set the kbuild verbosity. Can be assinged same values as "V=...".
Set the kbuild verbosity. Can be assigned same values as "V=...".
See make help for the full list.
Setting "V=..." takes precedence over KBUILD_VERBOSE.

Expand All @@ -35,14 +35,14 @@ KBUILD_OUTPUT
--------------------------------------------------
Specify the output directory when building the kernel.
The output directory can also be specificed using "O=...".
Setting "O=..." takes precedence over KBUILD_OUTPUT
Setting "O=..." takes precedence over KBUILD_OUTPUT.

ARCH
--------------------------------------------------
Set ARCH to the architecture to be built.
In most cases the name of the architecture is the same as the
directory name found in the arch/ directory.
But some architectures suach as x86 and sparc has aliases.
But some architectures such as x86 and sparc have aliases.
x86: i386 for 32 bit, x86_64 for 64 bit
sparc: sparc for 32 bit, sparc64 for 64 bit

Expand All @@ -63,7 +63,7 @@ CF is often used on the command-line like this:
INSTALL_PATH
--------------------------------------------------
INSTALL_PATH specifies where to place the updated kernel and system map
images. Default is /boot, but you can set it to other values
images. Default is /boot, but you can set it to other values.


MODLIB
Expand All @@ -90,7 +90,7 @@ INSTALL_MOD_STRIP will used as the options to the strip command.

INSTALL_FW_PATH
--------------------------------------------------
INSTALL_FW_PATH specify where to install the firmware blobs.
INSTALL_FW_PATH specifies where to install the firmware blobs.
The default value is:

$(INSTALL_MOD_PATH)/lib/firmware
Expand All @@ -99,7 +99,7 @@ The value can be overridden in which case the default value is ignored.

INSTALL_HDR_PATH
--------------------------------------------------
INSTALL_HDR_PATH specify where to install user space headers when
INSTALL_HDR_PATH specifies where to install user space headers when
executing "make headers_*".
The default value is:

Expand All @@ -112,22 +112,23 @@ The value can be overridden in which case the default value is ignored.

KBUILD_MODPOST_WARN
--------------------------------------------------
KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
symbols in the final module linking stage.
KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
symbols in the final module linking stage. It changes such errors
into warnings.

KBUILD_MODPOST_FINAL
KBUILD_MODPOST_NOFINAL
--------------------------------------------------
KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
This is solely usefull to speed up test compiles.
This is solely useful to speed up test compiles.

KBUILD_EXTRA_SYMBOLS
--------------------------------------------------
For modules use symbols from another modules.
For modules that use symbols from other modules.
See more details in modules.txt.

ALLSOURCE_ARCHS
--------------------------------------------------
For tags/TAGS/cscope targets, you can specify more than one archs
to be included in the databases, separated by blankspace. e.g.
For tags/TAGS/cscope targets, you can specify more than one arch
to be included in the databases, separated by blank space. E.g.:

$ make ALLSOURCE_ARCHS="x86 mips arm" tags
59 changes: 18 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -610,25 +610,20 @@ export INSTALL_PATH ?= /boot
MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
export MODLIB

strip-symbols := $(srctree)/scripts/strip-symbols \
$(wildcard $(srctree)/arch/$(ARCH)/scripts/strip-symbols)

#
# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped while
# they get installed. If INSTALL_MOD_STRIP is '1', then the default
# options (see below) will be used. Otherwise, INSTALL_MOD_STRIP will
# be used as the option(s) to the objcopy command.
# INSTALL_MOD_STRIP, if defined, will cause modules to be
# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
# the default option --strip-debug will be used. Otherwise,
# INSTALL_MOD_STRIP will used as the options to the strip command.

ifdef INSTALL_MOD_STRIP
ifeq ($(INSTALL_MOD_STRIP),1)
mod_strip_cmd = $(OBJCOPY) --strip-debug
ifeq ($(CONFIG_KALLSYMS_ALL),$(CONFIG_KALLSYMS_STRIP_GENERATED))
mod_strip_cmd += --wildcard $(addprefix --strip-symbols ,$(strip-symbols))
endif
mod_strip_cmd = $(STRIP) --strip-debug
else
mod_strip_cmd = $(OBJCOPY) $(INSTALL_MOD_STRIP)
mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
endif # INSTALL_MOD_STRIP=1
else
mod_strip_cmd = false
mod_strip_cmd = true
endif # INSTALL_MOD_STRIP
export mod_strip_cmd

Expand Down Expand Up @@ -758,7 +753,6 @@ last_kallsyms := 2
endif

kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
kallsyms.h := $(wildcard include/config/kallsyms/*.h) $(wildcard include/config/kallsyms/*/*.h)

define verify_kallsyms
$(Q)$(if $($(quiet)cmd_sysmap), \
Expand All @@ -783,41 +777,24 @@ endef

# Generate .S file with all kernel symbols
quiet_cmd_kallsyms = KSYM $@
cmd_kallsyms = { test $* -eq 0 || $(NM) -n $<; } \
| $(KALLSYMS) $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) >$@

quiet_cmd_kstrip = STRIP $@
cmd_kstrip = $(OBJCOPY) --wildcard $(addprefix --strip$(if $(CONFIG_RELOCATABLE),-unneeded)-symbols ,$(filter %/scripts/strip-symbols,$^)) $< $@
cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
$(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@

$(foreach n,0 1 2 3,.tmp_kallsyms$(n).o): KBUILD_AFLAGS += -Wa,--strip-local-absolute
$(foreach n,0 1 2 3,.tmp_kallsyms$(n).o): %.o: %.S scripts FORCE
.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
$(call if_changed_dep,as_o_S)

ifeq ($(CONFIG_KALLSYMS_STRIP_GENERATED),y)
strip-ext := .stripped
endif

.tmp_kallsyms%.S: .tmp_vmlinux%$(strip-ext) $(KALLSYMS) $(kallsyms.h)
.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS)
$(call cmd,kallsyms)

# make -jN seems to have problems with intermediate files, see bug #3330.
.SECONDARY: $(foreach n,1 2 3,.tmp_vmlinux$(n).stripped)
.tmp_vmlinux%.stripped: .tmp_vmlinux% $(strip-symbols) $(kallsyms.h)
$(call cmd,kstrip)

ifneq ($(CONFIG_DEBUG_INFO),y)
.tmp_vmlinux%: LDFLAGS_vmlinux += -S
endif
# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version
.tmp_vmlinux%: $(vmlinux-lds) $(vmlinux-all) FORCE
$(if $(filter 1,$*),$(call if_changed_rule,ksym_ld),$(call if_changed,vmlinux__))
.tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE
$(call if_changed_rule,ksym_ld)

.tmp_vmlinux0$(strip-ext):
$(Q)echo "placeholder" >$@
.tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE
$(call if_changed,vmlinux__)

.tmp_vmlinux1: .tmp_kallsyms0.o
.tmp_vmlinux2: .tmp_kallsyms1.o
.tmp_vmlinux3: .tmp_kallsyms2.o
.tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE
$(call if_changed,vmlinux__)

# Needs to visit scripts/ before $(KALLSYMS) can be used.
$(KALLSYMS): scripts ;
Expand Down
1 change: 0 additions & 1 deletion arch/x86/scripts/strip-symbols

This file was deleted.

7 changes: 0 additions & 7 deletions init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -725,13 +725,6 @@ config KALLSYMS_ALL

Say N.

config KALLSYMS_STRIP_GENERATED
bool "Strip machine generated symbols from kallsyms"
depends on KALLSYMS_ALL
default y
help
Say N if you want kallsyms to retain even machine generated symbols.

config KALLSYMS_EXTRA_PASS
bool "Do an extra kallsyms pass"
depends on KALLSYMS
Expand Down
16 changes: 10 additions & 6 deletions kernel/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@
#define all_var 0
#endif

extern const unsigned long kallsyms_addresses[];
extern const u8 kallsyms_names[];
/* These will be re-linked against their real values during the second link stage */
extern const unsigned long kallsyms_addresses[] __attribute__((weak));
extern const u8 kallsyms_names[] __attribute__((weak));

/* tell the compiler that the count isn't in the small data section if the arch
* has one (eg: FRV)
*/
extern const unsigned long kallsyms_num_syms
__attribute__((__section__(".rodata")));
__attribute__((weak, section(".rodata")));

extern const u8 kallsyms_token_table[];
extern const u16 kallsyms_token_index[];
extern const u8 kallsyms_token_table[] __attribute__((weak));
extern const u16 kallsyms_token_index[] __attribute__((weak));

extern const unsigned long kallsyms_markers[];
extern const unsigned long kallsyms_markers[] __attribute__((weak));

static inline int is_kernel_inittext(unsigned long addr)
{
Expand Down Expand Up @@ -167,6 +168,9 @@ static unsigned long get_symbol_pos(unsigned long addr,
unsigned long symbol_start = 0, symbol_end = 0;
unsigned long i, low, high, mid;

/* This kernel should never had been booted. */
BUG_ON(!kallsyms_addresses);

/* do a binary search on the sorted kallsyms_addresses array */
low = 0;
high = kallsyms_num_syms;
Expand Down
55 changes: 20 additions & 35 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
$(obj)/%.i: $(src)/%.c FORCE
$(call if_changed_dep,cc_i_c)

cmd_genksyms = \
cmd_gensymtypes = \
$(CPP) -D__GENKSYMS__ $(c_flags) $< | \
$(GENKSYMS) -T $@ -A -a $(ARCH) \
$(GENKSYMS) -T $@ -a $(ARCH) \
$(if $(KBUILD_PRESERVE),-p) \
$(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null)))

quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
cmd_cc_symtypes_c = \
set -e; \
$(call cmd_genksyms, true) >/dev/null; \
$(call cmd_gensymtypes, true) >/dev/null; \
test -s $@ || rm -f $@

$(obj)/%.symtypes : $(src)/%.c FORCE
Expand All @@ -177,38 +177,28 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<

else
# When module versioning is enabled the following steps are executed:
# o compile a .tmp_<file>.s from <file>.c
# o if .tmp_<file>.s doesn't contain a __ksymtab version, i.e. does
# not export symbols, we just assemble .tmp_<file>.s to <file>.o and
# o compile a .tmp_<file>.o from <file>.c
# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
# not export symbols, we just rename .tmp_<file>.o to <file>.o and
# are done.
# o otherwise, we calculate symbol versions using the good old
# genksyms on the preprocessed source and postprocess them in a way
# that they are usable as assembly source
# o assemble <file>.o from .tmp_<file>.s forcing inclusion of directives
# defining the actual values of __crc_*, followed by objcopy-ing them
# to force these symbols to be local to permit stripping them later.
s_file = $(@D)/.tmp_$(@F:.o=.s)
v_file = $(@D)/.tmp_$(@F:.o=.v)
tmp_o_file = $(@D)/.tmp_$(@F)
no_g_c_flags = $(filter-out -g%,$(c_flags))

cmd_cc_o_c = $(CC) $(c_flags) -S -o $(s_file) $<
# that they are usable as a linker script
# o generate <file>.o from .tmp_<file>.o using the linker to
# replace the unresolved symbols __crc_exported_symbol with
# the actual value of the checksum generated by genksyms

cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
cmd_modversions = \
if grep -q __ksymtab $(s_file); then \
if $(call cmd_genksyms, $(KBUILD_SYMTYPES)) > $(v_file) \
&& $(CC) $(no_g_c_flags) -c -Wa,$(v_file) \
-o $(tmp_o_file) $(s_file) \
&& $(OBJCOPY) -L '__crc_*' -L '___crc_*' -w \
$(tmp_o_file) $@; \
then \
: ; \
else \
rm -f $@; exit 1; \
fi; \
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
$(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \
> $(@D)/.tmp_$(@F:.o=.ver); \
\
$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
-T $(@D)/.tmp_$(@F:.o=.ver); \
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
else \
rm -f $(v_file); \
$(CC) $(no_g_c_flags) -c -o $@ $(s_file); \
mv -f $(@D)/.tmp_$(@F) $@; \
fi;
endif

Expand All @@ -225,12 +215,7 @@ define rule_cc_o_c
$(cmd_record_mcount) \
scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
$(dot-target).tmp; \
if [ -r $(@D)/.tmp_$(@F:.o=.v) ]; then \
echo >> $(dot-target).tmp; \
echo '$@: $(GENKSYMS)' >> $(dot-target).tmp; \
echo '$(GENKSYMS):: ;' >> $(dot-target).tmp; \
fi; \
rm -f $(depfile) $(@D)/.tmp_$(@F:.o=.?); \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
endef

Expand Down
3 changes: 1 addition & 2 deletions scripts/Makefile.modinst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ __modinst: $(modules)
@:

quiet_cmd_modules_install = INSTALL $@
cmd_modules_install = mkdir -p $(2); \
$(mod_strip_cmd) $@ $(2)/$(notdir $@) || cp $@ $(2)
cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@)

# Modules built outside the kernel source tree go into extra by default
INSTALL_MOD_DIR ?= extra
Expand Down
4 changes: 4 additions & 0 deletions scripts/config
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ else
FN=.config
fi

if [ "$1" = "" ] ; then
usage
fi

while [ "$1" != "" ] ; do
CMD="$1"
shift
Expand Down
Loading

0 comments on commit 2034563

Please sign in to comment.