Skip to content

Commit 198598f

Browse files
author
Martin Belanger
committed
libnvme: enforce ABI boundary with -fvisibility=hidden
Add -fvisibility=hidden to the libnvme library build and introduce a LIBNVME_PUBLIC macro (defined as __attribute__((visibility("default"))) in lib-types.h) to explicitly mark each exported function definition. With this change the compiler enforces the ABI boundary rather than relying solely on the linker version scripts (libnvme.ld, libnvmf.ld, accessors.ld). The immediate benefits are: - Any function accidentally omitted from the version script but lacking LIBNVME_PUBLIC will be hidden at compile time, making the omission visible as a link error rather than a silent symbol leak. - nm -D on the installed .so gives an authoritative, minimal symbol list suitable for CI checks and abidiff. The annotation is placed on function *definitions* in the .c files only. Installed public headers are left unannotated so that third-party code that includes them is not exposed to a build-internal attribute. The generate-accessors tool is updated to emit LIBNVME_PUBLIC on the generated function definitions in accessors.c. While auditing the version scripts, 34 stale symbol entries that had no corresponding definition in the source tree were removed from libnvme.ld and libnvmf.ld. Signed-off-by: Martin Belanger <[email protected]>
1 parent cd3c691 commit 198598f

23 files changed

Lines changed: 962 additions & 548 deletions

libnvme/src/libnvme.ld

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ LIBNVME_3 {
5656
nvme_get_ns_attr;
5757
nvme_get_nsid;
5858
nvme_get_path_attr;
59-
nvme_get_property;
6059
nvme_get_subsys_attr;
6160
nvme_get_telemetry_log;
6261
nvme_get_telemetry_max;
@@ -89,13 +88,11 @@ LIBNVME_3 {
8988
nvme_mi_aem_get_next_event;
9089
nvme_mi_aem_process;
9190
nvme_mi_close;
92-
nvme_mi_close_transport_handle;
9391
nvme_mi_control;
9492
nvme_mi_ctrl_id;
9593
nvme_mi_endpoint_desc;
9694
nvme_mi_ep_get_timeout;
9795
nvme_mi_ep_set_timeout;
98-
nvme_mi_first_ctrl;
9996
nvme_mi_first_endpoint;
10097
nvme_mi_init_transport_handle;
10198
nvme_mi_mi_config_get;
@@ -106,7 +103,6 @@ LIBNVME_3 {
106103
nvme_mi_mi_read_mi_data_subsys;
107104
nvme_mi_mi_subsystem_health_status_poll;
108105
nvme_mi_mi_xfer;
109-
nvme_mi_next_ctrl;
110106
nvme_mi_next_endpoint;
111107
nvme_mi_open_mctp;
112108
nvme_mi_scan_ep;
@@ -115,16 +111,13 @@ LIBNVME_3 {
115111
nvme_mi_status_to_string;
116112
nvme_mi_submit_entry;
117113
nvme_mi_submit_exit;
118-
nvme_namespace_attach_ctrls;
119-
nvme_namespace_detach_ctrls;
120114
nvme_filter_namespace;
121115
nvme_namespace_first_path;
122116
nvme_namespace_next_path;
123117
nvme_free_nbft;
124118
nvme_read_nbft;
125119
nvme_next_host;
126120
nvme_next_subsystem;
127-
nvme_ns_attach;
128121
nvme_ns_compare;
129122
nvme_ns_flush;
130123
nvme_ns_get_csi;
@@ -153,7 +146,6 @@ LIBNVME_3 {
153146
nvme_read_config;
154147
nvme_read_key;
155148
nvme_refresh_topology;
156-
nvme_release_fds;
157149
nvme_rescan_ctrl;
158150
nvme_revoke_tls_key;
159151
nvme_scan_ctrl;
@@ -171,9 +163,6 @@ LIBNVME_3 {
171163
nvme_set_ioctl_probing;
172164
nvme_set_keyring;
173165
nvme_set_logging_level;
174-
nvme_set_probe_enabled;
175-
nvme_set_property;
176-
nvme_set_root;
177166
nvme_skip_namespaces;
178167
nvme_status_to_errno;
179168
nvme_status_to_string;

libnvme/src/libnvmf.ld

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,6 @@ LIBNVMF_3 {
2222
nvmf_discovery;
2323
nvmf_discovery_config_file;
2424
nvmf_discovery_config_json;
25-
nvmf_discovery_ctx_already_connected_set;
26-
nvmf_discovery_ctx_connected_set;
27-
nvmf_discovery_ctx_create;
28-
nvmf_discovery_ctx_ctrlkey_set;
29-
nvmf_discovery_ctx_decide_retry_set;
30-
nvmf_discovery_ctx_default_fabrics_config_set;
31-
nvmf_discovery_ctx_device_set;
32-
nvmf_discovery_ctx_discovery_log_set;
33-
nvmf_discovery_ctx_host_iface_set;
34-
nvmf_discovery_ctx_host_traddr_set;
35-
nvmf_discovery_ctx_hostid_set;
36-
nvmf_discovery_ctx_hostkey_set;
37-
nvmf_discovery_ctx_hostnqn_set;
38-
nvmf_discovery_ctx_keep_alive_timeout;
39-
nvmf_discovery_ctx_keyring_set;
40-
nvmf_discovery_ctx_max_retries;
41-
nvmf_discovery_ctx_parser_cleanup_set;
42-
nvmf_discovery_ctx_parser_init_set;
43-
nvmf_discovery_ctx_parser_next_line_set;
44-
nvmf_discovery_ctx_persistent_set;
45-
nvmf_discovery_ctx_subsysnqn_set;
46-
nvmf_discovery_ctx_tls_key_identity_set;
47-
nvmf_discovery_ctx_tls_key_set;
48-
nvmf_discovery_ctx_traddr_set;
49-
nvmf_discovery_ctx_transport_set;
50-
nvmf_discovery_ctx_trsvcid_set;
5125
nvmf_discovery_nbft;
5226
nvmf_eflags_str;
5327
nvmf_exat_ptr_next;

libnvme/src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ libnvme = library(
9696
'nvme', # produces libnvme.so
9797
sources,
9898
version: libnvme_so_version,
99+
c_args: ['-fvisibility=hidden'],
99100
link_args: link_args,
100101
dependencies: deps,
101102
install: true,

0 commit comments

Comments
 (0)