home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.help
- Path: sparky!uunet!convex!darwin.sura.net!mlb.semi.harris.com!slopoke!swk
- From: swk@seymour.mlb.semi.harris.com (Song W. Koh)
- Subject: ld -r -d problem after gcc
- Date: 20 Aug 92 17:47:12
- Nntp-Posting-Host: seymour.mlb.semi.harris.com
- Distribution: gnu
- Organization: Harris Corp., Semiconductor Sector, Melbourne, FL
- Sender: news@mlb.semi.harris.com
- Message-ID: <SWK.92Aug20174712@seymour.mlb.semi.harris.com>
- Lines: 76
-
- Here is the problem... I would like to link files s2.c s3.c s4.c into
- one .o file to dynamically load into a running program. But the
- character pointers v1, v2, v3, all point to the same string, "hello".
-
- % gcc -c s2.c
- % gcc -c s3.c
- % gcc -c s4.c
- % ld -r -d s2.o s3.o s4.o -o sl.o
- % gcc s1.c sl.o
- % a.out
- f1/v1: 40b0 22b0 hello
- f2/v2: 40b8 22b0 hello
- f3/v3: 40c0 22b0 hello
-
- % # but if I compile with Sun cc
-
- % cc -c s2.c
- % cc -c s3.c
- % cc -c s4.c
- % ld -r -d s2.o s3.o s4.o -o sl.o
- % cc s1.c sl.o
- % a.out
- f1/v1: 40a8 40b0 hello
- f2/v2: 40d0 40d8 bye
- f3/v3: 40f0 40f8 byebye
-
- Could someone point me to the problem area. Or a test to determine if
- this is a gcc problem or an ld problem.
-
- System facts:
- Sparc IPC
- SunOS Release 4.1.2
- gcc 2.1
-
- file: s1.c ----------------------------------------
-
- main()
- {
- f1();
- }
-
- file: s2.c ----------------------------------------
-
- f1()
- {
- char *v1 = "hello";
- printf("f1/v1: %0x %0x %s\n", &v1, v1, v1);
- f2();
- }
-
- file: s3.c ----------------------------------------
-
- f2()
- {
- static char *v2 = "bye";
- printf("f2/v2: %0x %0x %s\n", &v2, v2, v2);
- f3();
- }
-
- file: s4.c ----------------------------------------
-
- f3()
- {
- static char *v3 = "byebye";
- printf("f3/v3: %0x %0x %s\n", &v3, v3, v3);
- }
-
- --
- ------------------------------------------------------------------------
- Song Koh Harris Semiconductor
- swk@mlb.semi.harris.com MS 62-022
- Voice: (407)-724-7085 P. O Box 883 (US mail)
- Fax: (407)-729-4960 Palm Bay Road (UPS)
- Melbourne, FL 32902-0883
- ------------------------------------------------------------------------
-
-