BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Vincent Li <vincent.mc.li@gmail.com>, bpf <bpf@vger.kernel.org>
Subject: Re: llvm-objdump bpf coredump
Date: Fri, 17 Sep 2021 20:00:07 -0700	[thread overview]
Message-ID: <dbf6ca0a-2c06-c703-6852-760b321e7219@fb.com> (raw)
In-Reply-To: <CAK3+h2wW-tWOT+VBOc8QjRcbhMX3dCpsvE9if4VOA8s7R2icjg@mail.gmail.com>



On 9/17/21 6:34 PM, Vincent Li wrote:
> Hi,
> 
> I am supposed to file a bug report in https://bugs.llvm.org/  but the
> site requires account login, while waiting for my account setup, and
> since this is related to BPF, I will try my luck here :)
> 
> This is cilium environment, when I use llvm-objdump to disassemble the
> bpf_lxc.o like below, it core dumps
> 
> #llvm-objdump -S -D  /var/run/cilium/state/2799/bpf_lxc.o >
> /home/bpf_lxc-5.4.txt

Any particular reason you are using '-D' here?

"llvm-objdump --help" gives:

   --disassemble-all       Display assembler mnemonics for the machine 
instructions 

   --disassemble           Display assembler mnemonics for the machine 
instructions 


   -D                      Alias for --disassemble-all 
 

   -d                      Alias for --disassemble

It gives the same description about -D and -d but actually -D tries to 
disassemble *all* sections and -d tries to disassemble *only* executable 
sections.

The following is an example to disassemble a selftest bpf program 
bpf_iter_tcp4.o:

[yhs@devbig003.ftw2 ~/work/bpf-next/tools/testing/selftests/bpf] 
llvm-objdump -D bpf_iter_tcp4.o >& ~/log
[yhs@devbig003.ftw2 ~/work/bpf-next/tools/testing/selftests/bpf] grep 
"Disassembly of section" ~/log
Disassembly of section .strtab:
Disassembly of section iter/tcp:
Disassembly of section .reliter/tcp:
Disassembly of section license:
Disassembly of section .rodata:
Disassembly of section .debug_loc:
Disassembly of section .debug_abbrev:
Disassembly of section .debug_info:
Disassembly of section .rel.debug_info:
Disassembly of section .debug_ranges:
Disassembly of section .debug_str:
Disassembly of section .BTF:
Disassembly of section .rel.BTF:
Disassembly of section .BTF.ext:
Disassembly of section .rel.BTF.ext:
Disassembly of section .debug_frame:
Disassembly of section .rel.debug_frame:
Disassembly of section .debug_line:
Disassembly of section .rel.debug_line:
Disassembly of section .llvm_addrsig:
Disassembly of section .symtab:
[yhs@devbig003.ftw2 ~/work/bpf-next/tools/testing/selftests/bpf] 
llvm-objdump -d bpf_iter_tcp4.o >& ~/log
[yhs@devbig003.ftw2 ~/work/bpf-next/tools/testing/selftests/bpf] grep 
"Disassembly of section" ~/log
Disassembly of section iter/tcp:
[yhs@devbig003.ftw2 ~/work/bpf-next/tools/testing/selftests/bpf]

You can see, "-D" tries to disassemble *all* sections and "-d" only 
tries to disassemble "iter/tcp" section which is the *text* section.

I suspect llvm BPF backend may have some loose end which didn't handle
well for illegal insn, which I will put up a task so we can fix it.

I guess you tries to disassemble for non-text sections because you want
to compare contents of sections with text file? If this is the case,
you may want to compare section data directly, because disassemble
illegal insn will result in "<unknown>" insn which may hide the
actual data difference. In any case, it would be good to know what you
try to do with "-D" result so we may discuss to find a proper solution.

> 
> PLEASE submit a bug report to https://bugs.llvm.org/  and include the
> crash backtrace.
> 
> Stack dump:
> 
> 0. Program arguments: llvm-objdump -S -D /var/run/cilium/state/2799/bpf_lxc.o
> 
>   #0 0x00000000006336bc llvm::sys::PrintStackTrace(llvm::raw_ostream&,
> int) (/usr/local/bin/llvm-objdump+0x6336bc)
> 
>   #1 0x00000000006318a4 llvm::sys::RunSignalHandlers()
> (/usr/local/bin/llvm-objdump+0x6318a4)
> 
>   #2 0x0000000000631efd SignalHandler(int) (/usr/local/bin/llvm-objdump+0x631efd)
> 
>   #3 0x00007f9f39a7fb20 __restore_rt (/lib64/libpthread.so.0+0x12b20)
> 
>   #4 0x0000000000492e8b
> llvm::BPFInstPrinter::printMemOperand(llvm::MCInst const*, int,
> llvm::raw_ostream&, char const*)
> (/usr/local/bin/llvm-objdump+0x492e8b)
> 
>   #5 0x00000000004946c0 llvm::BPFInstPrinter::printInst(llvm::MCInst
> const*, unsigned long, llvm::StringRef, llvm::MCSubtargetInfo const&,
> llvm::raw_ostream&) (/usr/local/bin/llvm-objdump+0x4946c0)
> 
>   #6 0x0000000000432351 (anonymous
> namespace)::BPFPrettyPrinter::printInst(llvm::MCInstPrinter&,
> llvm::MCInst const*, llvm::ArrayRef<unsigned char>,
> llvm::object::SectionedAddress, llvm::formatted_raw_ostream&,
> llvm::StringRef, llvm::MCSubtargetInfo const&, (anonymous
> namespace)::SourcePrinter*, llvm::StringRef,
> std::vector<llvm::object::RelocationRef,
> std::allocator<llvm::object::RelocationRef> >*, (anonymous
> namespace)::LiveVariablePrinter&)
> (/usr/local/bin/llvm-objdump+0x432351)
> 
>   #7 0x00000000004400b8 disassembleObject(llvm::Target const*,
> llvm::object::ObjectFile const*, llvm::MCContext&,
> llvm::MCDisassembler*, llvm::MCDisassembler*, llvm::MCInstrAnalysis
> const*, llvm::MCInstPrinter*, llvm::MCSubtargetInfo const*,
> llvm::MCSubtargetInfo const*, (anonymous namespace)::PrettyPrinter&,
> (anonymous namespace)::SourcePrinter&, bool)
> (/usr/local/bin/llvm-objdump+0x4400b8)
> 
>   #8 0x000000000044444e disassembleObject(llvm::object::ObjectFile
> const*, bool) (/usr/local/bin/llvm-objdump+0x44444e)
> 
>   #9 0x00000000004454e2 dumpObject(llvm::object::ObjectFile*,
> llvm::object::Archive const*, llvm::object::Archive::Child const*)
> (/usr/local/bin/llvm-objdump+0x4454e2)
> 
> #10 0x0000000000409910 main (/usr/local/bin/llvm-objdump+0x409910)
> 
> #11 0x00007f9f3854c493 __libc_start_main (/lib64/libc.so.6+0x23493)
> 
> #12 0x000000000042384e _start (/usr/local/bin/llvm-objdump+0x42384e)
> 
> Segmentation fault (core dumped)
> 
> I compiled and installed llvm and clang 12.0.1 myself
> 

  reply	other threads:[~2021-09-18  3:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18  1:34 llvm-objdump bpf coredump Vincent Li
2021-09-18  3:00 ` Yonghong Song [this message]
2021-09-18 15:41   ` Vincent Li
2021-09-19 23:36     ` Yonghong Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbf6ca0a-2c06-c703-6852-760b321e7219@fb.com \
    --to=yhs@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=vincent.mc.li@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox