@@ -10,15 +10,95 @@ binary was compiled.
1010See [ Package Metadata for Core Files] ( https://systemd.io/ELF_PACKAGE_METADATA/ )
1111for the overview and details.
1212
13- The new ` --package-metadata ` option provided by ` bfd ` , ` gold ` , ` mold ` , and ` lld ` is used.
13+ When building binaries, the ` --package-metadata ` option provided by
14+ ` bfd ` , ` gold ` , ` mold ` , and ` lld ` shall be used to inject the metadata
15+ into the binary.
1416
15- It also provides scripts to extract and display ` .note.dlopen ` ELF notes
16- that are used to describe libraries loaded via ` dlopen(3) ` .
17+ ### Displaying package notes
18+
19+ Raw:
20+ ``` console
21+ $ objdump -j .note.package -s /usr/bin/ls
22+
23+ /usr/bin/ls: file format elf64-x86-64
24+
25+ Contents of section .note.package:
26+ 03cc 04000000 7c000000 7e1afeca 46444f00 ....|...~...FDO.
27+ 03dc 7b227479 7065223a 2272706d 222c226e {"type":"rpm","n
28+ 03ec 616d6522 3a22636f 72657574 696c7322 ame":"coreutils"
29+ 03fc 2c227665 7273696f 6e223a22 392e342d ,"version":"9.4-
30+ 040c 372e6663 3430222c 22617263 68697465 7.fc40","archite
31+ 041c 63747572 65223a22 7838365f 3634222c cture":"x86_64",
32+ 042c 226f7343 7065223a 22637065 3a2f6f3a "osCpe":"cpe:/o:
33+ 043c 6665646f 72617072 6f6a6563 743a6665 fedoraproject:fe
34+ 044c 646f7261 3a343022 7d000000 dora:40"}...
35+ ```
36+
37+ Pretty:
38+ ``` console
39+ $ systemd-analyze inspect-elf /usr/bin/ls
40+ path: /usr/bin/ls
41+ elfType: executable
42+ elfArchitecture: AMD x86-64
43+
44+ type: rpm
45+ name: coreutils
46+ version: 9.4-7.fc40
47+ architecture: x86_64
48+ osCpe: cpe:/o:fedoraproject:fedora:40
49+ buildId: 40e5a1570a9d97fc48f5c61cfb7690fec0f872b2
50+ ```
51+
52+ ## ` dlopen() ` metadata
53+
54+ This package also provides scripts to extract and display
55+ ` .note.dlopen ` ELF notes that are used to describe libraries loaded via ` dlopen(3) ` .
1756
1857See [ ` dlopen() ` Metadata for ELF Files] ( https://systemd.io/ELF_DLOPEN_METADATA/ )
1958for the overview and details.
2059
60+ ### Displaying ` dlopen() ` notes
61+
62+ Raw:
63+ ``` console
64+ $ objdump -j .note.dlopen -s /usr/lib64/systemd/libsystemd-shared-257.so
65+
66+ /usr/lib64/systemd/libsystemd-shared-257.so: file format elf64-x86-64
67+
68+ Contents of section .note.dlopen:
69+ 0334 04000000 8e000000 0a0c7c40 46444f00 ..........|@FDO.
70+ 0344 5b7b2266 65617475 7265223a 22627066 [{"feature":"bpf
71+ 0354 222c2264 65736372 69707469 6f6e223a ","description":
72+ 0364 22537570 706f7274 20666972 6577616c "Support firewal
73+ 0374 6c696e67 20616e64 2073616e 64626f78 ling and sandbox
74+ 0384 696e6720 77697468 20425046 222c2270 ing with BPF","p
75+ 0394 72696f72 69747922 3a227375 67676573 riority":"sugges
76+ 03a4 74656422 2c22736f 6e616d65 223a5b22 ted","soname":["
77+ 03b4 6c696262 70662e73 6f2e3122 2c226c69 libbpf.so.1","li
78+ 03c4 62627066 2e736f2e 30225d7d 5d000000 bbpf.so.0"]}]...
79+ 03d4 04000000 9e000000 0a0c7c40 46444f00 ..........|@FDO.
80+ ...
81+ ```
82+
83+ Pretty:
84+ ``` console
85+ $ dlopen-notes /usr/lib64/systemd/libsystemd-shared-257.so
86+ # /usr/lib64/systemd/libsystemd-shared-257.so
87+ [
88+ {
89+ "feature": "bpf",
90+ "description": "Support firewalling and sandboxing with BPF",
91+ "priority": "suggested",
92+ "soname": [
93+ "libbpf.so.1",
94+ "libbpf.so.0"
95+ ]
96+ },
97+ ...
98+ ```
99+
21100## Requirements
22101* binutils (>= 2.39)
23102* mold (>= 1.3.0)
24103* lld (>= 15.0.0)
104+ * python (>= 3.8)
0 commit comments