HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 33 (of 101)
Chapter 11 Software Development
October 29, 2013
No such limits exist for shared mappings, but of course there is still the address space limit. The
third and fourth quadrants are dedicated to shared data and text, and the size of both quadrants,
reduced by ca. 250 MB in Q4 which are reserved for the kernel, is the only limit. But this is a
system wide limit. If the shared quadrants are full, they are full for all processes on the system.
Beyond The Limits
As shown above, the default limits for 32-bit processes are 1 GB of private and 2 GB of shared
data. But programs might have different requirements, ie. they might need more private data and
less shared memory, or the other way round. Of course, 64-bit programs have no problem with
that, because the quadrants (Q3) have a size of 4 TB each. However, there might be reasons why
an application cannot be built in 64-bit mode, and instead requires a more flexible way of using
the full 4 GB of its 32-bit address space.
HP-UX provides means to change the way how the 4 quadrants can be used by a program, which
shall be explained in the following paragraphs.
Allowing Private Data In Q1
At link time (and only then) you can select the usage of Q1. Per default, ld creates SHARE_MAGIC
executables which make use of the quadrants as described above. They cannot allocate data in
the first quadrant. The address space of this quadrant is lost.
When adding the linker option -N (ie. use Wl,-N in the cc(1) command that calls the linker), it
will create an executable of type EXEC_MAGIC, which means that the first quadrant is used for
both text and data. The heap will start immediately after the program code, thus allowing nearly
2 GB of private data. As a side effect, Q1 must now be writable and thus private, which means
such executables cannot be shared anymore between multiple processes. With this change, the
address space will look like this:
Q1
Q2
Q3
Q4
t
e
x
t
Heap
heap
un-
used
*1
s
t
a
c
k
s
h
m
e
m
un-
used
*2
s
h
l
i
b
un-
used
*2
un-
used
*2
s
h
l
i
b
un-
used
*2
s
h
m
e
m
shmem: shared memory segment
shlib: shared library
*1: can be used to increase the heap or to map private regions
*2: can be used for additional shared memory segments or shared libraries