www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/29/05:49:35

From: Dave Hudson <dave AT humbug DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with incremental linking
Date: Fri, 29 Nov 1996 10:08:19 GMT
Organization: Dave's Linux System
Lines: 73
Message-ID: <E1MMtv.7Fy@humbug.demon.co.uk>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I've been trying to port some code I have running under Linux and VSTa to 
build under DJGPP v2.01 and have run into a problem with incremental 
linking of files.  Normally I use a bash script to recurse through a 
number of directories building individual .o files and then incrementally 
linking them into large .o file per directory

The problem I've found is that using "ld" with the "-r" (or "-i") option
seems to add a number of extra symbols under DJGPP, such as
"djgpp_first_dtor".  When these incremental files are then linked, the
link fails with duplicated symbols.  Reading the FAQ I get the impression
that unless I use "-T/djgpp/lib/djgpp.lnk" I shouldn't be getting any
interference from the link file, but I'm wondering if that's what may be
causing my problem? 

I've included a little demonstration of the problem below - this doesn't 
mess about with directories, etc, but if you compare the the output of 
say test1.o and test1r.o (test1.o but incrementally linked) using "nm" 
it's easy to see the problem.

Is this a bug or a feature?  If it's a feature does anyone have a good 
suggestion as to a way around it?


					Regards,
					Dave


----------------------------------------------------------------------------
/*
 * test1.c
 */
extern void test2(void);

void
test1(void)
{
}

void
main(void)
{
	test1();
	test2();
}
----------------------------------------------------------------------------
/*
 * test2.c
 */
void
test2(void)
{
}
----------------------------------------------------------------------------
CC = gcc
CFLAGS = -Wall -fno-strength-reduce

.c.o:
	$(CC) $(CFLAGS) -c -o $*.o $<

all: test1r.o test2r.o
	gcc -o test test1r.o test2r.o

test1r.o: test1.o
	ld -r test1.o -o test1r.o

test2r.o: test2.o
	ld -r test2.o -o test2r.o

clean:
	rm -f *.o
	rm -f *.exe
	rm -f test

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019