Subject: odd ld behaviour..
To: None <current-users@pain.lcs.mit.edu>
From: Jason Downs <downsj@CSOS.ORST.EDU>
List: current-users
Date: 10/25/1994 16:06:33
recently, i've been having strange problems with ld. namely, it would fall
into an infinite loop while linking.

this doesn't normally happen. in fact, i can only get it to happen when using
certain combinations of X11 libraries.

at line 2333 of ld.c, it attempts to align the value of 'size'. this
usually returns sizeof(int), but on occasion it returns 0. following
this, it bit-wise ands this value with the value of 'align' (which is
sizeof(int)). this always produces 0, since size is 0, and this just so
happens to take place within a while() loop, testing whether size & align
is equal to 0.

since the value of the expression never changes, the loop never exits,
and the linker hangs.

this context diff illustrates the problem, along with how i'm avoiding
it (for now):

*** ld.c.orig	Sun Aug 14 03:47:08 1994
--- ld.c	Tue Oct 25 15:52:49 1994
***************
*** 2211,2217 ****
--- 2211,2221 ----
  {
  	FOR_EACH_SYMBOL(i, sp) {
  		int		size;
+ #ifdef AVOID_BUG
+ 		int		align = 1;
+ #else
  		int             align = sizeof(int);
+ #endif
  
  		if (!(sp->flags & GS_REFERENCED))
  			continue;
***************
*** 2330,2340 ****
  		 * above will have to be initialized to 1 instead of sizeof
  		 * (int).
  		 */
! 
  		size = PALIGN(size, sizeof(int));
  
  		while (!(size & align))
  			align <<= 1;
  
  		align = align > MAX_ALIGNMENT ? MAX_ALIGNMENT : align;
  
--- 2334,2345 ----
  		 * above will have to be initialized to 1 instead of sizeof
  		 * (int).
  		 */
! #ifndef AVOID_BUG
  		size = PALIGN(size, sizeof(int));
  
  		while (!(size & align))
  			align <<= 1;
+ #endif
  
  		align = align > MAX_ALIGNMENT ? MAX_ALIGNMENT : align;
 

has anyone else ever encountered anything like this?

--
                    ----------------------------------------
-------------------// jason downs // downsj@CSOS.ORST.EDU //------------------
                   ----------------------------------------      JD105
    SunOS 4.1.3: An OS with more bugs than NetBSD, and no hope of them ever
				 getting fixed.