libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tests on AIX 5


From: Daniel Reed
Subject: Re: tests on AIX 5
Date: Tue, 16 Nov 2004 11:41:10 -0500 (EST)

On 2004-11-16T10:15-0600, Bob Friesenhahn wrote:
) loaded.  If it did locate a symbol from the main exectable, then that
) indicates that symbols from the main executable may be polluting the
) namespace, which could lead to wrong behavior.

This is the case on at least Solaris, Linux, FreeBSD, and OS 10.

As of the summer of 2003, in Cygwin, symbols in the executable were not
available to dynamic libraries, but libraries had one symbol space (even if
they were not linked together, but linked against the executable or dlopened
by the executable). In order to get single-symbol-space behavior, the
executable can be linked as a dynamic library (with main() renamed to
main_stub()), and a stub executable could be linked against that library
(with main() just calling main_stub()).

It may lead to poor design or coding habits, and I do not want to
necessarily contest that first point, but it should not be unexpected, which
appears to be a second point.


(11:31)address@hidden:~/test3> cat main.c
#include <stdio.h>

void    core_dummy(void) {
        printf("core_dummy\n");
}

int     main(void) {
        printf("main\n");
        library_function();

        return(0);
}
(11:31)address@hidden:~/test3> cat library.c
#include <stdio.h>

void    library_function(void) {
        printf("library_function\n");
        core_dummy();
}
(11:32)address@hidden:~/test3> gcc -shared library.c -o library.so
(11:32)address@hidden:~/test3> gcc main.c -o main -L. -Wl,-rpath,. -lrary
(11:32)address@hidden:~/test3> ./main
main
library_function
core_dummy
(11:32)address@hidden:~/test3>

(This works on Cygwin by compiling main.c as ``gcc main.c -Dmain=main_stub
-shared -o libmain.so -L. -Wl,-rpath,. -lrary'' and creating a dummy
executable whose main() just calls main_stup() and links against
libmain.so.)

-- 
Daniel Reed <address@hidden>    http://people.redhat.com/djr/   
http://naim.n.ml.org/
1832 Savior214: that sucks that one day your just gonna die and all that
work you did learning stuff just gets a rm -rf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]