build: Generate the map file from the configured ABI Some linkers require the map file definitions to contain only symbols that are present on the linked object, either in the map file or in the sym file we generate from the map file. This is preparatory work to be able to conditionally include symbols in the man and sym files depending on the ABI definitions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
diff --git a/.gitignore b/.gitignore
index 5c3a5ed..a6f6403 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ ChangeLog
*.gcda
*.gcno
*.sym
+*.map
.dirstamp
.deps/
.libs/
diff --git a/src/Makefile.am b/src/Makefile.am
index 6f2325c..1c350b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,7 +28,7 @@ libbsd_la_included_sources = \
CLEANFILES =
EXTRA_DIST = \
- libbsd.map \
+ libbsd.map.in \
libbsd.pc.in \
libbsd-ctor.pc.in \
libbsd-overlay.pc.in \
@@ -53,6 +53,7 @@ endif
EXTRA_libbsd_la_DEPENDENCIES = \
$(libbsd_la_included_sources) \
libbsd.map \
+ libbsd.map.in \
# EOL
libbsd_la_LIBADD = \
$(MD5_LIBS) \
@@ -64,7 +65,7 @@ libbsd_la_LDFLAGS = \
# EOL
if HAVE_LINKER_VERSION_SCRIPT
libbsd_la_LDFLAGS += \
- -Wl,--version-script=$(srcdir)/libbsd.map \
+ -Wl,--version-script=libbsd.map \
# EOL
else
libbsd_la_LDFLAGS += \
@@ -194,12 +195,18 @@ endif
DISTCLEANFILES = \
libbsd.sym \
+ libbsd.map \
# EOL
libbsd_ctor_a_SOURCES = \
setproctitle_ctor.c \
# EOL
+# Generate the library map file with the pre-processor to selectively include
+# symbols depending on the host system, otherwise some linkers might fail.
+libbsd.map: libbsd.map.in
+ $(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -P - <$(srcdir)/libbsd.map.in >$@
+
# Generate a simple libtool symbol export list to be used as a fallback if
# there is no version script support.
libbsd.sym: libbsd.map
diff --git a/src/libbsd.map b/src/libbsd.map
deleted file mode 100644
index 6c61235..0000000
--- a/src/libbsd.map
+++ /dev/null
@@ -1,199 +0,0 @@
-LIBBSD_0.0 {
- global:
- arc4random;
- arc4random_stir;
- arc4random_addrandom;
-
- bsd_getopt;
- optreset;
-
- errc;
- warnc;
- verrc;
- vwarnc;
-
- fgetln;
- fmtcheck;
- heapsort;
- humanize_number;
-
- /* XXX: Already provided by glibc, remove. */
- inet_net_pton;
-
- getprogname;
- setprogname;
-
- strlcpy;
- strlcat;
-
- setmode;
- getmode;
-
- vis;
- strvis;
- strvisx;
- unvis;
- strunvis;
- strunvisx;
-
- /* The following functions are provided via the system libc or libmd
- * implementations. */
- MD5Init;
- MD5Update;
- MD5Pad;
- MD5Final;
- MD5Transform;
- MD5End;
- MD5File;
- MD5FileChunk;
- MD5Data;
-
- local:
- *;
-};
-
-LIBBSD_0.1 {
- strmode;
-
- /* Private symbol, but libkvm uses it. */
- __fdnlist;
- nlist;
-} LIBBSD_0.0;
-
-LIBBSD_0.2 {
- strtonum;
-
- strnvis;
- strnunvis;
-
- dehumanize_number;
-
- readpassphrase;
-
- flopen;
-
- pidfile_open;
- pidfile_write;
- pidfile_close;
- pidfile_remove;
-
- arc4random_buf;
- arc4random_uniform;
-} LIBBSD_0.1;
-
-LIBBSD_0.3 {
- reallocf;
- getpeereid;
-
- mergesort;
- radixsort;
- sradixsort;
-
- fpurge;
-} LIBBSD_0.2;
-
-LIBBSD_0.4 {
- closefrom;
- expand_number;
-} LIBBSD_0.3;
-
-LIBBSD_0.5 {
- fgetwln;
- fparseln;
-
- /* Introduced in 0.2 as a stub, implemented in 0.5. */
- setproctitle;
-
- strnstr;
-
- wcslcat;
- wcslcpy;
-} LIBBSD_0.4;
-
-LIBBSD_0.6 {
- /* Exported to cope with the constructor+dlopen+threads mess. */
- setproctitle_init;
-} LIBBSD_0.5;
-
-LIBBSD_0.7 {
- getbsize;
-
- /* This symbol might not be present on some specific systems, such
- * as musl based ones. It might need to be removed on SOVERSION bump,
- * as it cannot be portabily implemented everywhere. */
- funopen;
-
- reallocarray;
-
- sl_init;
- sl_add;
- sl_free;
- sl_find;
-
- _time32_to_time;
- _time_to_time32;
- _time64_to_time;
- _time_to_time64;
- _time_to_long;
- _long_to_time;
- _time_to_int;
- _int_to_time;
-} LIBBSD_0.6;
-
-LIBBSD_0.8 {
- explicit_bzero;
-} LIBBSD_0.7;
-
-LIBBSD_0.9 {
- flopenat;
-
- pidfile_fileno;
-
- strtoi;
- strtou;
-
- nvis;
- snvis;
- stravis;
- strenvisx;
- strnunvisx;
- strsenvisx;
- strsnvis;
- strsnvisx;
- strsvis;
- strsvisx;
- svis;
-} LIBBSD_0.8;
-
-LIBBSD_0.9.1 {
- /* The strnvis() and strnunvis() symbols changed prototype to match
- * the NetBSD implementation. Provided as versioned nodes in 0.9.1, and
- * exposed here explicitly so that we can redirect at compile-time. */
- strnvis_netbsd;
- strnunvis_netbsd;
-} LIBBSD_0.9;
-
-LIBBSD_0.10.0 {
- /* These BSD extensions are available on GNU systems, but not on other
- * systems such as Windows or musl libc based ones. */
- vwarn;
- vwarnx;
- warn;
- warnx;
- verr;
- verrx;
- err;
- errx;
-} LIBBSD_0.9.1;
-
-LIBBSD_0.11.0 {
- strnvisx;
-
- recallocarray;
- freezero;
-
- gid_from_group;
- group_from_gid;
- uid_from_user;
- user_from_uid;
-} LIBBSD_0.10.0;
diff --git a/src/libbsd.map.in b/src/libbsd.map.in
new file mode 100644
index 0000000..06550ea
--- /dev/null
+++ b/src/libbsd.map.in
@@ -0,0 +1,201 @@
+#include "config.h"
+
+LIBBSD_0.0 {
+ global:
+ arc4random;
+ arc4random_stir;
+ arc4random_addrandom;
+
+ bsd_getopt;
+ optreset;
+
+ errc;
+ warnc;
+ verrc;
+ vwarnc;
+
+ fgetln;
+ fmtcheck;
+ heapsort;
+ humanize_number;
+
+ /* XXX: Already provided by glibc, remove. */
+ inet_net_pton;
+
+ getprogname;
+ setprogname;
+
+ strlcpy;
+ strlcat;
+
+ setmode;
+ getmode;
+
+ vis;
+ strvis;
+ strvisx;
+ unvis;
+ strunvis;
+ strunvisx;
+
+ /* The following functions are provided via the system libc or libmd
+ * implementations. */
+ MD5Init;
+ MD5Update;
+ MD5Pad;
+ MD5Final;
+ MD5Transform;
+ MD5End;
+ MD5File;
+ MD5FileChunk;
+ MD5Data;
+
+ local:
+ *;
+};
+
+LIBBSD_0.1 {
+ strmode;
+
+ /* Private symbol, but libkvm uses it. */
+ __fdnlist;
+ nlist;
+} LIBBSD_0.0;
+
+LIBBSD_0.2 {
+ strtonum;
+
+ strnvis;
+ strnunvis;
+
+ dehumanize_number;
+
+ readpassphrase;
+
+ flopen;
+
+ pidfile_open;
+ pidfile_write;
+ pidfile_close;
+ pidfile_remove;
+
+ arc4random_buf;
+ arc4random_uniform;
+} LIBBSD_0.1;
+
+LIBBSD_0.3 {
+ reallocf;
+ getpeereid;
+
+ mergesort;
+ radixsort;
+ sradixsort;
+
+ fpurge;
+} LIBBSD_0.2;
+
+LIBBSD_0.4 {
+ closefrom;
+ expand_number;
+} LIBBSD_0.3;
+
+LIBBSD_0.5 {
+ fgetwln;
+ fparseln;
+
+ /* Introduced in 0.2 as a stub, implemented in 0.5. */
+ setproctitle;
+
+ strnstr;
+
+ wcslcat;
+ wcslcpy;
+} LIBBSD_0.4;
+
+LIBBSD_0.6 {
+ /* Exported to cope with the constructor+dlopen+threads mess. */
+ setproctitle_init;
+} LIBBSD_0.5;
+
+LIBBSD_0.7 {
+ getbsize;
+
+ /* This symbol might not be present on some specific systems, such
+ * as musl based ones. It might need to be removed on SOVERSION bump,
+ * as it cannot be portabily implemented everywhere. */
+ funopen;
+
+ reallocarray;
+
+ sl_init;
+ sl_add;
+ sl_free;
+ sl_find;
+
+ _time32_to_time;
+ _time_to_time32;
+ _time64_to_time;
+ _time_to_time64;
+ _time_to_long;
+ _long_to_time;
+ _time_to_int;
+ _int_to_time;
+} LIBBSD_0.6;
+
+LIBBSD_0.8 {
+ explicit_bzero;
+} LIBBSD_0.7;
+
+LIBBSD_0.9 {
+ flopenat;
+
+ pidfile_fileno;
+
+ strtoi;
+ strtou;
+
+ nvis;
+ snvis;
+ stravis;
+ strenvisx;
+ strnunvisx;
+ strsenvisx;
+ strsnvis;
+ strsnvisx;
+ strsvis;
+ strsvisx;
+ svis;
+} LIBBSD_0.8;
+
+LIBBSD_0.9.1 {
+ /* The strnvis() and strnunvis() symbols changed prototype to match
+ * the NetBSD implementation. Provided as versioned nodes in 0.9.1, and
+ * exposed here explicitly so that we can redirect at compile-time. */
+ strnvis_netbsd;
+ strnunvis_netbsd;
+} LIBBSD_0.9;
+
+LIBBSD_0.10.0 {
+ /* These BSD extensions are available on GNU systems, but not on other
+ * systems such as Windows or musl libc based ones. */
+ vwarn;
+ vwarnx;
+ warn;
+ warnx;
+ verr;
+ verrx;
+ err;
+ errx;
+} LIBBSD_0.9.1;
+
+LIBBSD_0.11.0 {
+ strnvisx;
+
+ recallocarray;
+ freezero;
+
+ gid_from_group;
+ group_from_gid;
+ uid_from_user;
+ user_from_uid;
+} LIBBSD_0.10.0;