File tree 4 files changed +28
-9
lines changed
shared-library/symbol-version
4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,26 @@ CC := gcc -pedantic-errors -std=c89 -Wall -Wextra
2
2
3
3
.PHONY : all clean run
4
4
5
- main.out : main.o libcirosantilli_a.so
6
- $(CC ) -L' .' main.o -o ' $@' -lcirosantilli_a
5
+ all : main.out main1.out main2.out
7
6
8
- run : main.out
7
+ run : all
9
8
LD_LIBRARY_PATH=. ./main.out
9
+ LD_LIBRARY_PATH=. ./main1.out
10
+ LD_LIBRARY_PATH=. ./main2.out
11
+
12
+ main.out : main.c libcirosantilli_a.so
13
+ $(CC ) -L' .' main.c -o ' $@' -lcirosantilli_a
14
+
15
+ main1.out : main.c libcirosantilli_a.so
16
+ $(CC ) -DV1 -L' .' main.c -o ' $@' -lcirosantilli_a
17
+
18
+ main2.out : main.c libcirosantilli_a.so
19
+ $(CC ) -DV2 -L' .' main.c -o ' $@' -lcirosantilli_a
10
20
11
21
libcirosantilli_a.so : a.o
12
22
$(CC ) -Wl,--version-script,a.map -L' .' -shared a.o -o ' $@'
13
23
14
- % .o : % .c
24
+ libcirosantilli_a .o : a .c
15
25
$(CC ) -fPIC -c ' $<' -o ' $@'
16
26
17
27
clean :
Original file line number Diff line number Diff line change 2
2
3
3
Trying to replicate glibc's ` symbol@@VERSION ` madness.
4
4
5
- TODO: not working, and I have no idea what I'm doing.
5
+ This allows you to have a single library ` v2 ` , that also contains symbols from ` v1 ` .
6
+
7
+ < https://www.technovelty.org/c/symbol-versions-and-dependencies.html > contains a nice example.
Original file line number Diff line number Diff line change 4
4
5
5
__asm__(".symver a1,a@LIBA_1" );
6
6
void a1 (void ) {
7
- puts ("a " );
7
+ puts ("a1 " );
8
8
}
9
9
10
- __asm__(".symver a2,a@LIBA_2" );
10
+ /* @@ means "default version". */
11
+ __asm__(".symver a2,a@@LIBA_2" );
11
12
void a2 (void ) {
12
- puts ("a " );
13
+ puts ("a2 " );
13
14
}
Original file line number Diff line number Diff line change 3
3
4
4
#include "a.h"
5
5
6
- __asm__(".symver a1,a@LIBA_1" );
6
+ /* TODO: any clearer way of doing this maybe
7
+ * with some compilation option only? */
8
+ #if defined(V1 )
9
+ __asm__(".symver a,a@LIBA_1" );
10
+ #elif defined(V2 )
11
+ __asm__(".symver a,a@LIBA_2" );
12
+ #endif
7
13
8
14
int main (void ) {
9
15
a ();
You can’t perform that action at this time.
0 commit comments