Message ID | 20200317011654.zkx5r7so53skowlc@google.com |
---|---|
State | Changes Requested |
Delegated to: | BPF Maintainers |
Headers | show |
Series | [bpf] bpf: Support llvm-objcopy and llvm-objdump for vmlinux BTF | expand |
On Mon, Mar 16, 2020 at 6:17 PM Fangrui Song <maskray@google.com> wrote: > > Simplify gen_btf logic to make it work with llvm-objcopy and > llvm-objdump. We just need to retain one section .BTF. To do so, we can > use a simple objcopy --only-section=.BTF instead of jumping all the > hoops via an architecture-less binary file. > > We use a dd comment to change the e_type field in the ELF header from > ET_EXEC to ET_REL so that .btf.vmlinux.bin.o will be accepted by lld. > > Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux") > Cc: Stanislav Fomichev <sdf@google.com> > Cc: Nick Desaulniers <ndesaulniers@google.com> > Tested-by: Nick Desaulniers <ndesaulniers@google.com> > Reported-by: Nathan Chancellor <natechancellor@gmail.com> > Link: https://github.com/ClangBuiltLinux/linux/issues/871 > Signed-off-by: Fangrui Song <maskray@google.com> > --- > scripts/link-vmlinux.sh | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > index dd484e92752e..84be8d7c361d 100755 > --- a/scripts/link-vmlinux.sh > +++ b/scripts/link-vmlinux.sh > @@ -120,18 +120,9 @@ gen_btf() > > info "BTF" ${2} > vmlinux_link ${1} > - LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1} Is it really tested? Seems like you just dropped .BTF generation step completely... > > - # dump .BTF section into raw binary file to link with final vmlinux > - bin_arch=$(LANG=C ${OBJDUMP} -f ${1} | grep architecture | \ > - cut -d, -f1 | cut -d' ' -f2) > - bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \ > - awk '{print $4}') > - ${OBJCOPY} --change-section-address .BTF=0 \ > - --set-section-flags .BTF=alloc -O binary \ > - --only-section=.BTF ${1} .btf.vmlinux.bin > - ${OBJCOPY} -I binary -O ${bin_format} -B ${bin_arch} \ > - --rename-section .data=.BTF .btf.vmlinux.bin ${2} > + # Extract .BTF section, change e_type to ET_REL, to link with final vmlinux > + ${OBJCOPY} --only-section=.BTF ${1} ${2} && printf '\1' | dd of=${2} conv=notrunc bs=1 seek=16 > } > > # Create ${2} .o file with all symbols from the ${1} object file > -- > 2.25.1.481.gfbce0eb801-goog
Hi Fangrui,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on bpf/master]
[also build test WARNING on net/master linus/master v5.6-rc6]
[cannot apply to net-next/master next-20200317]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Fangrui-Song/bpf-Support-llvm-objcopy-and-llvm-objdump-for-vmlinux-BTF/20200317-125132
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
config: h8300-randconfig-a001-20200317 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=h8300
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0x3ffeac, is this intentional?
h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0x400048, is this intentional?
h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0xc72720, is this intentional?
h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0x119cf5c, is this intentional?
h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0x119e2d0, is this intentional?
h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0x119f000, is this intentional?
h8300-linux-objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0x122b300, is this intentional?
1+0 records in
1+0 records out
1 byte copied, 6.8066e-05 s, 14.7 kB/s
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Fangrui,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on bpf/master]
[also build test WARNING on net/master linus/master v5.6-rc6]
[cannot apply to net-next/master next-20200317]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Fangrui-Song/bpf-Support-llvm-objcopy-and-llvm-objdump-for-vmlinux-BTF/20200317-125132
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
config: i386-randconfig-g003-20200317 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0xc1000000, is this intentional?
objcopy: .tmp_vmlinux.btf: warning: empty loadable segment detected at vaddr=0xc1aae000, is this intentional?
1+0 records in
1+0 records out
1 byte copied, 8.22e-05 s, 12.2 kB/s
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index dd484e92752e..84be8d7c361d 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -120,18 +120,9 @@ gen_btf() info "BTF" ${2} vmlinux_link ${1} - LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1} - # dump .BTF section into raw binary file to link with final vmlinux - bin_arch=$(LANG=C ${OBJDUMP} -f ${1} | grep architecture | \ - cut -d, -f1 | cut -d' ' -f2) - bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \ - awk '{print $4}') - ${OBJCOPY} --change-section-address .BTF=0 \ - --set-section-flags .BTF=alloc -O binary \ - --only-section=.BTF ${1} .btf.vmlinux.bin - ${OBJCOPY} -I binary -O ${bin_format} -B ${bin_arch} \ - --rename-section .data=.BTF .btf.vmlinux.bin ${2} + # Extract .BTF section, change e_type to ET_REL, to link with final vmlinux + ${OBJCOPY} --only-section=.BTF ${1} ${2} && printf '\1' | dd of=${2} conv=notrunc bs=1 seek=16 } # Create ${2} .o file with all symbols from the ${1} object file