* [PATCH] Add support for referencing specific symbol versions
@ 2016-06-22 15:18 Florian Weimer
2016-07-11 3:23 ` Carlos O'Donell
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2016-06-22 15:18 UTC (permalink / raw)
To: libc-alpha
This is needed for writing tests of compat symbols.
2016-06-22 Florian Weimer <fweimer@redhat.com>
Support linking against compatibility symbols, for use in tests.
* include/libc-symbols.h (symbol_version_reference): New macro.
(symbol_version): Use it.
* include/shlib-compat.h: Unconditionally include <abi-versions.h>.
(compat_symbol): Use compat_symbol_reference.
(compat_symbol_1, compat_symbol_2): Remove.
(compat_symbol_reference, compat_symbol_reference_1)
(compat_symbol_reference_2): New macro. Use
symbol_version_reference.
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 4548e09..c2b499a 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -282,19 +282,28 @@ for linking")
past the last element in SET. */
#define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
+/* Use symbol_version_reference to specify the version a symbol
+ reference should link to. Use symbol_version or
+ default_symbol_version for the definition of a versioned symbol.
+ The difference is that the latter is a no-op in non-shared
+ builds. */
+#ifdef __ASSEMBLER__
+# define symbol_version_reference(real, name, version) \
+ .symver real, name##@##version
+#else /* !__ASSEMBLER__ */
+# define symbol_version_reference(real, name, version) \
+ __asm__ (".symver " #real "," #name "@" #version)
+#endif
+
#ifdef SHARED
# define symbol_version(real, name, version) \
- _symbol_version(real, name, version)
+ symbol_version_reference(real, name, version)
# define default_symbol_version(real, name, version) \
_default_symbol_version(real, name, version)
# ifdef __ASSEMBLER__
-# define _symbol_version(real, name, version) \
- .symver real, name##@##version
# define _default_symbol_version(real, name, version) \
.symver real, name##@##@##version
# else
-# define _symbol_version(real, name, version) \
- __asm__ (".symver " #real "," #name "@" #version)
# define _default_symbol_version(real, name, version) \
__asm__ (".symver " #real "," #name "@@" #version)
# endif
diff --git a/include/shlib-compat.h b/include/shlib-compat.h
index c1c5e2c..025c731 100644
--- a/include/shlib-compat.h
+++ b/include/shlib-compat.h
@@ -19,10 +19,10 @@
#ifndef _SHLIB_COMPAT_H
#define _SHLIB_COMPAT_H 1
-#ifdef SHARED
-
# include <abi-versions.h>
+#ifdef SHARED
+
/* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
code for each library. For a version set that is subsumed by a later
@@ -62,11 +62,7 @@
default_symbol_version (local, symbol, name)
# define compat_symbol(lib, local, symbol, version) \
- compat_symbol_1 (lib, local, symbol, version)
-# define compat_symbol_1(lib, local, symbol, version) \
- compat_symbol_2 (local, symbol, VERSION_##lib##_##version)
-# define compat_symbol_2(local, symbol, name) \
- symbol_version (local, symbol, name)
+ compat_symbol_reference (lib, local, symbol, version)
#else
@@ -82,6 +78,14 @@
#endif
+/* Use compat_symbol_reference for a reference to a specific version
+ of a symbol. Use compat_symbol to define such a symbol. */
+#define compat_symbol_reference(lib, local, symbol, version) \
+ compat_symbol_reference_1 (lib, local, symbol, version)
+#define compat_symbol_reference_1(lib, local, symbol, version) \
+ compat_symbol_reference_2 (local, symbol, VERSION_##lib##_##version)
+#define compat_symbol_reference_2(local, symbol, name) \
+ symbol_version_reference (local, symbol, name)
# ifdef LINK_OBSOLETE_RPC
/* Export the symbol for both static and dynamic linking. */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add support for referencing specific symbol versions
2016-06-22 15:18 [PATCH] Add support for referencing specific symbol versions Florian Weimer
@ 2016-07-11 3:23 ` Carlos O'Donell
2016-07-11 12:00 ` Adhemerval Zanella
0 siblings, 1 reply; 3+ messages in thread
From: Carlos O'Donell @ 2016-07-11 3:23 UTC (permalink / raw)
To: Florian Weimer, libc-alpha
On 06/22/2016 11:18 AM, Florian Weimer wrote:
> This is needed for writing tests of compat symbols.
>
> 2016-06-22 Florian Weimer <fweimer@redhat.com>
>
> Support linking against compatibility symbols, for use in tests.
> * include/libc-symbols.h (symbol_version_reference): New macro.
> (symbol_version): Use it.
> * include/shlib-compat.h: Unconditionally include <abi-versions.h>.
> (compat_symbol): Use compat_symbol_reference.
> (compat_symbol_1, compat_symbol_2): Remove.
> (compat_symbol_reference, compat_symbol_reference_1)
> (compat_symbol_reference_2): New macro. Use
> symbol_version_reference.
This is awesome. Please check this in. I'm happy to see this kind
of compat symbol testing framework go in!
> diff --git a/include/libc-symbols.h b/include/libc-symbols.h
> index 4548e09..c2b499a 100644
> --- a/include/libc-symbols.h
> +++ b/include/libc-symbols.h
> @@ -282,19 +282,28 @@ for linking")
> past the last element in SET. */
> #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
>
> +/* Use symbol_version_reference to specify the version a symbol
> + reference should link to. Use symbol_version or
> + default_symbol_version for the definition of a versioned symbol.
> + The difference is that the latter is a no-op in non-shared
> + builds. */
> +#ifdef __ASSEMBLER__
> +# define symbol_version_reference(real, name, version) \
> + .symver real, name##@##version
> +#else /* !__ASSEMBLER__ */
> +# define symbol_version_reference(real, name, version) \
> + __asm__ (".symver " #real "," #name "@" #version)
> +#endif
OK. Wow. To be honest I was surprised this was
possible. We've always talked about using prebuilt binaries for
testing, but using this to call the compat symbol seems like a
perfect solution for now and much easier. Perhaps we'll never need
anything more.
> +
> #ifdef SHARED
> # define symbol_version(real, name, version) \
> - _symbol_version(real, name, version)
> + symbol_version_reference(real, name, version)
> # define default_symbol_version(real, name, version) \
> _default_symbol_version(real, name, version)
> # ifdef __ASSEMBLER__
> -# define _symbol_version(real, name, version) \
> - .symver real, name##@##version
> # define _default_symbol_version(real, name, version) \
> .symver real, name##@##@##version
> # else
> -# define _symbol_version(real, name, version) \
> - __asm__ (".symver " #real "," #name "@" #version)
> # define _default_symbol_version(real, name, version) \
> __asm__ (".symver " #real "," #name "@@" #version)
> # endif
> diff --git a/include/shlib-compat.h b/include/shlib-compat.h
> index c1c5e2c..025c731 100644
> --- a/include/shlib-compat.h
> +++ b/include/shlib-compat.h
> @@ -19,10 +19,10 @@
> #ifndef _SHLIB_COMPAT_H
> #define _SHLIB_COMPAT_H 1
>
> -#ifdef SHARED
> -
> # include <abi-versions.h>
>
> +#ifdef SHARED
> +
> /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
> symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
> code for each library. For a version set that is subsumed by a later
> @@ -62,11 +62,7 @@
> default_symbol_version (local, symbol, name)
>
> # define compat_symbol(lib, local, symbol, version) \
> - compat_symbol_1 (lib, local, symbol, version)
> -# define compat_symbol_1(lib, local, symbol, version) \
> - compat_symbol_2 (local, symbol, VERSION_##lib##_##version)
> -# define compat_symbol_2(local, symbol, name) \
> - symbol_version (local, symbol, name)
> + compat_symbol_reference (lib, local, symbol, version)
>
> #else
>
> @@ -82,6 +78,14 @@
>
> #endif
>
> +/* Use compat_symbol_reference for a reference to a specific version
> + of a symbol. Use compat_symbol to define such a symbol. */
> +#define compat_symbol_reference(lib, local, symbol, version) \
> + compat_symbol_reference_1 (lib, local, symbol, version)
> +#define compat_symbol_reference_1(lib, local, symbol, version) \
> + compat_symbol_reference_2 (local, symbol, VERSION_##lib##_##version)
> +#define compat_symbol_reference_2(local, symbol, name) \
> + symbol_version_reference (local, symbol, name)
>
> # ifdef LINK_OBSOLETE_RPC
> /* Export the symbol for both static and dynamic linking. */
>
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add support for referencing specific symbol versions
2016-07-11 3:23 ` Carlos O'Donell
@ 2016-07-11 12:00 ` Adhemerval Zanella
0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2016-07-11 12:00 UTC (permalink / raw)
To: libc-alpha
On 11/07/2016 04:23, Carlos O'Donell wrote:
> On 06/22/2016 11:18 AM, Florian Weimer wrote:
>> This is needed for writing tests of compat symbols.
>>
>> 2016-06-22 Florian Weimer <fweimer@redhat.com>
>>
>> Support linking against compatibility symbols, for use in tests.
>> * include/libc-symbols.h (symbol_version_reference): New macro.
>> (symbol_version): Use it.
>> * include/shlib-compat.h: Unconditionally include <abi-versions.h>.
>> (compat_symbol): Use compat_symbol_reference.
>> (compat_symbol_1, compat_symbol_2): Remove.
>> (compat_symbol_reference, compat_symbol_reference_1)
>> (compat_symbol_reference_2): New macro. Use
>> symbol_version_reference.
>
> This is awesome. Please check this in. I'm happy to see this kind
> of compat symbol testing framework go in!
It could be also useful if you add a small snippet oh how to use such
as the one in include/libc-symbols.h:317.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-11 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 15:18 [PATCH] Add support for referencing specific symbol versions Florian Weimer
2016-07-11 3:23 ` Carlos O'Donell
2016-07-11 12:00 ` Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).