summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-08-13 14:54:42 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2019-08-13 17:19:42 -0400
commit7fd785685e2243bb639b31557e258d11464c3489 (patch)
treef26abfedf56ba3a3e2674f367538e783b958dd4d
parent9840a4ffcf0b26e08472ed53d176a6a0f1d4c498 (diff)
btf: rename /sys/kernel/btf/kernel into /sys/kernel/btf/vmlinux
Expose kernel's BTF under the name vmlinux to be more uniform with using kernel module names as file names in the future. Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs") Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--Documentation/ABI/testing/sysfs-kernel-btf2
-rw-r--r--kernel/bpf/sysfs_btf.c30
-rwxr-xr-xscripts/link-vmlinux.sh18
3 files changed, 25 insertions, 25 deletions
diff --git a/Documentation/ABI/testing/sysfs-kernel-btf b/Documentation/ABI/testing/sysfs-kernel-btf
index 5390f8001f96..2c9744b2cd59 100644
--- a/Documentation/ABI/testing/sysfs-kernel-btf
+++ b/Documentation/ABI/testing/sysfs-kernel-btf
@@ -6,7 +6,7 @@ Description:
6 Contains BTF type information and related data for kernel and 6 Contains BTF type information and related data for kernel and
7 kernel modules. 7 kernel modules.
8 8
9What: /sys/kernel/btf/kernel 9What: /sys/kernel/btf/vmlinux
10Date: Aug 2019 10Date: Aug 2019
11KernelVersion: 5.5 11KernelVersion: 5.5
12Contact: bpf@vger.kernel.org 12Contact: bpf@vger.kernel.org
diff --git a/kernel/bpf/sysfs_btf.c b/kernel/bpf/sysfs_btf.c
index 092e63b9758b..4659349fc795 100644
--- a/kernel/bpf/sysfs_btf.c
+++ b/kernel/bpf/sysfs_btf.c
@@ -9,30 +9,30 @@
9#include <linux/sysfs.h> 9#include <linux/sysfs.h>
10 10
11/* See scripts/link-vmlinux.sh, gen_btf() func for details */ 11/* See scripts/link-vmlinux.sh, gen_btf() func for details */
12extern char __weak _binary__btf_kernel_bin_start[]; 12extern char __weak _binary__btf_vmlinux_bin_start[];
13extern char __weak _binary__btf_kernel_bin_end[]; 13extern char __weak _binary__btf_vmlinux_bin_end[];
14 14
15static ssize_t 15static ssize_t
16btf_kernel_read(struct file *file, struct kobject *kobj, 16btf_vmlinux_read(struct file *file, struct kobject *kobj,
17 struct bin_attribute *bin_attr, 17 struct bin_attribute *bin_attr,
18 char *buf, loff_t off, size_t len) 18 char *buf, loff_t off, size_t len)
19{ 19{
20 memcpy(buf, _binary__btf_kernel_bin_start + off, len); 20 memcpy(buf, _binary__btf_vmlinux_bin_start + off, len);
21 return len; 21 return len;
22} 22}
23 23
24static struct bin_attribute bin_attr_btf_kernel __ro_after_init = { 24static struct bin_attribute bin_attr_btf_vmlinux __ro_after_init = {
25 .attr = { .name = "kernel", .mode = 0444, }, 25 .attr = { .name = "vmlinux", .mode = 0444, },
26 .read = btf_kernel_read, 26 .read = btf_vmlinux_read,
27}; 27};
28 28
29static struct kobject *btf_kobj; 29static struct kobject *btf_kobj;
30 30
31static int __init btf_kernel_init(void) 31static int __init btf_vmlinux_init(void)
32{ 32{
33 int err; 33 int err;
34 34
35 if (!_binary__btf_kernel_bin_start) 35 if (!_binary__btf_vmlinux_bin_start)
36 return 0; 36 return 0;
37 37
38 btf_kobj = kobject_create_and_add("btf", kernel_kobj); 38 btf_kobj = kobject_create_and_add("btf", kernel_kobj);
@@ -42,10 +42,10 @@ static int __init btf_kernel_init(void)
42 return err; 42 return err;
43 } 43 }
44 44
45 bin_attr_btf_kernel.size = _binary__btf_kernel_bin_end - 45 bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end -
46 _binary__btf_kernel_bin_start; 46 _binary__btf_vmlinux_bin_start;
47 47
48 return sysfs_create_bin_file(btf_kobj, &bin_attr_btf_kernel); 48 return sysfs_create_bin_file(btf_kobj, &bin_attr_btf_vmlinux);
49} 49}
50 50
51subsys_initcall(btf_kernel_init); 51subsys_initcall(btf_vmlinux_init);
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index cb93832c6ad7..f7933c606f27 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -117,9 +117,9 @@ gen_btf()
117 # dump .BTF section into raw binary file to link with final vmlinux 117 # dump .BTF section into raw binary file to link with final vmlinux
118 bin_arch=$(${OBJDUMP} -f ${1} | grep architecture | \ 118 bin_arch=$(${OBJDUMP} -f ${1} | grep architecture | \
119 cut -d, -f1 | cut -d' ' -f2) 119 cut -d, -f1 | cut -d' ' -f2)
120 ${OBJCOPY} --dump-section .BTF=.btf.kernel.bin ${1} 2>/dev/null 120 ${OBJCOPY} --dump-section .BTF=.btf.vmlinux.bin ${1} 2>/dev/null
121 ${OBJCOPY} -I binary -O ${CONFIG_OUTPUT_FORMAT} -B ${bin_arch} \ 121 ${OBJCOPY} -I binary -O ${CONFIG_OUTPUT_FORMAT} -B ${bin_arch} \
122 --rename-section .data=.BTF .btf.kernel.bin ${2} 122 --rename-section .data=.BTF .btf.vmlinux.bin ${2}
123} 123}
124 124
125# Create ${2} .o file with all symbols from the ${1} object file 125# Create ${2} .o file with all symbols from the ${1} object file
@@ -227,10 +227,10 @@ ${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o
227info MODINFO modules.builtin.modinfo 227info MODINFO modules.builtin.modinfo
228${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo 228${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
229 229
230btf_kernel_bin_o="" 230btf_vmlinux_bin_o=""
231if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then 231if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then
232 if gen_btf .tmp_vmlinux.btf .btf.kernel.bin.o ; then 232 if gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then
233 btf_kernel_bin_o=.btf.kernel.bin.o 233 btf_vmlinux_bin_o=.btf.vmlinux.bin.o
234 fi 234 fi
235fi 235fi
236 236
@@ -265,11 +265,11 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
265 kallsyms_vmlinux=.tmp_vmlinux2 265 kallsyms_vmlinux=.tmp_vmlinux2
266 266
267 # step 1 267 # step 1
268 vmlinux_link .tmp_vmlinux1 ${btf_kernel_bin_o} 268 vmlinux_link .tmp_vmlinux1 ${btf_vmlinux_bin_o}
269 kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o 269 kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
270 270
271 # step 2 271 # step 2
272 vmlinux_link .tmp_vmlinux2 .tmp_kallsyms1.o ${btf_kernel_bin_o} 272 vmlinux_link .tmp_vmlinux2 .tmp_kallsyms1.o ${btf_vmlinux_bin_o}
273 kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o 273 kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
274 274
275 # step 3 275 # step 3
@@ -280,13 +280,13 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
280 kallsymso=.tmp_kallsyms3.o 280 kallsymso=.tmp_kallsyms3.o
281 kallsyms_vmlinux=.tmp_vmlinux3 281 kallsyms_vmlinux=.tmp_vmlinux3
282 282
283 vmlinux_link .tmp_vmlinux3 .tmp_kallsyms2.o ${btf_kernel_bin_o} 283 vmlinux_link .tmp_vmlinux3 .tmp_kallsyms2.o ${btf_vmlinux_bin_o}
284 kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o 284 kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o
285 fi 285 fi
286fi 286fi
287 287
288info LD vmlinux 288info LD vmlinux
289vmlinux_link vmlinux "${kallsymso}" "${btf_kernel_bin_o}" 289vmlinux_link vmlinux "${kallsymso}" "${btf_vmlinux_bin_o}"
290 290
291if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then 291if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then
292 info SORTEX vmlinux 292 info SORTEX vmlinux