Go to file
Arnaldo Carvalho de Melo b91b19840b dwarf_loader: Support DW_AT_data_bit_offset
This appeared in DWARF4 but is supported only in gcc's -gdwarf-5,
support it in a way that makes the output be the same for both cases:

  $ gcc -gdwarf-4 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   a:1;                  /*     0: 0  8 */
  	long int                   b:1;                  /*     0: 1  8 */
  	long int                   c:1;                  /*     0: 2  8 */

  	/* XXX 29 bits hole, try to pack */
  	/* Bitfield combined with next fields */

  	int                        after_bitfield;       /*     4     4 */

  	/* size: 8, cachelines: 1, members: 4 */
  	/* sum members: 4 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* last cacheline: 8 bytes */
  };
  $ gcc -gdwarf-5 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   a:1;                  /*     0: 0  8 */
  	long int                   b:1;                  /*     0: 1  8 */
  	long int                   c:1;                  /*     0: 2  8 */

  	/* XXX 29 bits hole, try to pack */
  	/* Bitfield combined with next fields */

  	int                        after_bitfield;       /*     4     4 */

  	/* size: 8, cachelines: 1, members: 4 */
  	/* sum members: 4 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* last cacheline: 8 bytes */
  };
  $

Now with an integer before the bitfield:

  $ cat examples/dwarf5/bf.c
  struct pea {
  	int before_bitfield;
  	long a:1, b:1, c:1;
  	int after_bitfield;
  } p;
  $ gcc -gdwarf-4 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	int                        before_bitfield;      /*     0     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*     0:32  8 */
  	long int                   b:1;                  /*     0:33  8 */
  	long int                   c:1;                  /*     0:34  8 */

  	/* XXX 29 bits hole, try to pack */

  	int                        after_bitfield;       /*     8     4 */

  	/* size: 16, cachelines: 1, members: 5 */
  	/* sum members: 8 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 16 bytes */
  };
  $ gcc -gdwarf-5 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	int                        before_bitfield;      /*     0     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*     0:32  8 */
  	long int                   b:1;                  /*     0:33  8 */
  	long int                   c:1;                  /*     0:34  8 */

  	/* XXX 29 bits hole, try to pack */

  	int                        after_bitfield;       /*     8     4 */

  	/* size: 16, cachelines: 1, members: 5 */
  	/* sum members: 8 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 16 bytes */
  };
  $

And an array of long integers at the start, before the combination of an
integer with a long integer bitfield:

  $ cat examples/dwarf5/bf.c
  struct pea {
  	long array[3];
  	int before_bitfield;
  	long a:1, b:1, c:1;
  	int after_bitfield;
  } p;
  $ gcc -gdwarf-4 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   array[3];             /*     0    24 */
  	int                        before_bitfield;      /*    24     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*    24:32  8 */
  	long int                   b:1;                  /*    24:33  8 */
  	long int                   c:1;                  /*    24:34  8 */

  	/* XXX 29 bits hole, try to pack */

  	int                        after_bitfield;       /*    32     4 */

  	/* size: 40, cachelines: 1, members: 6 */
  	/* sum members: 32 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 40 bytes */
  };
  $ gcc -gdwarf-5 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   array[3];             /*     0    24 */
  	int                        before_bitfield;      /*    24     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*    24:32  8 */
  	long int                   b:1;                  /*    24:33  8 */
  	long int                   c:1;                  /*    24:34  8 */

  	/* XXX 29 bits hole, try to pack */

  	int                        after_bitfield;       /*    32     4 */

  	/* size: 40, cachelines: 1, members: 6 */
  	/* sum members: 32 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 40 bytes */
  };
  $

Reported-by: Mark Wielaard <mark@klomp.org>
Tested-by: "Daniel P. Berrangé" <berrange@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1919965
Link: https://lore.kernel.org/dwarves/20210128121122.GA775562@kernel.org/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-01-28 14:11:02 -03:00
cmake/modules cmake: libebl was merged into libdw 2020-02-03 08:42:13 +01:00
lib libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
man-pages pahole: Add heuristic to auto-add --btf_base for /sys/kernel/btf/ prefixed files 2020-11-18 11:10:23 -03:00
ostra ostra: Initial python3 conversion 2019-04-23 12:02:22 -03:00
rpm/SPECS rpm: Fix changelog date 2020-12-04 19:59:44 -03:00
.gitignore pahole: Add build dir, config.h to .gitignore 2019-02-11 12:55:46 -03:00
.gitmodules pahole: add libbpf as submodule under lib/bpf 2019-02-11 12:56:40 -03:00
CMakeLists.txt libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
COPYING [LICENSE]: Add COPYING file and add missing license info on some files 2007-12-17 14:15:42 -02:00
MANIFEST dwarves: Prep v1.19 2020-11-23 09:52:44 -03:00
NEWS dwarves: Prep v1.19 2020-11-23 09:52:44 -03:00
README [CMAKE]: Make the default install prefix be /usr/local 2007-04-19 18:01:47 -03:00
README.DEBUG README.DEBUG: Add an extra step to make the instructions cut'n'exec 2017-12-14 14:15:54 -03:00
README.btf v1.13: New release 2019-04-16 16:13:19 -03:00
README.cross README: Add instructions to do a cross build 2020-08-17 09:52:02 -03:00
README.ctracer ctracer: update README.ctracer, f9 has the dwarves 2008-10-29 08:54:53 -02:00
README.tarball docs: Add command line to generate tarball with a prefix 2020-03-12 16:55:15 -03:00
btf_encoder.c bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values 2021-01-26 22:36:36 -03:00
btf_encoder.h btf_encoder: Allow disabling BTF var encoding. 2020-09-21 17:00:16 -03:00
btf_loader.c libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
btfdiff v1.13: New release 2019-04-16 16:13:19 -03:00
changes-v1.13 v1.13: New release 2019-04-16 16:13:19 -03:00
changes-v1.16 dwarves: Prep v1.16 2019-12-16 11:43:53 -03:00
changes-v1.17 dwarves: Prep v1.17 2020-03-13 16:36:02 -03:00
changes-v1.18 dwarves: Prep v1.18 2020-10-02 17:29:59 -03:00
changes-v1.19 dwarves: Prep v1.19 2020-11-23 09:52:44 -03:00
codiff.c codiff: Remove unused filenames variable 2019-07-01 16:41:02 -03:00
config.h.cmake [DWARVES] Fixes a FIXME relating to a missing elf (libdw) symbol check. 2008-02-12 21:08:49 -02:00
ctf.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
ctf_encoder.c strings: use BTF's string APIs for strings management 2020-10-20 17:17:51 -03:00
ctf_encoder.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
ctf_loader.c dwarves: Move the common initialization of fields for 'struct type' 2020-08-05 15:16:19 -03:00
ctfdwdiff ctfdwdiff: Don't ask for variables and inline expansions in pfunct 2009-03-31 19:21:46 -03:00
ctracer.c dwarves: Adopt tag__is_base_type() from ctrace.c 2020-06-24 14:14:33 -03:00
dtagnames.c Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
dutil.c elf_symtab: Handle SHN_XINDEX index in elf_section_by_name() 2021-01-25 14:25:01 -03:00
dutil.h btf_encoder: Detect kernel module ftrace addresses 2020-12-07 12:53:11 -03:00
dwarf_loader.c dwarf_loader: Support DW_AT_data_bit_offset 2021-01-28 14:11:02 -03:00
dwarves.c pahole: Introduce --numeric_version for use in scripts and Makefiles 2020-11-10 13:04:22 -03:00
dwarves.h dwarf_loader: Support DW_AT_data_bit_offset 2021-01-28 14:11:02 -03:00
dwarves_emit.c emit: Remove unused 'is_pointer' variable 2019-07-02 10:27:16 -03:00
dwarves_emit.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
dwarves_fprintf.c fprintf: Make typedef__fprintf print anonymous enums 2020-11-19 11:41:18 -03:00
dwarves_reorganize.c reorganize: Enclose bitfield routines under ifdef 2019-07-02 12:28:50 -03:00
dwarves_reorganize.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
elf_symtab.c bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values 2021-01-26 22:36:36 -03:00
elf_symtab.h bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values 2021-01-26 22:36:36 -03:00
elfcreator.c elfcreator: Address initialization warning emitted by 'gcc -O6' 2019-12-16 11:19:47 -03:00
elfcreator.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
fullcircle v1.13: New release 2019-04-16 16:13:19 -03:00
gobuffer.c gobuffer: Do not crash on object without any public symbols 2020-01-17 13:54:15 -03:00
gobuffer.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
hash.h [DWARVES]: Use a hash table for the tags in a CU 2008-02-11 11:47:17 -02:00
libbtf.c btf_encoder: Improve ELF error reporting 2021-01-27 11:01:41 -03:00
libbtf.h libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
libctf.c strings: use BTF's string APIs for strings management 2020-10-20 17:17:51 -03:00
libctf.h strings: use BTF's string APIs for strings management 2020-10-20 17:17:51 -03:00
list.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
pahole.c libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
pahole_strings.h libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
pdwtags.c core: Allow the loaders to advertise features they have 2019-04-15 14:45:27 -03:00
pfunct.c pfunct: Use load stealer to speed up --class 2020-11-16 08:15:23 -03:00
pglobal.c pglobal: Allow passing the format path specifier, to use with BTF 2019-10-24 08:17:16 -03:00
prefcnt.c prefcnt: Avoid ambiguous else with for_each macro 2019-07-02 12:31:57 -03:00
rbtree.c Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
rbtree.h Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
regtest regtest: Accept --diff instad of plain 'diff' as long option 2012-05-14 19:36:58 -03:00
scncopy.c Adopt SPDX-License-Identifier 2019-01-18 15:41:48 -03:00
strings.c libbpf: allow to use packaged version 2021-01-21 10:26:25 -03:00
syscse.c dwarves: Make function__for_each_parameter receive 'cu' arg 2020-01-09 14:16:52 -03:00

README

Build instructions:

1. install cmake
2. mkdir build
3. cd build
4. cmake -D__LIB=lib ..
5. make install

Default is to be installed on /usr/local, see rpm spec file for
installing on other places.

Known to work scenarios:

Mandriva Cooker:

cmake 2.4.5-1mdv2007.1
libelfutils1-devel 0.123-1mdv2007.1

Debian Unstable:

cmake 2.4.5-1
libdw-dev 0.123-2

Fedora Core 6:

cmake 2.4.5-2.fc6
elfutils-devel 0.126-1.fc6