home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gcc / help / 1964 < prev    next >
Encoding:
Text File  |  1992-08-20  |  2.0 KB  |  89 lines

  1. Newsgroups: gnu.gcc.help
  2. Path: sparky!uunet!convex!darwin.sura.net!mlb.semi.harris.com!slopoke!swk
  3. From: swk@seymour.mlb.semi.harris.com (Song W. Koh)
  4. Subject: ld -r -d problem after gcc
  5. Date: 20 Aug 92 17:47:12
  6. Nntp-Posting-Host: seymour.mlb.semi.harris.com
  7. Distribution: gnu
  8. Organization: Harris Corp., Semiconductor Sector, Melbourne, FL
  9. Sender: news@mlb.semi.harris.com
  10. Message-ID: <SWK.92Aug20174712@seymour.mlb.semi.harris.com>
  11. Lines: 76
  12.  
  13. Here is the problem... I would like to link files s2.c s3.c s4.c into
  14. one .o file to dynamically load into a running program.  But the
  15. character pointers v1, v2, v3, all point to the same string, "hello".
  16.  
  17. % gcc -c s2.c
  18. % gcc -c s3.c
  19. % gcc -c s4.c
  20. % ld -r -d s2.o s3.o s4.o -o sl.o
  21. % gcc s1.c sl.o
  22. % a.out
  23. f1/v1: 40b0 22b0 hello
  24. f2/v2: 40b8 22b0 hello
  25. f3/v3: 40c0 22b0 hello
  26.  
  27. % # but if I compile with Sun cc
  28.  
  29. % cc -c s2.c
  30. % cc -c s3.c
  31. % cc -c s4.c
  32. % ld -r -d s2.o s3.o s4.o -o sl.o
  33. % cc s1.c sl.o
  34. % a.out
  35. f1/v1: 40a8 40b0 hello
  36. f2/v2: 40d0 40d8 bye
  37. f3/v3: 40f0 40f8 byebye
  38.  
  39. Could someone point me to the problem area. Or a test to determine if
  40. this is a gcc problem or an ld problem.  
  41.  
  42. System facts:
  43.     Sparc IPC
  44.     SunOS Release 4.1.2 
  45.     gcc 2.1
  46.  
  47. file: s1.c ----------------------------------------
  48.  
  49. main()
  50. {
  51.   f1();
  52. }
  53.  
  54. file: s2.c ----------------------------------------
  55.  
  56. f1()
  57. {
  58.   char *v1 = "hello";
  59.   printf("f1/v1: %0x %0x %s\n", &v1, v1, v1);
  60.   f2();
  61. }
  62.  
  63. file: s3.c ----------------------------------------
  64.  
  65. f2()
  66. {
  67.   static char *v2 = "bye";
  68.   printf("f2/v2: %0x %0x %s\n", &v2, v2, v2);
  69.   f3();
  70. }
  71.  
  72. file: s4.c ----------------------------------------
  73.  
  74. f3()
  75. {
  76.   static char *v3 = "byebye";
  77.   printf("f3/v3: %0x %0x %s\n", &v3, v3, v3);
  78. }
  79.  
  80. --
  81. ------------------------------------------------------------------------
  82. Song Koh            Harris Semiconductor
  83. swk@mlb.semi.harris.com        MS 62-022
  84. Voice: (407)-724-7085        P. O Box 883 (US mail) 
  85. Fax:   (407)-729-4960        Palm Bay Road (UPS)
  86.                 Melbourne, FL 32902-0883
  87. ------------------------------------------------------------------------
  88.  
  89.