The information contained in this document is subject to change without
notice.
Hewlett-Packard makes no warranty of any kind with regard to this
manual, including, but not limited to, the implied warranties of
merchantability and fitness for a particular purpose. Hewlett-Packard
shall not be liable for errors contained herein or direct, indirect, special,
incidental or consequential damages in connection with the furnishing,
performance, or use of this material.
rights are reserved. Reproduction, adaptation, or translation without
prior written permission is prohibited, except as allowed under the
copyright laws.
Corporate Offices:
Hewlett-Packard Co.
3000 Hanover St.
Palo Alto, CA 94304
Use, duplication or disclosure by the U.S. Government Department of
Defense is subject to restrictions as set forth in paragraph (b)(3)(ii) of the
Rights in Technical Data and Software clause in FAR 52.227-7013.
Rights for non-DOD U.S. Government Departments and Agencies are as
set forth in FAR 52.227-19(c)(1,2).
Use of this manual and flexible disc(s), compact disc(s), or tape
cartridge(s) supplied for this pack is restricted to this product only.
Additional copies of the programs may be made for security and back-up
purposes only. Resale of the programs in their present form or with
alterations, is expressly prohibited.
A copy of the specific warranty terms applicable to your Hewlett-Packard
product and replacement parts can be obtained from your local Sales and
Service Office.
Window System is a trademark of the Massachussetts Institute of
Technology.
MS-DOS and Microsoft are U.S. registered trademarks of Microsoft
Corporation.
OSF/Motif is a trademark of the Open Software Foundation, Inc. in the
U.S. and other countries. Certification for conformance with OSF/Motif
user environment pending.
• Chapter 1, “What's New in Recent Releases,” lists new features added
in recent releases.
• Chapter 2, “What Happens When You Compile and Link a Program,”
provides details on compiling and linking programs.
• Chapter 3, “Linker Tasks,” lists many ways you can specify how you
want your program linked.
• Chapter 4, “Linker Tools,” list the tools available in the linker toolset.
• Chapter 5, “Creating and Using Libraries,” discusses all aspects of
both archive and shared libraries.
• Chapter 6, “Shared Library Management Routines,” explains how to
explicitly load libraries at run time using shared library management
routines.
• Chapter 7, “Position-Independent Code,” describes how to write
position-independent assembly code.
• Chapter 8, “W a ys to Improve Performance, ” discusses several w a ys to
optimize your program.
• Appendix A, “Using Mapfiles,” describes mapfiles.
• Glossary contains definitions of important terms in this manual.
Printing History
New editions of this manual will incorporate all material updated since
the previous edition. The manual printing date and part number indicate
its current edition. The printing date changes when a new edition is
printed. The manual part number changes when extensive technical
changes are incorporated.
• November 1997, Edition 1, part number B2355-90655. This manual
supersedes HP-UX Linker and Libraries User’s Guide part number
B2355-90655. The main reason for this new edition is to document
new functionality for the HP-UX 11.00 release:
15
• Add the +ee linker option to export symbols.
• Add 64-bit linker toolset support for linker options.
• Add 64-bit mode linker tools and describe the enhancements to the
32-bit mode toolset.
• Describe 32-bit and 64-bit mode behavior differences.
• Add the dl* shared library management routines for 64-bit mode
support and describe enhancement to the shl_load routines for
shared libraries.
• Add init/fini style initializers for 64-bit mode support for shared
libraries.
• Add the BIND_BREADTH_FIRST flag to the shl_load routine to
control search path behavior.
• Add description of support for ELF object file format.
• April 1997, Edition 1, part number B2355-90654. This manual
supersedes Programming on HP-UX part number B2355-90652. The
main reason for this new edition is to document new functionality for
the HP-UX 10.30 release:
• Announce linker thread-safe features for ld, dld.sl, crt0.o,
and libdld.sl.
• Add the +pd size linker option to set the virtual memory page size
for program data.
• Add the +pi size linker option to set the virtual memory page size
for program instructions.
• Add the +k linker option (see ld(1)) to only create an executable if
no errors are found at link time.
• Add the chatr +k option to enable or disable kernel-assisted
branch prediction.
• Add the chatr +pd size and +pi size virtual memory page setting
options.
16
• July 1996, Edition 1, part number B2355-90653. This manual
supersedes Programming on HP-UX part number B2355-90652. The
main reason for this new edition is to document new functionality for
the HP-UX 10.20 release and to describe what's ahead in a future
release of the linker toolset:
• Add a -B symbolic option to help improve shared library
performance.
• Introduce the fastbind tool to improve the start up time of
programs that use shared libraries.
• Introduce the Linker and Libraries Online User Guide.
• Announce changes in PA-RISC hardw are compatibility—PA-RISC
1.1 systems, by default, generate PA-RISC 1.1 code; PA-RISC 2.0
systems generate 2.0 code.
• Describe compatibility warnings generated by the linker and
dynamic loader for HP 9000 architecture issues and linker toolset
features that may change in a future release.
• Describe what's changing in a future release of the linker toolset.
• Add the +Ostaticprediction option to use with profile-based
optimization.
• January 1995, Edition 1, part number B2355-90652. This manual
supersedes Programming on HP-UX part number B2355-90026. The
main reason for this new edition is to document new functionality for
the HP-UX 10.0 release:
• Update path names to reflect the new System V Release 4 file
system. Some of the changes are:
• Most files in /lib are now in /usr/lib.
• Most optional products are in /opt. For example, HP C is in
/opt/ansic, HP C is in /opt/CC, HP FORTRAN/9000 is in
/opt/fortran, and HP/DDE is in /opt/langtools/dde.
• Caution against mixing shared and archive libraries.
• Describe a new library-level versioning scheme for shared
libraries.
• Update the chapter on profile-based optimization.
• Describe changes in optimization levels 3 and 4.
17
• Describe thread-safe interfaces shl_get_r and
shl_gethandle_r.
• Add a new BIND_TOGETHER flag to the shl_load routine.
• Add a new chapter "Porting Applications to HP-UX."
18
What's New in Recent Releases
1What's New in Recent Releases
This section contains information about recent releases of the HP-UX
linker toolset:
For This Release
The HP-UX 11.00 linker toolset contains new features:
If you use the 32-bit mode linker toolset, see the following items:
• “PA-RISC Changes in Hardware Compatibility” updated in this
chapter.
• “Exporting Symbols with +ee” on page 81.
• “Changes in Future Releases” updated in this chapter.
If you use the 64-bit mode linker toolset, see the following items:
• “PA-RISC Changes in Hardware Compatibility” updated in this
chapter.
• “64-bit Mode Linker Toolset Compatibility with De Facto Industry
Standards” described in this chapter.
• “64-bit Mode ELF Object File Format” described in this chapter.
• “Dynamic Path Searching for Shared Libraries” on page 177
describes differences in the run time searching of shared libraries.
• “Shared Library Symbol Binding Semantics” on page 178 describes
differences in shared library binding semantics.
• New 64-bit mode linker options, symbols, and features, described
in“New Features for 64-bit Mode Linking” in this chapter.
• Unsupported 32-bit mode features, behavior, and linker options,
described in “64-bit Mode Link-time Differences” and“64-bit Mode
Run Time Differences” in this chapter.
• “64-bit Mode Initializers” on page 210 describes the init/fini support
for 64-bit mode shared libraries.
Chapter 119
What's New in Recent Releases
• “The dlopen Shared Library Management Routines” on page 240
describes the dl* family of shared library management routines for
64-bit mode.
• “BIND_BREADTH_FIRST Modifier” on page 222 describes the flag
added to the shl_load routine to modify search behavior.
• “Changes in Future Releases” updated in this chapter.
For Previous Releases
The following items were added in the HP-UX 10.30 release:
• “Linker Thread-Safe Features” on page 50.
• “Options to Improve TLB Hit Rates” on page 273.
• The +k linker option (see ld(1)) to remove an executable if the link
fails.
• The +k chatr option (see chatr(1)) to improve branch prediction on
PA-RISC 2.0.
The following items were added in the HP-UX 10.20 release:
• “Improving Shared Library Performance with -B symbolic” on page
60.
• “Improving Shared Library Start-Up Time with fastbind” on page
293.
• “Online Help for Linker and Libraries” described in this chapter.
• “PA-RISC Changes in Hardware Compatibility” described in this
chapter.
• “Linker Compatibility Warnings” on page 99.
• “Dynamic Loader Compatibility Warnings” on page 256.
• The +Ostaticprediction linker option described in the ld(1) man
page to use with profile-based optimization
20Chapter 1
What's New in Recent Releases
PA-RISC Changes in Hardware Compatibility
PA-RISC Changes in Hardware
Compatibility
The HP-UX 10.20 release introduced HP 9000 systems based on the
PA-RISC 2.0 architecture. Also, beginning with that release, HP
compilers by default generate executable code for the PA-RISC
architecture of the machine on which you are compiling.
In previous releases, the compilers generated PA-RISC 1.0 code on all
HP 9000 Series 800 servers and PA-RISC 1.1 code on Series 700
workstations. HP compilers now by default generate PA-RISC 1.1 code
on 1.1 systems and 2.0 code on 2.0 systems.
Using the +DAportable compiler option provides compatibility of code
between PA-RISC 1.1 and 2.0 systems. Note that the HP-UX 10.10
release is the last supported release for PA-RISC 1.0 systems, so code
generated by the HP-UX 10.20 release of HP compilers is not supported
on PA-RISC 1.0 systems.
NOTEThe +DA1.0 option will be obsolete in a future release. You can achieve
better performance on PA-RISC 1.1 and 2.0 systems by not using this
option.
PA-RISC 2.0 Compatibility
The instruction set on PA-RISC 2.0 is a superset of the instruction set on
PA-RISC 1.1. As a result, code generated for PA-RISC 1.1 systems will
run on PA-RISC 2.0 systems. However, code generated for PA-RISC 2.0
systems will not run on P A-RISC 1.1 or 1.0. The linker issues a hardw are
compatibility warning whenever it links in any PA-RISC 2.0 object files:
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file
(sum.o) was detected. The linked output may not run on PA 1.x
system.
If you try to run a PA-RISC 2.0 program on a 1.1 system, you'll see a
message like:
$ a.out
ksh: ./a.out: Executable file incompatible with hardware
Chapter 121
What's New in Recent Releases
PA-RISC Changes in Hardware Compatibility
In this example, the +DAportable compiler option can be used to create
code compatible for PA-RISC 1.1 and 2.0 systems.
PA-RISC Architectures and Their System
Models
The HP 9000 PA-RISC (Precision Architecture Reduced Instruction Set
Computing) Series 700/800 family of workstations and servers has
evolved from three versions of PA-RISC:
PA-RISC 1.0The original version of PA-RISC first introduced on
Series 800 servers. The following Series are included:
840, 825, 835/SE, 845/SE, 850, 855, 860, 865, 870/x00,
822, 832, 842, 852, 890, 808, 815, 635, 645.
PA-RISC 1.1The second version of PA-RISC first introduced on
Series 700 workstations. Newer Series 800 systems
also use this version of the architecture. The following
Series are included: 700, 705, 710, 715, 720, 725, 730,
735, 750, 755, B132L, B160L, B132L+, B180L, C100,
C110, J200, J210, J210XC, 742i, 742rt, 743i, 743rt,
745i, 747i, 748i, 8x7, D (except Dx70, Dx80), E, F, G, H,
I, K (except Kx50, Kx60, Kx70), T500, T520.
PA-RISC 2.0The newest version of PA-RISC. The following Series
• See your compiler online help or documentation for details on the +DA
option.
• See the file /opt/langtools/lib/sched.models for a complete
list of model numbers and their architectures. Use the command
model to determine the model number of your system.
22Chapter 1
What's New in Recent Releases
64-bit Mode Linker Toolset Compatibility with De Facto Industry Standards
64-bit Mode Linker Toolset
Compatibility with De Facto Industry
Standards
The 64-bit mode linker and dynamic loader provide linking and loading
behaviors found widely across the Unix industry, considered, with the
SVR4 standards, to define the de facto industry standards. The following
64-bit linker behavior is compliant with de facto industry standard:
• ELF object file format and libelf(3x) routines
• Dynamic path searching
• Library-level versioning
• dl* family of dynamic loading routines
• Breadth-first symbol searching
The HP-UX 11.00 release maintains certain behaviors to make
transition from 32-bit to 64-bit mode easier:
• Creation of default run-time path environment variable (RPATH) if no
ld +b is seen on the link line, to improve transition from the 32-bit
mode linker.
•ld +compat option for compatibility with 32-bit linking and loading
behavior.
Chapter 123
What's New in Recent Releases
64-bit Mode ELF Object File Format
64-bit Mode ELF Object File Format
Starting with HP-UX release 11.00, the 64-bit linker toolset supports the
ELF (executable and linking format) object file format. The 64-bit linker
toolset provides new tools to display and manipulate ELF files. The
libelf(3x) library routines provide access to ELF files. The command
elfdump(1) displays contents of an ELF file.
The following options instruct the compiler to generate 64-bit ELF object
code.
OptionCompiler
+DA2.0WC and aC++
+DD64C
See the HP-UX Software Transition Toolkit (STK) at
http://www.software.hp.com/STK/ for more information on the
structure of ELF object files.
24Chapter 1
What's New in Recent Releases
New Features for 64-bit Mode Linking
New Features for 64-bit Mode Linking
This section introduces new features of the 64-bit linker for HP-UX
release 11.00.
64-bit Mode Linker Options
The ld(1) command supports the following new options in 64-bit mode:
OptionAction
-dynamicForces the linker to create a shared
executable. The linker looks for shared
libraries first and then archived libraries.
This option is on by default when you
compile in 64-bit mode.
-nosharedForces the linker to create a fully bound
archive program.
-k filenameAllows you to control the mapping of input
section in the object file to segments in the
output file.
+[no]allowunsatsInstructs the linker how to report errors for
output files with unsatisfied symbols.
+compatInstruct the linker to use 32-bit mode
linking and dynamic loading behaviors.
+[no]forceloadEnables/disables forced loading of all the
object files from archive libraries.
+hideallsymbols
+nodefaultmapInstructs the linker not to load the default
Chapter 125
Hides all symbols from being exported.
mapfile. See the -k option.
a
a
a
What's New in Recent Releases
New Features for 64-bit Mode Linking
OptionAction
+noenvvarInstructs the dynamic loader not to look at
the LD_LIBRARY_PATH and SHLIB_PATH
environment variables at runtime.
a
+stdInstructs the linker to use SVR4 compatible
linking and loading behaviors. Default for
64-bit mode.
a
+stripunwindInstructs the linker not to output the
unwind table.
+vtype typeProduces verbose output about selected link
operations.
a
a. The linker accepts but ignores this option in 32-bit mode. It
creates an executable (a.out).
64-bit Mode Linker-defined Symbols
The 64-bit linker reserves the following symbol names:
SymbolDefinition
__SYSTEM_IDLargest architecture revision level used by
any compilation unit
_FPU_STATUS Initial value of FPU status register
_endAddress of first byte following the end of the
main program’s data segment; identifies the
beginning of the heap segment
__TLS_SIZESize of the Thread Local Storage segment
required by the program
__text_startBeginning of the text segment
_etextEnd of the text segment
__data_startBeginning of the data segment
26Chapter 1
What's New in Recent Releases
New Features for 64-bit Mode Linking
SymbolDefinition
_edataEnd of initialized data
__gpGlobal pointer value
__init_startBeginning of the .init section
__init_endEnd of the .init section
__fini_startBeginning of the .fini section
__fini_endEnd of the .fini section
__unwind_startBeginning of the unwind table
__unwind_endEnd of the unwind table
NOTEThe linker generates an error if a user application also defines these
symbols.
Chapter 127
What's New in Recent Releases
64-bit Mode Link-time Differences
64-bit Mode Link-time Differences
The 64-bit mode linker toolset does not support the following 32-bit mode
features.
Option or
Behavior
-A nameSpecifies incremental loading. 64-bit applications
must use shared libraries instead.
-C nDoes parameter type checking. This option is
unsupported.
-SGenerates an initial program loader header file.
This option is unsupported.
-TSave data and relocation information in temporary
files to reduce virtual memory requirements during
linking. This option is unsupported.
-q, -Q, -nGenerates an executable with file type
DEMAND_MAGIC, EXEC_MAGIC, and SHARE_MAGIC
respectively. These options have no effect and are
ignored in 64-bit mode.
-NCauses the data segment to be placed immediately
after the text segment. This option is accepted but
ignored in 64-bit mode. If this option is used
because your application data segment is large,
then the option is no longer needed in 64-bit mode.
If this option is used because your program is used
in an embedded system or other specialized
application, consider using mapfile support with
the -k option.
Description
+cg pathnameSpecifies pathname for compiling I-SOMs to SOMs.
which have been removed due to dead procedure
elimination. Use the -v linker option instead.
Intra-library
versioning
Duplicate code
and data
symbols
All internal
and
undocumented
linker options
For more information, see the HP-UX Linker and Libraries Online UserGuide (ld +help).
Specified by using the HP_SHLIB_VERSION pragma
(C and aC++) or SHLIB_VERSION directive
(Fortran90).
In 32-bit mode, the linker lets you version your
library by object files. 64-bit applications must use
SVR4 library-level versioning instead.
Code and data cannot share the same namespace in
64-bit mode. You should rename the conflicting
symbols.
These options are unsupported.
Description
Chapter 129
What's New in Recent Releases
64-bit Mode Run Time Differences
64-bit Mode Run Time Differences
Applications compiled and linked in 64-bit mode use a run-time dynamic
loading model similar to other SVR4 systems. There are two main areas
where program startup changes in 64-bit mode:
• Dynamic path searching for shared libraries.
• Symbol searching in dependent libraries.
It is recommended that you use the standard SVR4 linking option
(+std), which is on by default when linking 64-bit applications. There
may be circumstances while you transition, that you need 32-bit
compatible linking behavior. The 64-bit linker provides the +compat
option to force the linker to use 32-bit linking and dynamic loading
behavior.
The following table summarizes the dynamic loader differences between
32-bit and 64-bit mode:
Linker and Loader
Functions
+s and +b path_list
ordering
32-bit Mode Behavior64-bit Mode Behavior
Ordering is significant.Ordering is insignificant by default.
Use +compat to enforce ordering.
30Chapter 1
Loading...
+ 303 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.