add symbol-versions/
authorStefan Metzmacher <metze@samba.org>
Mon, 23 Apr 2012 08:28:35 +0000 (10:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 23 Apr 2012 08:28:35 +0000 (10:28 +0200)
This shows that upgrades from libraries without symbol versions
to libraries with symbol versions seem to work.

(At least on ubuntu 11.04 amd64)

metze

symbol-versions/Makefile [new file with mode: 0644]
symbol-versions/app.c [new file with mode: 0644]
symbol-versions/lib.c [new file with mode: 0644]

diff --git a/symbol-versions/Makefile b/symbol-versions/Makefile
new file mode 100644 (file)
index 0000000..27c3403
--- /dev/null
@@ -0,0 +1,37 @@
+default: all
+
+CFLAGS=-fPIC
+
+clean:
+       rm -rf *.o *.so* without-version/ with-version/ app
+
+without-version:
+       mkdir -p without-version
+
+without-version/vscript: without-version
+       echo "{ global: *; };" > without-version/vscript
+
+without-version/lib.so.0: lib.o without-version/vscript
+       gcc -shared -o without-version/lib.so.0 -Wl,-soname=lib.so.0 -Wl,--version-script=without-version/vscript lib.o
+
+with-version:
+       mkdir -p with-version
+
+with-version/vscript: with-version
+       echo "LIB_0 { global: *; };" > with-version/vscript
+
+with-version/lib.so.0: lib.o with-version/vscript
+       gcc -shared -o with-version/lib.so.0 -Wl,-soname=lib.so.0 -Wl,--version-script=with-version/vscript lib.o
+
+app: app.o without-version/lib.so.0 with-version/lib.so.0
+       gcc -o app app.o without-version/lib.so.0
+
+show: clean app
+       readelf -a without-version/lib.so.0 |grep lib_function
+       LD_LIBRARY_PATH=without-version/ ldd ./app
+       LD_LIBRARY_PATH=without-version/ ./app
+       readelf -a with-version/lib.so.0 |grep lib_function
+       LD_LIBRARY_PATH=with-version/ ldd ./app
+       LD_LIBRARY_PATH=with-version/ ./app
+
+all: show
diff --git a/symbol-versions/app.c b/symbol-versions/app.c
new file mode 100644 (file)
index 0000000..d916ea5
--- /dev/null
@@ -0,0 +1,7 @@
+
+int main(void)
+{
+       lib_function();
+       return 0;
+}
+
diff --git a/symbol-versions/lib.c b/symbol-versions/lib.c
new file mode 100644 (file)
index 0000000..397b746
--- /dev/null
@@ -0,0 +1,6 @@
+
+void lib_function(void)
+{
+       printf("lib_function\n");
+}
+