DWARFGEN(1) 1 (dwarfdump and libdwarf) DWARFGEN(1)

# [NAME](#NAME)

`dwarfgen` — generate example DWARF data.

# [SYNOPSIS](#SYNOPSIS)

`dwarfgen` \[`-t` `type`] \[`-o` `outpath`] \[`-c` `-cunum`] `pathname`

# [DESCRIPTION](#DESCRIPTION)

The `dwarfgen` creates DWARF sections as requested by specific options.

Using some information source, create a tree of dwarf information (speaking of a DIE tree). Turn the die tree into dwarfdata using libdwarf producer and write the resulting data in an object file. It is a bit inconsistent in error handling just to demonstrate the various possibilities using the producer library.

Main options:

[`-t`](#t) `type`

what sort of input to read. May be one of:

`def`

means predefined (no input is read, the output is based on some canned setups built into dwarfgen). `path` is ignored in this case. This is the default, and does not work.

`obj`

means `path` is the object file to read (The dwarf sections are duplicated in the output file.) Requires `path`.

`txt`

`path` contains plain text (in a form rather like output by dwarfdump) that defines the dwarf that is to be output. Requires `path`.

[`-o`](#o) `outpath`

specifies the pathname of the output object. If not supplied, testout.o is used as the default output path.

[`-c`](#c) `cunum`

supplies a CU number of the ‘`obj`’ `type` input to read . because the dwarf producer wants just one CU. Default is -1 which won't match anything.

Other options:

[`-h`](#h)

transform high PC to const.

[`-s`](#s)

output as text.

[`-r`](#r)

show relocation details.

[`-v`](#v) `version`

DWARF version 2, 3, 4, or 5.

[`-p`](#p) `size`

pointer size, 4 or 8.

[`-f`](#f) `offset`

offset size, 4 or 8.

Linux 4.19.0-gvisor

---

Document: dwarfgen(1) from dwarf-tools 2.3.3-r0 (Chainguard OS)
Source: https://github.com/davea42/libdwarf-code
