Commit 6c1c79a5 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'kbuild-fixes-v5.5' of...

Merge tag 'kbuild-fixes-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - fix warning in out-of-tree 'make clean'

 - add READELF variable to the top Makefile

 - fix broken builds when LINUX_COMPILE_BY contains a backslash

 - fix build warning in kallsyms

 - fix NULL pointer access in expr_eq() in Kconfig

 - fix missing dependency on rsync in deb-pkg build

 - remove ---help--- from documentation

 - fix misleading documentation about directory descending

* tag 'kbuild-fixes-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: clarify the difference between obj-y and obj-m w.r.t. descending
  kconfig: remove ---help--- from documentation
  scripts: package: mkdebian: add missing rsync dependency
  kconfig: don't crash on NULL expressions in expr_eq()
  scripts/kallsyms: fix offset overflow of kallsyms_relative_base
  mkcompile_h: use printf for LINUX_COMPILE_BY
  mkcompile_h: git rid of UTS_TRUNCATE from LINUX_COMPILE_{BY,HOST}
  x86/boot: kbuild: allow readelf executable to be specified
  kbuild: fix 'No such file or directory' warning when cleaning
parents 62104694 28f94a44
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -196,14 +196,11 @@ applicable everywhere (see syntax).
  or equal to the first symbol and smaller than or equal to the second
  symbol.

- help text: "help" or "---help---"
- help text: "help"

  This defines a help text. The end of the help text is determined by
  the indentation level, this means it ends at the first line which has
  a smaller indentation than the first line of the help text.
  "---help---" and "help" do not differ in behaviour, "---help---" is
  used to help visually separate configuration logic from help within
  the file as an aid to developers.

- misc options: "option" <symbol>[=<value>]

+13 −3
Original line number Diff line number Diff line
@@ -297,9 +297,19 @@ more details, with real examples.
	If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
	the corresponding obj- variable will be set, and kbuild will descend
	down in the ext2 directory.
	Kbuild only uses this information to decide that it needs to visit
	the directory, it is the Makefile in the subdirectory that
	specifies what is modular and what is built-in.

	Kbuild uses this information not only to decide that it needs to visit
	the directory, but also to decide whether or not to link objects from
	the directory into vmlinux.

	When Kbuild descends into the directory with 'y', all built-in objects
	from that directory are combined into the built-in.a, which will be
	eventually linked into vmlinux.

	When Kbuild descends into the directory with 'm', in contrast, nothing
	from that directory will be linked into vmlinux. If the Makefile in
	that directory specifies obj-y, those objects will be left orphan.
	It is very likely a bug of the Makefile or of dependencies in Kconfig.

	It is good practice to use a `CONFIG_` variable when assigning directory
	names. This allows kbuild to totally skip the directory if the
+2 −1
Original line number Diff line number Diff line
@@ -414,6 +414,7 @@ STRIP = $(CROSS_COMPILE)strip
OBJCOPY		= $(CROSS_COMPILE)objcopy
OBJDUMP		= $(CROSS_COMPILE)objdump
OBJSIZE		= $(CROSS_COMPILE)size
READELF		= $(CROSS_COMPILE)readelf
PAHOLE		= pahole
LEX		= flex
YACC		= bison
@@ -472,7 +473,7 @@ GCC_PLUGINS_CFLAGS :=
CLANG_FLAGS :=

export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE

+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
quiet_cmd_check_data_rel = DATAREL $@
define cmd_check_data_rel
	for obj in $(filter %.o,$^); do \
		${CROSS_COMPILE}readelf -S $$obj | grep -qF .rel.local && { \
		$(READELF) -S $$obj | grep -qF .rel.local && { \
			echo "error: $$obj has data relocations!" >&2; \
			exit 1; \
		} || true; \
+18 −20
Original line number Diff line number Diff line
@@ -310,6 +310,15 @@ static void output_label(const char *label)
	printf("%s:\n", label);
}

/* Provide proper symbols relocatability by their '_text' relativeness. */
static void output_address(unsigned long long addr)
{
	if (_text <= addr)
		printf("\tPTR\t_text + %#llx\n", addr - _text);
	else
		printf("\tPTR\t_text - %#llx\n", _text - addr);
}

/* uncompress a compressed symbol. When this function is called, the best table
 * might still be compressed itself, so the function needs to be recursive */
static int expand_symbol(const unsigned char *data, int len, char *result)
@@ -360,19 +369,6 @@ static void write_src(void)

	printf("\t.section .rodata, \"a\"\n");

	/* Provide proper symbols relocatability by their relativeness
	 * to a fixed anchor point in the runtime image, either '_text'
	 * for absolute address tables, in which case the linker will
	 * emit the final addresses at build time. Otherwise, use the
	 * offset relative to the lowest value encountered of all relative
	 * symbols, and emit non-relocatable fixed offsets that will be fixed
	 * up at runtime.
	 *
	 * The symbol names cannot be used to construct normal symbol
	 * references as the list of symbols contains symbols that are
	 * declared static and are private to their .o files.  This prevents
	 * .tmp_kallsyms.o or any other object from referencing them.
	 */
	if (!base_relative)
		output_label("kallsyms_addresses");
	else
@@ -380,6 +376,13 @@ static void write_src(void)

	for (i = 0; i < table_cnt; i++) {
		if (base_relative) {
			/*
			 * Use the offset relative to the lowest value
			 * encountered of all relative symbols, and emit
			 * non-relocatable fixed offsets that will be fixed
			 * up at runtime.
			 */

			long long offset;
			int overflow;

@@ -402,12 +405,7 @@ static void write_src(void)
			}
			printf("\t.long\t%#x\n", (int)offset);
		} else if (!symbol_absolute(&table[i])) {
			if (_text <= table[i].addr)
				printf("\tPTR\t_text + %#llx\n",
					table[i].addr - _text);
			else
				printf("\tPTR\t_text - %#llx\n",
					_text - table[i].addr);
			output_address(table[i].addr);
		} else {
			printf("\tPTR\t%#llx\n", table[i].addr);
		}
@@ -416,7 +414,7 @@ static void write_src(void)

	if (base_relative) {
		output_label("kallsyms_relative_base");
		printf("\tPTR\t_text - %#llx\n", _text - relative_base);
		output_address(relative_base);
		printf("\n");
	}

Loading