dwarves/man-pages
Arnaldo Carvalho de Melo 65d7273668 pahole: Introduce --compile to produce a compilable output
This is the same strategy adopted by the bpftool when generating a
vmlinux file using:

  $ bpftool btf dump file vmlinux format c > vmlinux.h

Testing it:

  $ cat a.c
  #include "vmlinux.h"

  int main(void)
  {
        struct saved_context bla;

        bla.ds = 1;
        return bla.ds + 1;
  }
  $

  $ rm -f a ; make a
  cc     a.c   -o a
  $

Now using pahole:

  $ pahole --compile > vmlinux.h
  $ rm -f a ; make a
  $

This still have some issues, like:

  $ pahole --compile ../build/allyesconfig/drivers/spi/spi-bitbang.o > spi.h
  $ make spi
  cc     spi.c   -o spi
  In file included from spi.c:1:
  spi.h:7127:38: error: ‘txrx_word’ declared as function returning an array
   7127 |         u32 (*txrx_word)(struct spi_device *, unsigned int, u32, u8, unsigned int)[4]; /*   200    32 */
        |              ^~~~~~~~~
  make: *** [<builtin>: spi] Error 1
  $

The original source code:

	/* txrx_word[SPI_MODE_*]() just looks like a shift register */

                  u32 (*txrx_word[4])(struct spi_device *, unsigned int, u32, u8, unsigned int);

But this misgeneration predates this patch, so shouldn't prevent it from
being merged now, to make progress.

Also there are issues when generating from DWARF, so for now only accept
it if generating from BTF.

Trying to run it with dwarf produces, for now:

  $ pahole -F dwarf --compile vmlinux
  pahole: --compile currently only works with BTF.
  $

Cc: Tony Jones <tonyj@suse.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-03-09 15:54:24 -03:00
..
pahole.1 pahole: Introduce --compile to produce a compilable output 2022-03-09 15:54:24 -03:00