| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="SD_ELF_NOTE_DLOPEN" xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 7 |
|
| 8 |
<refentryinfo> |
| 9 |
<title>SD_ELF_NOTE_DLOPEN</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>SD_ELF_NOTE_DLOPEN</refentrytitle> |
| 15 |
<manvolnum>3</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>SD_ELF_NOTE_DLOPEN</refname> |
| 20 |
<refname>SD_ELF_NOTE_DLOPEN_VENDOR</refname> |
| 21 |
<refname>SD_ELF_NOTE_DLOPEN_TYPE</refname> |
| 22 |
<refname>SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED</refname> |
| 23 |
<refname>SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED</refname> |
| 24 |
<refname>SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED</refname> |
| 25 |
|
| 26 |
<refpurpose>Embed ELF .note.dlopen metadata for shared library dependencies</refpurpose> |
| 27 |
</refnamediv> |
| 28 |
|
| 29 |
<refsynopsisdiv> |
| 30 |
<funcsynopsis> |
| 31 |
<funcsynopsisinfo>#include <systemd/sd-dlopen.h></funcsynopsisinfo> |
| 32 |
|
| 33 |
<funcsynopsisinfo><function>SD_ELF_NOTE_DLOPEN(<replaceable>feature</replaceable>, <replaceable>description</replaceable>, <replaceable>priority</replaceable>, <replaceable>soname...</replaceable>)</function></funcsynopsisinfo> |
| 34 |
|
| 35 |
<funcsynopsisinfo>#define SD_ELF_NOTE_DLOPEN_VENDOR "FDO"</funcsynopsisinfo> |
| 36 |
<funcsynopsisinfo>#define SD_ELF_NOTE_DLOPEN_TYPE UINT32_C(0x407c0c0a)</funcsynopsisinfo> |
| 37 |
<funcsynopsisinfo>#define SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED "required"</funcsynopsisinfo> |
| 38 |
<funcsynopsisinfo>#define SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED "recommended"</funcsynopsisinfo> |
| 39 |
<funcsynopsisinfo>#define SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED "suggested"</funcsynopsisinfo> |
| 40 |
|
| 41 |
</funcsynopsis> |
| 42 |
</refsynopsisdiv> |
| 43 |
|
| 44 |
<refsect1> |
| 45 |
<title>Description</title> |
| 46 |
|
| 47 |
<para><function>SD_ELF_NOTE_DLOPEN()</function> is a macro that embeds a |
| 48 |
<filename>.note.dlopen</filename> ELF note section in the compiled binary, declaring a weak dependency |
| 49 |
on a shared library loaded via <function>dlopen()</function>. This implements the |
| 50 |
<ulink url="https://uapi-group.org/specifications/specs/elf_dlopen_metadata/">ELF dlopen |
| 51 |
metadata</ulink> specification, allowing package managers and build systems to discover runtime |
| 52 |
dependencies that are not visible through regular ELF <constant>DT_NEEDED</constant> entries.</para> |
| 53 |
|
| 54 |
<para>The macro takes the following parameters:</para> |
| 55 |
|
| 56 |
<variablelist> |
| 57 |
<varlistentry> |
| 58 |
<term><parameter>feature</parameter></term> |
| 59 |
<listitem><para>A short string identifying the feature this library provides (e.g. |
| 60 |
<literal>XKB</literal>, <literal>PCRE2</literal>).</para> |
| 61 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 62 |
</varlistentry> |
| 63 |
|
| 64 |
<varlistentry> |
| 65 |
<term><parameter>description</parameter></term> |
| 66 |
<listitem><para>A human-readable description of what the library is used for.</para> |
| 67 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 68 |
</varlistentry> |
| 69 |
|
| 70 |
<varlistentry> |
| 71 |
<term><parameter>priority</parameter></term> |
| 72 |
<listitem><para>One of <constant>SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED</constant>, |
| 73 |
<constant>SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED</constant>, or |
| 74 |
<constant>SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED</constant>, indicating how important the |
| 75 |
dependency is.</para> |
| 76 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 77 |
</varlistentry> |
| 78 |
|
| 79 |
<varlistentry> |
| 80 |
<term><parameter>soname...</parameter></term> |
| 81 |
<listitem><para>One or more shared object names (sonames) for the library, e.g. |
| 82 |
<literal>libfoo.so.1</literal>. Multiple sonames may be specified as separate arguments (up to 5) |
| 83 |
for libraries that have changed soname across versions.</para> |
| 84 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 85 |
</varlistentry> |
| 86 |
</variablelist> |
| 87 |
|
| 88 |
<para>The embedded metadata can be read from a compiled ELF binary using:</para> |
| 89 |
<programlisting>systemd-analyze dlopen-metadata <replaceable>binary</replaceable></programlisting> |
| 90 |
|
| 91 |
</refsect1> |
| 92 |
|
| 93 |
<refsect1> |
| 94 |
<title>Examples</title> |
| 95 |
|
| 96 |
<example> |
| 97 |
<title>Single soname</title> |
| 98 |
<programlisting>#include <systemd/sd-dlopen.h> |
| 99 |
|
| 100 |
SD_ELF_NOTE_DLOPEN("XKB", "Keyboard layout support", |
| 101 |
SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, |
| 102 |
"libxkbcommon.so.0");</programlisting> |
| 103 |
</example> |
| 104 |
|
| 105 |
<example> |
| 106 |
<title>Multiple sonames for different library versions</title> |
| 107 |
<programlisting>SD_ELF_NOTE_DLOPEN("crypt", "Support for hashing passwords", |
| 108 |
SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, |
| 109 |
"libcrypt.so.2", "libcrypt.so.1", "libcrypt.so.1.1");</programlisting> |
| 110 |
</example> |
| 111 |
|
| 112 |
</refsect1> |
| 113 |
|
| 114 |
<refsect1> |
| 115 |
<title>Notes</title> |
| 116 |
|
| 117 |
<para>The macros described here are header-only and do not require runtime linkage against |
| 118 |
<citerefentry><refentrytitle>libsystemd</refentrytitle><manvolnum>3</manvolnum></citerefentry>. |
| 119 |
Only the installed header and include path (as provided by |
| 120 |
<command>pkg-config --cflags libsystemd</command>) are needed.</para> |
| 121 |
</refsect1> |
| 122 |
|
| 123 |
<refsect1> |
| 124 |
<title>History</title> |
| 125 |
<para><function>SD_ELF_NOTE_DLOPEN()</function>, |
| 126 |
<function>SD_ELF_NOTE_DLOPEN_VENDOR</function>, |
| 127 |
<function>SD_ELF_NOTE_DLOPEN_TYPE</function>, |
| 128 |
<function>SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED</function>, |
| 129 |
<function>SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED</function>, and |
| 130 |
<function>SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED</function> were added in version 261.</para> |
| 131 |
</refsect1> |
| 132 |
|
| 133 |
<refsect1> |
| 134 |
<title>See Also</title> |
| 135 |
|
| 136 |
<para><simplelist type="inline"> |
| 137 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 138 |
<member><citerefentry><refentrytitle>sd-dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 139 |
<member><citerefentry project='man-pages'><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 140 |
</simplelist></para> |
| 141 |
</refsect1> |
| 142 |
|
| 143 |
</refentry> |