We’re converting some of our libraries to be shared (this is in 6.1.0 on
an x86) and we’ve run into a serious problem.
It seems like any shared library that uses va_list, etc. (or maybe it’s
vsprintf()) will not be created or linked correctly, such that if an
executable is linked with that shared library it will segmentation fault
before main() is even invoked.
Here is a very simple testcase. Anyone have any ideas?
$ cat logapi.c
#include <stdio.h>
#include <stdarg.h>
int logMsg(const char *fmt, …)
{
int ret;
va_list args;
va_start(args, fmt);
ret = vprintf(fmt, args);
va_end(args);
return ret;
}
$ cat logtest.c
#include <stdio.h>
int main(void)
{
printf(“Hello…\n”);
return 0;
}
$ cat Makefile
CC = gcc -g
all: logtest
liblogapi.so: logapi.o ; $(CC) -shared -o $@ $^
logtest: logtest.o liblogapi.so ; $(CC) -o $@ $^
$ make
gcc -g -c -o logtest.o logtest.c
gcc -g -c -o logapi.o logapi.c
gcc -g -shared -o liblogapi.so logapi.o
gcc -g -o logtest logtest.o liblogapi.so
$ LD_LIBRARY_PATH=. ./logtest
segmentation violation (core dumped)
$ LD_LIBRARY_PATH=. gdb ./logtest
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “–host=x86-pc-nto-qnx --target=ntox86”…
(gdb) run
Starting program: /tmp/./logtest
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0xb032b2db in ?? ()
(gdb) bt
#0 0xb032b2db in ?? ()
#1 0xb032b42b in ?? ()
#2 0xb032a363 in ?? ()
\
Paul D. Smith <pausmith@nortelnetworks.com> HASMAT–HA Software Mthds & Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad Scientist
These are my opinions—Nortel Networks takes no responsibility for them.