[gnu.g++.bug] ld++, problem in layout_ctors_and_dtors

jw@sics.se (Johan Widen) (02/03/89)

	struct relocation_info r1, r2;

in this function will not be completely initialized on any machine where
struct reloclation_info has other fields than those defined on a Sun.

This holds true for example on the Sequent Symmetry. The following patch
appears to fix the problem.

(This is the ld++ distributed with g++-1.32. The line numbers will differ
as I have made other changes.)

*** ld.c.old	Thu Jan 26 16:40:37 1989
--- ld.c	Thu Feb  2 23:48:28 1989
***************
*** 1927,1932
      }
  
    /* Do relocation.  Initialize invariant data.  */
  #if defined(sun) && (TARGET == SUN4)
    r1.r_addend = 0;
    r1.r_type = RELOC_32;

--- 1927,1934 -----
      }
  
    /* Do relocation.  Initialize invariant data.  */
+   bzero(&r1, sizeof(r1));
+   bzero(&r2, sizeof(r2));
  #if defined(sun) && (TARGET == SUN4)
    r1.r_type = RELOC_32;
    r1.r_extern   = 1;
***************
*** 1928,1934
  
    /* Do relocation.  Initialize invariant data.  */
  #if defined(sun) && (TARGET == SUN4)
-   r1.r_addend = 0;
    r1.r_type = RELOC_32;
    r1.r_extern   = 1;
    r2.r_addend = 0;

--- 1930,1935 -----
    bzero(&r1, sizeof(r1));
    bzero(&r2, sizeof(r2));
  #if defined(sun) && (TARGET == SUN4)
    r1.r_type = RELOC_32;
    r1.r_extern   = 1;
    r2.r_type = RELOC_32;
***************
*** 1931,1937
    r1.r_addend = 0;
    r1.r_type = RELOC_32;
    r1.r_extern   = 1;
-   r2.r_addend = 0;
    r2.r_type = RELOC_32;
    r2.r_extern   = 1;
  #else

--- 1932,1937 -----
  #if defined(sun) && (TARGET == SUN4)
    r1.r_type = RELOC_32;
    r1.r_extern   = 1;
    r2.r_type = RELOC_32;
    r2.r_extern   = 1;
  #else
***************
*** 1935,1941
    r2.r_type = RELOC_32;
    r2.r_extern   = 1;
  #else
-   r1.r_pcrel = 0;
    r1.r_length = 2;
    r1.r_extern = 1;
    r2.r_pcrel = 0;

--- 1935,1940 -----
    r2.r_type = RELOC_32;
    r2.r_extern   = 1;
  #else
    r1.r_length = 2;
    r1.r_extern = 1;
    r2.r_length = 2;
***************
*** 1938,1944
    r1.r_pcrel = 0;
    r1.r_length = 2;
    r1.r_extern = 1;
-   r2.r_pcrel = 0;
    r2.r_length = 2;
    r2.r_extern = 1;
  #endif

--- 1937,1942 -----
  #else
    r1.r_length = 2;
    r1.r_extern = 1;
    r2.r_length = 2;
    r2.r_extern = 1;
  #endif
--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30
Internet: jw@sics.se or {mcvax,munnari,ukc,unido}!enea!sics.se!jw