Changing between Large and Small Address Models


Contents

About This Document
About Small and Large Address-Space Models
The Scripts

About this Document

This document describes how to change to the Large Address-Space Model, which may be required for some applications that manipulate large amounts of data. This document applies to all levels of AIX.


About Small and Large Address-Space Models

The RS/6000 divides the address space into sixteen equally sized segments of 256MB. When a program is loaded, by default a single segment is allocated to program text (executable instructions) and a second segment is allocated to program data (heap, stack, and user block).

This arrangement is sufficient for most applications. However, applications that manipulate large amounts of data may require more than one segment for program data. Such allocation is facilitated with the Large Address-Space Model, which is described in InfoExplorer in the article "Large Program Support Overview".

When an application is compiled, the loader stores the maximum data-segment size in the executable file. This value may be changed with the two scripts in the following section. These two scripts modify the executable file header and cause the executable to use the Large Address-Space Model.


The Scripts

For each script, create a file and carefully enter the script text given below. Then put the two files in the system directory where local commands are stored. This directory must be in the $PATH environment variable for the commands to be found. Then make the files executable with the chmod command chmod 555 mksmall mklarge.

To change an executable command from the Small Address-Space Model to the Large Address-Space Model, execute the script mklarge with the name of the file to be modified as the argument. To change an executable command from the Large Address-Space Model to the Small Address-Space Model, execute the command mksmall with the name of the file to be modified as the argument.

For example, to make the gprof command use the large address-space model, execute the command:

   mklarge /usr/ucb/gprof 

This could be reversed with the command:

   mksmall /usr/ucb/gprof 

Note that these commands can only be executed by a user with write permission on the file being changed.

NOTE: Depending on how you are viewing this document, some characters in the following code may appear incorrectly. If the characters in the following list do not match their descriptions, be sure to change them in the code.

[ left bracket
] right bracket
` grave (back tic)

The mklarge Script

#!/bin/ksh 
# 
#   mklarge -- change executable to be "large address-space model" 
# 
if [ $# -ne 1 -o ! -f "${1}"  -o ! -x "${1}" -o ! -w "${1}" ]; then 
   /bin/echo 'usage: mklarge file' 
   exit 1 
fi 
MAGIC=`/bin/dd bs=1 count=2 if=${1} 2>/dev/null` 
TEST=`/bin/echo '\001\0337\c'`
if [ "${MAGIC}" != "${TEST}" ]; then 
   /bin/echo "${1} is not an executable file" 
   exit 1 
fi 
/bin/echo '\0200\0\0\0' | \ 
   /bin/dd of=${1} bs=4 count=1 seek=19 conv=notrunc 2>/dev/null 
exit 0 

The mksmall Script

#!/bin/ksh 
# 
#mksmall -- change executable to be "small address-space model" 
# 
if [ $# -ne 1 -o ! -f "${1}"  -o ! -x "${1}" -o ! -w "${1}" ]; then 
   /bin/echo 'usage: mksmall file' 
   exit 1 
fi 
MAGIC=`/bin/dd bs=1 count=2 if=${1} 2>/dev/null` 
TEST=`/bin/echo '\001\0337\c'` 
if [ "${MAGIC}" != "${TEST}" ]; then 
   /bin/echo "${1} is not an executable file" 
   exit 1 
fi 
/bin/echo '\0\0\0\0' | \ 
   /bin/dd of=${1} bs=4 count=1 seek=19 conv=notrunc 2>/dev/null 
exit 0 


Changing between Large and Small Address Models: large.addr.model.all.lng ITEM: FAX
Dated: 99/01/04~00:00 Category: lng
This HTML file was generated 99/06/24~12:42:08
Comments or suggestions? Contact us