950216

This file contributed by Toon Moene (toon@moene.indiv.nluug.nl).

Developers of FORTRAN code on NEXTSTEP (all architectures) have to  
watch out for the following problem when writing programs with  
large, statically allocated (i.e. non-stack based) data structures  
(common blocks, saved arrays).

Due to the way the native loader ('/bin/ld') on NEXTSTEP lays out  
data structures in virtual memory, it is very easy to create an  
executable wherein the '__DATA' segment overlaps (has addresses in  
common) with the 'UNIX STACK' segment.

This leads to all sorts of trouble, from the executable simply 'not  
being executable' to Bus errors. The NEXTSTEP command line tool  
'ebadexec' points to the problem as follows:

% /bin/ebadexec a.out
/bin/ebadexec: __LINKEDIT segment (truncated address = 0x3de000  
rounded size = 0x2a000) of executable file: a.out overlaps with UNIX  
STACK segment (truncated address = 0x400000 rounded size =  
0x3c00000) of executable file: a.out

(in this case it is the '__LINKEDIT' segment which overlaps the  
stack segment). This can be cured by assigning the '__DATA' segment  
(virtual) addresses beyond the stack segment. A conservative  
estimate for this is from address 6000000 (hexadecimal) onwards -  
this has always worked for me [Toon Moene]:

% g77 -segaddr __DATA 6000000 test.f
% ebadexec a.out
ebadexec: file: a.out appears to be executable

Browsing through the Makefile in the f/ directory in your gcc  
distribution, you will find that linking f771 itself also has to be  
done with these flags - it apparently has large statically allocated  
data structures.
