mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-08 11:02:24 +01:00
build: Abstract symbol versioning via new libbsd_symver_* macros
This makes it more obvious what they are doing. It will make it easier to make these directives more portable, as they are really ELF specific.
This commit is contained in:
parent
b0ebb0d4c2
commit
890699a78b
@ -30,4 +30,11 @@
|
||||
#define libbsd_link_warning(symbol, msg) \
|
||||
static const char libbsd_emit_link_warning_##symbol[] \
|
||||
__attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
|
||||
|
||||
#define libbsd_symver_default(alias, symbol, version) \
|
||||
__asm__(".symver " #symbol "," #alias "@@" #version)
|
||||
|
||||
#define libbsd_symver_variant(alias, symbol, version) \
|
||||
__asm__(".symver " #symbol "," #alias "@" #version)
|
||||
|
||||
#endif
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "local-link.h"
|
||||
|
||||
static struct {
|
||||
/* Original value. */
|
||||
@ -280,7 +281,7 @@ setproctitle_impl(const char *fmt, ...)
|
||||
*++nul = '\0';
|
||||
}
|
||||
}
|
||||
__asm__(".symver setproctitle_impl,setproctitle@@LIBBSD_0.5");
|
||||
libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5);
|
||||
|
||||
/* The original function introduced in 0.2 was a stub, it only got implemented
|
||||
* in 0.5, make the implementation available in the old version as an alias
|
||||
@ -295,4 +296,4 @@ void
|
||||
setproctitle_stub(const char *fmt, ...)
|
||||
__attribute__((__alias__("setproctitle_impl")));
|
||||
#endif
|
||||
__asm__(".symver setproctitle_stub,setproctitle@LIBBSD_0.2");
|
||||
libbsd_symver_variant(setproctitle, setproctitle_stub, LIBBSD_0.2);
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include <vis.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include "local-link.h"
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(strnunvisx,_strnunvisx)
|
||||
#endif
|
||||
@ -566,11 +568,11 @@ strnunvis_openbsd(char *dst, const char *src, size_t dlen)
|
||||
{
|
||||
return strnunvisx(dst, dlen, src, 0);
|
||||
}
|
||||
__asm__(".symver strnunvis_openbsd,strnunvis@@LIBBSD_0.2");
|
||||
libbsd_symver_default(strnunvis, strnunvis_openbsd, LIBBSD_0.2);
|
||||
|
||||
int
|
||||
strnunvis_netbsd(char *dst, size_t dlen, const char *src)
|
||||
{
|
||||
return strnunvisx(dst, dlen, src, 0);
|
||||
}
|
||||
__asm__(".symver strnunvis_netbsd,strnunvis@LIBBSD_0.9.1");
|
||||
libbsd_symver_variant(strnunvis, strnunvis_netbsd, LIBBSD_0.9.1);
|
||||
|
@ -77,6 +77,8 @@ __weak_alias(strvisx,_strvisx)
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "local-link.h"
|
||||
|
||||
#define _DIAGASSERT(x)
|
||||
|
||||
/*
|
||||
@ -735,14 +737,14 @@ strnvis_openbsd(char *mbdst, const char *mbsrc, size_t dlen, int flags)
|
||||
{
|
||||
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
|
||||
}
|
||||
__asm__(".symver strnvis_openbsd,strnvis@@LIBBSD_0.2");
|
||||
libbsd_symver_default(strnvis, strnvis_openbsd, LIBBSD_0.2);
|
||||
|
||||
int
|
||||
strnvis_netbsd(char *mbdst, size_t dlen, const char *mbsrc, int flags)
|
||||
{
|
||||
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
|
||||
}
|
||||
__asm__(".symver strnvis_netbsd,strnvis@LIBBSD_0.9.1");
|
||||
libbsd_symver_variant(strnvis, strnvis_netbsd, LIBBSD_0.9.1);
|
||||
|
||||
int
|
||||
stravis(char **mbdstp, const char *mbsrc, int flags)
|
||||
|
Loading…
Reference in New Issue
Block a user