sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget(/translations/zh_CN/kbuild/gendwarfksymsmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/zh_TW/kbuild/gendwarfksymsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/it_IT/kbuild/gendwarfksymsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ja_JP/kbuild/gendwarfksymsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ko_KR/kbuild/gendwarfksymsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/sp_SP/kbuild/gendwarfksymsmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hDWARF module versioningh]hDWARF module versioning}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhB/var/lib/git/docbuild/linux/Documentation/kbuild/gendwarfksyms.rsthKubh)}(hhh](h)}(h Introductionh]h Introduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXWhen CONFIG_MODVERSIONS is enabled, symbol versions for modules are typically calculated from preprocessed source code using the **genksyms** tool. However, this is incompatible with languages such as Rust, where the source code has insufficient information about the resulting ABI. With CONFIG_GENDWARFKSYMS (and CONFIG_DEBUG_INFO) selected, **gendwarfksyms** is used instead to calculate symbol versions from the DWARF debugging information, which contains the necessary details about the final module ABI.h](hWhen CONFIG_MODVERSIONS is enabled, symbol versions for modules are typically calculated from preprocessed source code using the }(hhhhhNhNubhstrong)}(h **genksyms**h]hgenksyms}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh tool. However, this is incompatible with languages such as Rust, where the source code has insufficient information about the resulting ABI. With CONFIG_GENDWARFKSYMS (and CONFIG_DEBUG_INFO) selected, }(hhhhhNhNubh)}(h**gendwarfksyms**h]h gendwarfksyms}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh is used instead to calculate symbol versions from the DWARF debugging information, which contains the necessary details about the final module ABI.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hUsageh]hUsage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hgendwarfksyms accepts a list of object files on the command line, and a list of symbol names (one per line) in standard input::h]h~gendwarfksyms accepts a list of object files on the command line, and a list of symbol names (one per line) in standard input:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh literal_block)}(hXUsage: gendwarfksyms [options] elf-object-file ... < symbol-list Options: -d, --debug Print debugging information --dump-dies Dump DWARF DIE contents --dump-die-map Print debugging information about die_map changes --dump-types Dump type strings --dump-versions Dump expanded type strings used for symbol versions -s, --stable Support kABI stability features -T, --symtypes file Write a symtypes file -h, --help Print this messageh]hXUsage: gendwarfksyms [options] elf-object-file ... < symbol-list Options: -d, --debug Print debugging information --dump-dies Dump DWARF DIE contents --dump-die-map Print debugging information about die_map changes --dump-types Dump type strings --dump-versions Dump expanded type strings used for symbol versions -s, --stable Support kABI stability features -T, --symtypes file Write a symtypes file -h, --help Print this message}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhhhhubeh}(h]usageah ]h"]usageah$]h&]uh1hhhhhhhhKubeh}(h] introductionah ]h"] introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hType information availabilityh]hType information availability}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj?hhhhhK%ubh)}(hXWhile symbols are typically exported in the same translation unit (TU) where they're defined, it's also perfectly fine for a TU to export external symbols. For example, this is done when calculating symbol versions for exports in stand-alone assembly code.h]hXWhile symbols are typically exported in the same translation unit (TU) where they’re defined, it’s also perfectly fine for a TU to export external symbols. For example, this is done when calculating symbol versions for exports in stand-alone assembly code.}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hj?hhubh)}(hTo ensure the compiler emits the necessary DWARF type information in the TU where symbols are actually exported, gendwarfksyms adds a pointer to exported symbols in the `EXPORT_SYMBOL()` macro using the following macro::h](hTo ensure the compiler emits the necessary DWARF type information in the TU where symbols are actually exported, gendwarfksyms adds a pointer to exported symbols in the }(hj^hhhNhNubhtitle_reference)}(h`EXPORT_SYMBOL()`h]hEXPORT_SYMBOL()}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj^ubh! macro using the following macro:}(hj^hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK,hj?hhubj)}(h#define __GENDWARFKSYMS_EXPORT(sym) \ static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ __section(".discard.gendwarfksyms") = &sym;h]h#define __GENDWARFKSYMS_EXPORT(sym) \ static typeof(sym) *__gendwarfksyms_ptr_##sym __used \ __section(".discard.gendwarfksyms") = &sym;}hjsbah}(h]h ]h"]h$]h&]j-j.uh1jhhhK1hj?hhubh)}(hXWhen a symbol pointer is found in DWARF, gendwarfksyms can use its type for calculating symbol versions even if the symbol is defined elsewhere. The name of the symbol pointer is expected to start with `__gendwarfksyms_ptr_`, followed by the name of the exported symbol.h](hWhen a symbol pointer is found in DWARF, gendwarfksyms can use its type for calculating symbol versions even if the symbol is defined elsewhere. The name of the symbol pointer is expected to start with }(hjhhhNhNubjg)}(h`__gendwarfksyms_ptr_`h]h__gendwarfksyms_ptr_}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh., followed by the name of the exported symbol.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK6hj?hhubeh}(h]type-information-availabilityah ]h"]type information availabilityah$]h&]uh1hhhhhhhhK%ubh)}(hhh](h)}(hSymtypes output formath]hSymtypes output format}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKhjhhubh)}(hMatching the existing format, the first column of each line contains either a type reference or a symbol name. Type references have a one-letter prefix followed by "#" and the name of the type. Four reference types are supported::h]hMatching the existing format, the first column of each line contains either a type reference or a symbol name. Type references have a one-letter prefix followed by “#” and the name of the type. Four reference types are supported:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKEhjhhubj)}(hEe# = enum s# = struct t# = typedef u# = unionh]hEe# = enum s# = struct t# = typedef u# = union}hjsbah}(h]h ]h"]h$]h&]j-j.uh1jhhhKJhjhhubh)}(hCType names with spaces in them are wrapped in single quotes, e.g.::h]hBType names with spaces in them are wrapped in single quotes, e.g.:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjhhubj)}(h=s#'core::result::Result'h]h=s#'core::result::Result'}hjsbah}(h]h ]h"]h$]h&]j-j.uh1jhhhKQhjhhubh)}(hThe rest of the line contains a type string. Unlike with genksyms that produces C-style type strings, gendwarfksyms uses the same simple parsed DWARF format produced by **--dump-dies**, but with type references instead of fully expanded strings.h](hThe rest of the line contains a type string. Unlike with genksyms that produces C-style type strings, gendwarfksyms uses the same simple parsed DWARF format produced by }(hjhhhNhNubh)}(h**--dump-dies**h]h --dump-dies}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh=, but with type references instead of fully expanded strings.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKShjhhubeh}(h]symtypes-output-formatah ]h"]symtypes output formatah$]h&]uh1hhhhhhhhK`, but we can't hide the increase in structure size. The `byte_size` rule allows us to override the structure size used for symbol versioning.h](hWTo append new members, we can hide them from symbol versioning as described in section }(hj(hhhNhNubh)}(h&:ref:`Hiding members `h]hinline)}(hj2h]hHiding members}(hj6hhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1j4hj0ubah}(h]h ]h"]h$]h&]refdockbuild/gendwarfksyms refdomainjAreftyperef refexplicitrefwarn reftargethiding_membersuh1hhhhKhj(ubh:, but we can’t hide the increase in structure size. The }(hj(hhhNhNubjg)}(h `byte_size`h]h byte_size}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhj(ubhJ rule allows us to override the structure size used for symbol versioning.}(hj(hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(h.The rule fields are expected to be as follows:h]h.The rule fields are expected to be as follows:}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubj )}(hhh](j)}(h`type`: "byte_size"h]h)}(hjh](jg)}(h`type`h]htype}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubh: “byte_size”}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(he`target`: The fully qualified name of the target data structure (as shown in **--dump-dies** output).h]h)}(he`target`: The fully qualified name of the target data structure (as shown in **--dump-dies** output).h](jg)}(h`target`h]htarget}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubhE: The fully qualified name of the target data structure (as shown in }(hjhhhNhNubh)}(h**--dump-dies**h]h --dump-dies}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh output).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hK`value`: A positive decimal number indicating the structure size in bytes. h]h)}(hJ`value`: A positive decimal number indicating the structure size in bytes.h](jg)}(h`value`h]hvalue}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jfhjubhC: A positive decimal number indicating the structure size in bytes.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]jjuh1j hhhKhj hhubh)}(h