Skip to content

Commit c229c17

Browse files
hawkinswanakryiko
authored andcommitted
docs/bpf: Add constant values for linkages
Make the values of the symbolic constants that define the valid linkages for functions and variables explicit. Signed-off-by: Will Hawkins <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 376bd59 commit c229c17

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

Documentation/bpf/btf.rst

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ No additional type data follow ``btf_type``.
368368
* ``info.kind_flag``: 0
369369
* ``info.kind``: BTF_KIND_FUNC
370370
* ``info.vlen``: linkage information (BTF_FUNC_STATIC, BTF_FUNC_GLOBAL
371-
or BTF_FUNC_EXTERN)
371+
or BTF_FUNC_EXTERN - see :ref:`BTF_Function_Linkage_Constants`)
372372
* ``type``: a BTF_KIND_FUNC_PROTO type
373373

374374
No additional type data follow ``btf_type``.
@@ -424,9 +424,8 @@ following data::
424424
__u32 linkage;
425425
};
426426

427-
``struct btf_var`` encoding:
428-
* ``linkage``: currently only static variable 0, or globally allocated
429-
variable in ELF sections 1
427+
``btf_var.linkage`` may take the values: BTF_VAR_STATIC, BTF_VAR_GLOBAL_ALLOCATED or BTF_VAR_GLOBAL_EXTERN -
428+
see :ref:`BTF_Var_Linkage_Constants`.
430429

431430
Not all type of global variables are supported by LLVM at this point.
432431
The following is currently available:
@@ -549,6 +548,38 @@ The ``btf_enum64`` encoding:
549548
If the original enum value is signed and the size is less than 8,
550549
that value will be sign extended into 8 bytes.
551550

551+
2.3 Constant Values
552+
-------------------
553+
554+
.. _BTF_Function_Linkage_Constants:
555+
556+
2.3.1 Function Linkage Constant Values
557+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
558+
.. table:: Function Linkage Values and Meanings
559+
560+
=================== ===== ===========
561+
kind value description
562+
=================== ===== ===========
563+
``BTF_FUNC_STATIC`` 0x0 definition of subprogram not visible outside containing compilation unit
564+
``BTF_FUNC_GLOBAL`` 0x1 definition of subprogram visible outside containing compilation unit
565+
``BTF_FUNC_EXTERN`` 0x2 declaration of a subprogram whose definition is outside the containing compilation unit
566+
=================== ===== ===========
567+
568+
569+
.. _BTF_Var_Linkage_Constants:
570+
571+
2.3.2 Variable Linkage Constant Values
572+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
573+
.. table:: Variable Linkage Values and Meanings
574+
575+
============================ ===== ===========
576+
kind value description
577+
============================ ===== ===========
578+
``BTF_VAR_STATIC`` 0x0 definition of global variable not visible outside containing compilation unit
579+
``BTF_VAR_GLOBAL_ALLOCATED`` 0x1 definition of global variable visible outside containing compilation unit
580+
``BTF_VAR_GLOBAL_EXTERN`` 0x2 declaration of global variable whose definition is outside the containing compilation unit
581+
============================ ===== ===========
582+
552583
3. BTF Kernel API
553584
=================
554585

0 commit comments

Comments
 (0)