Subject: Re: bug#10240: GNUstep build fails during dumping

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Thu, 08 Dec 2011 09:57:07 +0900

>>>>> On Wed, 07 Dec 2011 13:06:13 -0500, Glenn Morris <[email-masked]> said:
YAMAMOTO Mitsuharu wrote:

>> Could you show the results of `readelf -S src/temacs' 
>> and `nm -an src/temacs | grep _OBJC_' ?

> Here you go:

> 0000000000c4d071 b _OBJC_ClassName_
> 0000000000c4d29c b _OBJC_ClassName_
> 0000000000c4d2f0 b _OBJC_ClassName_
> 0000000000c4d720 b _OBJC_ClassName_
> 0000000000c4d768 b _OBJC_ClassName_
> 0000000000c4d798 b _OBJC_ClassName_

Probably these symbols whose values are in the .bss section caused the
problem, because the current code assumes such values are in the .data
section.  Could you try the patch at the end of this mail?

> Just to say again: `/bin/pwd`/temacs --batch --load loadup bootstrap
> in isolation works fine, but it fails every time when make calls the
> same command, dumping 40MB of 0s.

Currently I have no idea why such a difference in invocation causes
different results.

				     YAMAMOTO Mitsuharu
				[email-masked]

=== modified file 'src/unexelf.c'
*** src/unexelf.c	2011-11-14 21:00:24 +0000
--- src/unexelf.c	2011-12-08 00:46:29 +0000
***************
*** 1219,1227 ****
  	      nn = symp->st_shndx;
  	      if (nn > old_bss_index)
  		nn--;
! 	      old = ((symp->st_value - NEW_SECTION_H (symp->st_shndx).sh_addr)
! 		     + OLD_SECTION_H (nn).sh_offset + old_base);
! 	      memcpy (new, old, symp->st_size);
  	    }
  #endif
  	}
--- 1219,1233 ----
  	      nn = symp->st_shndx;
  	      if (nn > old_bss_index)
  		nn--;
! 	      if (nn == old_bss_index)
! 		memset (new, 0, symp->st_size);
! 	      else
! 		{
! 		  old = ((symp->st_value
! 			  - NEW_SECTION_H (symp->st_shndx).sh_addr)
! 			 + OLD_SECTION_H (nn).sh_offset + old_base);
! 		  memcpy (new, old, symp->st_size);
! 		}
  	    }
  #endif
  	}