On Fri 2015-01-23 06:03:25 -0500, Holger Levsen wrote:
> Hi Niko,
>
> On Freitag, 23. Januar 2015, Niko Tyni wrote:
>> A quick search indicates that there's no separate namespace for other
>> uname(2) information than the host name and domain name. This suggests
>> that something like http://www.bstern.org/libuname/ is needed. I'm not
>> aware of anything in Debian already that does that. Time for an RFP maybe
>> :)
>
> it builds fine but doesn't work:
>
> jenkins@jenkins:~/u/libuname-1.0.0$ make
> gcc -Wall -Werror -O2 -fPIC -c -o libuname.o libuname.c
> if [ "`uname -s`" = "SunOS" ]; then \
> ld -G -dy -z text -Qn -o libuname.so libuname.o; \
> else \
> ld -shared -fPIC -o libuname.so libuname.o; \
> fi
> jenkins@jenkins:~/u/libuname-1.0.0$ LD_PRELOAD=$PWD/libuname.so
> LIBUNAME='Linux;bar;2.6.15;#1;Mon Feb 37 22:33:44 UTC 2006;i686;unknown'
> uname
> -a
> uname: symbol lookup error: /var/lib/jenkins/u/libuname-1.0.0/libuname.so:
> undefined symbol: dlsym
This is resolved by the attached patch.
--dkg
diff --git a/Makefile b/Makefile
index 7c5fed4..4ecec59 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CFLAGS=-Wall -Werror -O2 -fPIC
##CFLAGS=-Wall -Werror -O2 -fPIC -m64
CC=gcc
-LINUX_LDFLAGS=-shared -fPIC
+LINUX_LDFLAGS=-shared -fPIC -ldl
SOLARIS_LDFLAGS=-G -dy -z text -Qn
.PHONY: all clean
diff --git a/libuname.c b/libuname.c
index 9951b37..66ee5e1 100644
--- a/libuname.c
+++ b/libuname.c
@@ -59,7 +59,7 @@ static void *loadsym(const char *name) {
void _init(void) {
char *envstr = getenv("LIBUNAME");
char *e_uname[U_LAST] = { NULL };
- char *lasts;
+ char *lasts = NULL;
register int i;
if (envstr == NULL) {