kernel/configs: use .incbin directive to embed config_data.gz
This slightly optimizes the kernel/configs.c build. bin2c is not very efficient because it converts a data file into a huge array to embed it into a *.c file. Instead, we can use the .incbin directive. Also, this simplifies the code; Makefile is cleaner, and the way to get the offset/size of the config_data.gz is more straightforward. I used the "asm" statement in *.c instead of splitting it into *.S because MODULE_* tags are not supported in *.S files. I also cleaned up kernel/.gitignore; "config_data.gz" is unneeded because the top-level .gitignore takes care of the "*.gz" pattern. [yamada.masahiro@socionext.com: v2] Link: http://lkml.kernel.org/r/1550108893-21226-1-git-send-email-yamada.masahiro@socionext.com Link: http://lkml.kernel.org/r/1549941160-8084-1-git-send-email-yamada.masahiro@socionext.com Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Alexander Popov <alex.popov@linux.com> Cc: Kees Cook <keescook@chromium.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3337d5cfe5
commit
13610aa908
|
@ -106,7 +106,6 @@ compile.h*
|
||||||
conf
|
conf
|
||||||
config
|
config
|
||||||
config-*
|
config-*
|
||||||
config_data.h*
|
|
||||||
config.mak
|
config.mak
|
||||||
config.mak.autogen
|
config.mak.autogen
|
||||||
conmakehash
|
conmakehash
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#
|
#
|
||||||
# Generated files
|
# Generated files
|
||||||
#
|
#
|
||||||
config_data.h
|
|
||||||
config_data.gz
|
|
||||||
timeconst.h
|
timeconst.h
|
||||||
hz.bc
|
hz.bc
|
||||||
|
|
|
@ -116,17 +116,8 @@ obj-$(CONFIG_GCC_PLUGIN_STACKLEAK) += stackleak.o
|
||||||
KASAN_SANITIZE_stackleak.o := n
|
KASAN_SANITIZE_stackleak.o := n
|
||||||
KCOV_INSTRUMENT_stackleak.o := n
|
KCOV_INSTRUMENT_stackleak.o := n
|
||||||
|
|
||||||
$(obj)/configs.o: $(obj)/config_data.h
|
$(obj)/configs.o: $(obj)/config_data.gz
|
||||||
|
|
||||||
targets += config_data.gz
|
targets += config_data.gz
|
||||||
$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
|
$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
|
||||||
$(call if_changed,gzip)
|
$(call if_changed,gzip)
|
||||||
|
|
||||||
filechk_ikconfiggz = \
|
|
||||||
echo "static const char kernel_config_data[] __used = MAGIC_START"; \
|
|
||||||
cat $< | scripts/bin2c; \
|
|
||||||
echo "MAGIC_END;"
|
|
||||||
|
|
||||||
targets += config_data.h
|
|
||||||
$(obj)/config_data.h: $(obj)/config_data.gz FORCE
|
|
||||||
$(call filechk,ikconfiggz)
|
|
||||||
|
|
|
@ -30,37 +30,35 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
/**************************************************/
|
|
||||||
/* the actual current config file */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define kernel_config_data and kernel_config_data_size, which contains the
|
* "IKCFG_ST" and "IKCFG_ED" are used to extract the config data from
|
||||||
* wrapped and compressed configuration file. The file is first compressed
|
* a binary kernel image or a module. See scripts/extract-ikconfig.
|
||||||
* with gzip and then bounded by two eight byte magic numbers to allow
|
|
||||||
* extraction from a binary kernel image:
|
|
||||||
*
|
|
||||||
* IKCFG_ST
|
|
||||||
* <image>
|
|
||||||
* IKCFG_ED
|
|
||||||
*/
|
*/
|
||||||
#define MAGIC_START "IKCFG_ST"
|
asm (
|
||||||
#define MAGIC_END "IKCFG_ED"
|
" .pushsection .rodata, \"a\" \n"
|
||||||
#include "config_data.h"
|
" .ascii \"IKCFG_ST\" \n"
|
||||||
|
" .global kernel_config_data \n"
|
||||||
|
"kernel_config_data: \n"
|
||||||
#define MAGIC_SIZE (sizeof(MAGIC_START) - 1)
|
" .incbin \"kernel/config_data.gz\" \n"
|
||||||
#define kernel_config_data_size \
|
" .global kernel_config_data_end \n"
|
||||||
(sizeof(kernel_config_data) - 1 - MAGIC_SIZE * 2)
|
"kernel_config_data_end: \n"
|
||||||
|
" .ascii \"IKCFG_ED\" \n"
|
||||||
|
" .popsection \n"
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef CONFIG_IKCONFIG_PROC
|
#ifdef CONFIG_IKCONFIG_PROC
|
||||||
|
|
||||||
|
extern char kernel_config_data;
|
||||||
|
extern char kernel_config_data_end;
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
ikconfig_read_current(struct file *file, char __user *buf,
|
ikconfig_read_current(struct file *file, char __user *buf,
|
||||||
size_t len, loff_t * offset)
|
size_t len, loff_t * offset)
|
||||||
{
|
{
|
||||||
return simple_read_from_buffer(buf, len, offset,
|
return simple_read_from_buffer(buf, len, offset,
|
||||||
kernel_config_data + MAGIC_SIZE,
|
&kernel_config_data,
|
||||||
kernel_config_data_size);
|
&kernel_config_data_end -
|
||||||
|
&kernel_config_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations ikconfig_file_ops = {
|
static const struct file_operations ikconfig_file_ops = {
|
||||||
|
@ -79,7 +77,7 @@ static int __init ikconfig_init(void)
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
proc_set_size(entry, kernel_config_data_size);
|
proc_set_size(entry, &kernel_config_data_end - &kernel_config_data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue