This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Incremental Linking
- From: Gerald Rogers <grogers at mail dot ipinfusion dot com>
- To: gcc-help at gnu dot org
- Cc: grogers at ipinfusion dot com
- Date: Mon, 8 Jul 2002 07:31:46 -0400
- Subject: Incremental Linking
- Reply-to: grogers at mail dot ipinfusion dot com
I am seeking help with performing an incremental link which will exclude all
symbols except those I defined in the -retain-symbols-file filename option,
and those which are unresolved.
I have a piece of software which has a common library, and on those systems
which have a flat name space I get name conflicts. I was wanting to link the
library into each module instance which uses the library, and then link all
of the modules into a single application.
As a test, I used the following setup. This failed to exclude those symbols I
did not want in the object.
file 1:
#include "stdlib.h"
int x;
extern int foo();
int func1()
{
foo();
printf("func1 x addr %x, x val %d\n", &x, x);
}
file 2:
#include "stdlib.h"
int x;
extern int foo();
int func2()
{
foo();
printf("func1 x addr %x, x val %d\n", &x, x);
}
file 3:
extern int x;
int foo()
{
x = x + 1;
}
Symbols_file:
func1
func2
In the above files, I performed the following.
gcc -c file1.c
gcc -c file2.c
gcc -c file3.c
ld -r -retain-symbols-file symbol_file file1.0 file3.0 -o file_1.o
The output is a .o which contains all the symbols from file1.c and file3.c .
What I wanted to see was the symbols to contain only the following:
func1 from file1
printf from file1 (unresolved so should be included).
Is there any way to do this with incremental links.
I have managed to link into seperate objects when I did not include unresolved
symbols (i.e. printf) without the -r option, and then link the seperate
objects together. However, when I include printf that means I have to link
against the standard libraries, and I don't want multiple instances of the
standard libraries.
Any help is greatly appreciated.
Thanks,
Gerald Rogers
IP Infusion, Inc.