On 15 Oct 2001, Niels Möller wrote:
> If the test succeeds, that indicates that you really have
> program_invocation_name. If you don't have it, the test should get
> link errors.

Hmmm, let's look at some test code:

----------tst.c----------
extern char *gargelpu;

int main(void) { return(0); }
----------tst2.c---------
extern char *gargelpu;

int foo(void) { *gargelpu = 'c'; }
-------------------------

robert@callisto:~/tmp ! gcc -c tst.c -o tst.o
robert@callisto:~/tmp ! gcc -c tst2.c -o tst2.o
robert@callisto:~/tmp ! nm -n tst.o tst2.o

tst.o:
00000000 t gcc2_compiled.
00000000 T main

tst2.o:
         U gargelpu
00000000 T foo
00000000 t gcc2_compiled.
robert@callisto:~/tmp ! gcc tst.o tst2.o -o tst
tst2.o: In function `foo':
tst2.o(.text+0x4): undefined reference to `gargelpu'
collect2: ld returned 1 exit status
robert@callisto:~/tmp ! gcc tst.c -o tst
robert@callisto:~/tmp !
--------------------------

The test does what tst.c does. It is possible to compile and link this
stand alone without a problem. Later in the source some tst2.c stuff is
compiled; I get exactly the same situation at the moment with argp.
program_invocation_name is undefined at the moment the linker tries to put
things together.

I assume it works with glibc because the physical variable is somehow
defined "in" glibc and the declarations are just references. But I don't
really understand the reason why.

Robert
-- 
 +--------------------------------------------------------+
 |             Dipl.-Ing. Robert Schwebel                 |
 |      Linux Solutions for Science and Industry          |
 |  Braunschweiger Straße 79, 31134 Hildesheim, Germany   |
 |     Phone: +49-5121-28619-0  Fax: +49-5121-28619-4     |
 +--------------------------------------------------------+


Reply via email to