---
name: "dwarf_add_AT_dataref"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/dwarf_add_AT_dataref"
---

# dwarf\_add\_AT\_dataref(3)

create an attribute descriptor for a relocatable address

## NAME

**dwarf\_add\_AT\_dataref** – create an attribute descriptor for a relocatable address

## LIBRARY

library “libdwarf”

## SYNOPSIS

**#include \<libdwarf.h\>**

*Dwarf\_P\_Attribute*\

**dwarf\_add\_AT\_dataref**(*Dwarf\_P\_Debug dbg*, *Dwarf\_P\_Die die*, *Dwarf\_Half attr*, *Dwarf\_Unsigned pc\_value*, *Dwarf\_Unsigned sym\_index*, *Dwarf\_Error \*err*);

## DESCRIPTION

Function **dwarf\_add\_AT\_dataref**() creates an attribute descriptor for a relocatable address and attaches it to the debugging information entry referenced by argument *die*.

If flag DW\_DLC\_SIZE\_64 is set, the address value will be 8 bytes in size and of the DWARF form DW\_FORM\_data8. Otherwise, the address value will be 4 bytes in size and of the DWARF form DW\_FORM\_data4.

Argument *dbg* should reference a DWARF producer instance allocated using [dwarf\_producer\_init(3)](/dwarf_producer_init/3.md) or [dwarf\_producer\_init\_b(3)](/dwarf_producer_init_b/3.md).

Argument *die* should reference a debugging information entry allocated using [dwarf\_new\_die(3)](/dwarf_new_die/3.md).

Argument *attr* specifies the attribute code of the created attribute descriptor.

Argument *pc\_value* specifies the value of the relocatable address.

Argument *sym\_index* specifies the ELF symbol index of the symbol to be used for relocation.

If argument *err* is not NULL, it will be used to store error information in case of an error.

## RETURN VALUES

On success, function **dwarf\_add\_AT\_dataref**() returns the created attribute descriptor. In case of an error, function **dwarf\_add\_AT\_dataref**() returns DW\_DLV\_BADADDR and sets the argument *err*.

## ERRORS

Function **dwarf\_add\_AT\_dataref**() can fail with:

- \[DW\_DLE\_ARGUMENT\]

  Either of the arguments *dbg* or *die* was NULL.

- \[DW\_DLE\_MEMORY\]

  An out of memory condition was encountered during the execution of the function.

## SEE ALSO

[dwarf(3)](/dwarf/3.md), [dwarf\_add\_AT\_ref\_address(3)](/dwarf_add_AT_ref_address/3.md), [dwarf\_add\_AT\_reference(3)](/dwarf_add_AT_reference/3.md), [dwarf\_add\_AT\_signed\_const(3)](/dwarf_add_AT_signed_const/3.md), [dwarf\_add\_AT\_unsigned\_const(3)](/dwarf_add_AT_unsigned_const/3.md), [dwarf\_new\_die(3)](/dwarf_new_die/3.md), [dwarf\_producer\_init(3)](/dwarf_producer_init/3.md), [dwarf\_producer\_init\_b(3)](/dwarf_producer_init_b/3.md)
