Skip to content

Commit 6c1c79a

Browse files
committed
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
2 parents 6210469 + 28f94a4 commit 6c1c79a

File tree

9 files changed

+48
-37
lines changed

9 files changed

+48
-37
lines changed

Documentation/kbuild/kconfig-language.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,11 @@ applicable everywhere (see syntax).
196196
or equal to the first symbol and smaller than or equal to the second
197197
symbol.
198198

199-
- help text: "help" or "---help---"
199+
- help text: "help"
200200

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

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

Documentation/kbuild/makefiles.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,19 @@ more details, with real examples.
297297
If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
298298
the corresponding obj- variable will be set, and kbuild will descend
299299
down in the ext2 directory.
300-
Kbuild only uses this information to decide that it needs to visit
301-
the directory, it is the Makefile in the subdirectory that
302-
specifies what is modular and what is built-in.
300+
301+
Kbuild uses this information not only to decide that it needs to visit
302+
the directory, but also to decide whether or not to link objects from
303+
the directory into vmlinux.
304+
305+
When Kbuild descends into the directory with 'y', all built-in objects
306+
from that directory are combined into the built-in.a, which will be
307+
eventually linked into vmlinux.
308+
309+
When Kbuild descends into the directory with 'm', in contrast, nothing
310+
from that directory will be linked into vmlinux. If the Makefile in
311+
that directory specifies obj-y, those objects will be left orphan.
312+
It is very likely a bug of the Makefile or of dependencies in Kconfig.
303313

304314
It is good practice to use a `CONFIG_` variable when assigning directory
305315
names. This allows kbuild to totally skip the directory if the

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ STRIP = $(CROSS_COMPILE)strip
414414
OBJCOPY = $(CROSS_COMPILE)objcopy
415415
OBJDUMP = $(CROSS_COMPILE)objdump
416416
OBJSIZE = $(CROSS_COMPILE)size
417+
READELF = $(CROSS_COMPILE)readelf
417418
PAHOLE = pahole
418419
LEX = flex
419420
YACC = bison
@@ -472,7 +473,7 @@ GCC_PLUGINS_CFLAGS :=
472473
CLANG_FLAGS :=
473474

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

arch/x86/boot/compressed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
103103
quiet_cmd_check_data_rel = DATAREL $@
104104
define cmd_check_data_rel
105105
for obj in $(filter %.o,$^); do \
106-
${CROSS_COMPILE}readelf -S $$obj | grep -qF .rel.local && { \
106+
$(READELF) -S $$obj | grep -qF .rel.local && { \
107107
echo "error: $$obj has data relocations!" >&2; \
108108
exit 1; \
109109
} || true; \

scripts/kallsyms.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ static void output_label(const char *label)
310310
printf("%s:\n", label);
311311
}
312312

313+
/* Provide proper symbols relocatability by their '_text' relativeness. */
314+
static void output_address(unsigned long long addr)
315+
{
316+
if (_text <= addr)
317+
printf("\tPTR\t_text + %#llx\n", addr - _text);
318+
else
319+
printf("\tPTR\t_text - %#llx\n", _text - addr);
320+
}
321+
313322
/* uncompress a compressed symbol. When this function is called, the best table
314323
* might still be compressed itself, so the function needs to be recursive */
315324
static int expand_symbol(const unsigned char *data, int len, char *result)
@@ -360,26 +369,20 @@ static void write_src(void)
360369

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

363-
/* Provide proper symbols relocatability by their relativeness
364-
* to a fixed anchor point in the runtime image, either '_text'
365-
* for absolute address tables, in which case the linker will
366-
* emit the final addresses at build time. Otherwise, use the
367-
* offset relative to the lowest value encountered of all relative
368-
* symbols, and emit non-relocatable fixed offsets that will be fixed
369-
* up at runtime.
370-
*
371-
* The symbol names cannot be used to construct normal symbol
372-
* references as the list of symbols contains symbols that are
373-
* declared static and are private to their .o files. This prevents
374-
* .tmp_kallsyms.o or any other object from referencing them.
375-
*/
376372
if (!base_relative)
377373
output_label("kallsyms_addresses");
378374
else
379375
output_label("kallsyms_offsets");
380376

381377
for (i = 0; i < table_cnt; i++) {
382378
if (base_relative) {
379+
/*
380+
* Use the offset relative to the lowest value
381+
* encountered of all relative symbols, and emit
382+
* non-relocatable fixed offsets that will be fixed
383+
* up at runtime.
384+
*/
385+
383386
long long offset;
384387
int overflow;
385388

@@ -402,12 +405,7 @@ static void write_src(void)
402405
}
403406
printf("\t.long\t%#x\n", (int)offset);
404407
} else if (!symbol_absolute(&table[i])) {
405-
if (_text <= table[i].addr)
406-
printf("\tPTR\t_text + %#llx\n",
407-
table[i].addr - _text);
408-
else
409-
printf("\tPTR\t_text - %#llx\n",
410-
_text - table[i].addr);
408+
output_address(table[i].addr);
411409
} else {
412410
printf("\tPTR\t%#llx\n", table[i].addr);
413411
}
@@ -416,7 +414,7 @@ static void write_src(void)
416414

417415
if (base_relative) {
418416
output_label("kallsyms_relative_base");
419-
printf("\tPTR\t_text - %#llx\n", _text - relative_base);
417+
output_address(relative_base);
420418
printf("\n");
421419
}
422420

scripts/kconfig/expr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ static int expr_eq(struct expr *e1, struct expr *e2)
254254
{
255255
int res, old_count;
256256

257+
/*
258+
* A NULL expr is taken to be yes, but there's also a different way to
259+
* represent yes. expr_is_yes() checks for either representation.
260+
*/
261+
if (!e1 || !e2)
262+
return expr_is_yes(e1) && expr_is_yes(e2);
263+
257264
if (e1->type != e2->type)
258265
return 0;
259266
switch (e1->type) {

scripts/mkcompile_h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ CONFIG_FLAGS=""
5555
if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
5656
if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
5757
if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi
58-
UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
5958

6059
# Truncate to maximum length
61-
6260
UTS_LEN=64
63-
UTS_TRUNCATE="cut -b -$UTS_LEN"
61+
UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
6462

6563
# Generate a temporary compile.h
6664

@@ -69,10 +67,10 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
6967

7068
echo \#define UTS_MACHINE \"$ARCH\"
7169

72-
echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
70+
echo \#define UTS_VERSION \"$UTS_VERSION\"
7371

74-
echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
75-
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
72+
printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
73+
echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
7674

7775
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
7876
} > .tmpcompile

scripts/package/mkdebian

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Source: $sourcename
174174
Section: kernel
175175
Priority: optional
176176
Maintainer: $maintainer
177-
Build-Depends: bc, kmod, cpio, bison, flex | flex:native $extra_build_depends
177+
Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends
178178
Homepage: http://www.kernel.org/
179179
180180
Package: $packagename

usr/include/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ endif
9191
# asm-generic/*.h is used by asm/*.h, and should not be included directly
9292
header-test- += asm-generic/%
9393

94-
extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h'))
94+
extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))
9595

9696
quiet_cmd_hdrtest = HDRTEST $<
9797
cmd_hdrtest = \

0 commit comments

Comments
 (0)