From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 20902 invoked from network); 29 Jun 1998 21:41:00 -0000 Received: from anubis.gsfc.nasa.gov (128.183.126.248) by mail2.redhat.com with SMTP; 29 Jun 1998 21:41:00 -0000 Received: from localhost (miket@localhost) by anubis.gsfc.nasa.gov (8.8.5/8.8.5) with SMTP id RAA13937 for ; Mon, 29 Jun 1998 17:39:48 -0400 Date: Mon, 29 Jun 1998 17:39:48 -0400 (EDT) From: Mike Tripicco To: axp-list@redhat.com Subject: Re: malloc oddity? In-Reply-To: <199806292010.QAA09705@linux01.hlo.dec.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 29 Jun 1998, Jim Paradis wrote: > I'm just curious; why is this a problem? Surely you're not assuming > that malloc'ed memory is contiguous?! Malloc can return you a pointer > anywhere it pleases 8-) The problem relates to some legacy Fortran code I've inherited which allows Fortran to do dynamic memory allocation. The trick involves Fortran handling the offset between the location of a common block set by the Fortran code and the location of the malloc'd memory. That offset is used by Fortran and thus must fit in a 4-byte integer. In this case that's impossible. However, it looks to me like if the GNU linker had an option equivalent to Digital's "-taso" I'd be able to avoid the problem: -taso This option tells the linker that the executable should be loaded in the lower 31-bit addressable virtual address range. The -T and -D options to the ld(1) command can also be used to ensure that the text and data segments addresses, respectively, are loaded into low memory. The -taso option, however, in addition to setting default addresses for text and data segments, also causes shared libraries linked outside the 31-bit address space to be appropriately relocated by the loader. If you specify -taso and also specify text and data segment addresses with -T and -D, those addresses override the -taso default addresses. The -taso option is useful for porting 32-bit programs to the Digital UNIX operating system. I'm not trying to argue whether it's legal for malloc to do this or not. But I do think it's unfortunate (and odd) that it operates this way using Alpha Linux and nowhere else, including x86 Linux or Alphas running Digital Unix... Thanks, Mike