Kenwood HP 9000 User manual

  • Hello! I am an AI chatbot trained to assist you with the Kenwood HP 9000 User manual. I’ve already reviewed the document and can help you find the information you need or explain it in simple terms. Just ask your questions, and providing more details will help me assist you more effectively!
HP-UX Linker and Libraries User's Guide
HP 9000 Computers
B2355-90655
November 1997
© Copyright 1997 Hewlett-Packard Company. All rights reserved.
2
Legal Notices
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.
Copyright © 1997 Hewlett-Packard Company.
This document contains information which is protected by copyright. All
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.
© Copyright 1980, 1984, 1986 AT&T Technologies, Inc. UNIX and
System V are registered trademarks of AT&T in the USA and other
countries.
3
UNIX is a registered trademark in the United States and other
countries, licensed exclusively through X/Open Company Limited.
© Copyright 1979, 1980, 1983, 1985-1990 Regents of the University of
California. This software is based in part on the Fourth Berkeley
Software Distribution under license from the Regents of the University
of California.
Copyright © The Regents of the University of Colorado, a body corporate
1979
This document has been reproduced and modified with the permission of
the Regents of the University of Colorado, a body corporate.
PostScript is a trademark of Adobe Systems, Inc.
Intel is a registered trademark and Intel 80386 is a trademark of Intel
Corporation.
Ethernet is a trademark of Xerox Corporation.
© Copyright 1985-1986, 1988 Massachussetts Institute of Technology. X
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.
4
Contents
5
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Printing History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
1. What's New in Recent Releases
PA-RISC Changes in Hardware Compatibility . . . . . . . . . . . . . . . . . . . .21
PA-RISC 2.0 Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
PA-RISC Architectures and Their System Models. . . . . . . . . . . . . . . .22
64-bit Mode Linker Toolset Compatibility with De Facto Industry
Standards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
64-bit Mode ELF Object File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
New Features for 64-bit Mode Linking. . . . . . . . . . . . . . . . . . . . . . . . . . .25
64-bit Mode Linker Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
64-bit Mode Linker-defined Symbols. . . . . . . . . . . . . . . . . . . . . . . . . . .26
64-bit Mode Link-time Differences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
64-bit Mode Run Time Differences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
Changes in Future Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Online Help for Linker and Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Accessing Help with ld +help. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Accessing Help with the HP CDE Front Panel. . . . . . . . . . . . . . . . . . .33
Accessing Help with the dthelpview Command . . . . . . . . . . . . . . . . . .33
Accessing Help with the charhelp Command. . . . . . . . . . . . . . . . . . . .33
2. What Happens When You Compile and Link a Program
Compiling Programs on HP-UX:
An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Looking “inside” a Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
What is an Object File? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
Local Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
6
Contents
Global Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
External References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Compiler-Linker Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Linking Programs on HP-UX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The crt0.o Startup File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
The a.out File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Linking with Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Library Naming Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Default Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
The Default Library Search Path. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Link Order. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Running the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Loading Programs: exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Binding Routines to a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Deferred Binding is the Default. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Linker Thread-Safe Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3. Linker Tasks
Using the Compiler to Link. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Changing the Default Library Search Path with -Wl, -L . . . . . . . . . . 53
Getting Verbose Output with -v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Passing Linker Options from the Compiler Command with -Wl . . . . 54
Renaming the Output File with -o. . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Specifying Libraries with -l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Suppressing the Link-Edit Phase with -c . . . . . . . . . . . . . . . . . . . . . . 55
Using Linker commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Linking with the 32-bit crt0.o Startup File. . . . . . . . . . . . . . . . . . . . . 57
Changing the Default Library Search Path with -L and LPATH. . . . 57
Contents
7
Changing the Default Shared Library Binding with -B. . . . . . . . . . . .58
Improving Shared Library Performance with -B symbolic . . . . . . . . .60
Choosing Archive or Shared Libraries with -a . . . . . . . . . . . . . . . . . . .63
Dynamic Linking with -A and -R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Exporting Symbols with +e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Exporting Symbols with +ee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
Exporting Symbols from main with -E . . . . . . . . . . . . . . . . . . . . . . . . .81
Hiding Symbols with -h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
Moving Libraries after Linking with +b . . . . . . . . . . . . . . . . . . . . . . . .84
Moving Libraries After Linking with +s and SHLIB_PATH. . . . . . . .86
Passing Linker Options in a file with -c . . . . . . . . . . . . . . . . . . . . . . . .86
Passing Linker Options with LDOPTS. . . . . . . . . . . . . . . . . . . . . . . . .87
Specifying Libraries with -l and l:. . . . . . . . . . . . . . . . . . . . . . . . . . . . .87
Stripping Symbol Table Information from the Output File with -s and
-x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89
Using 64-bit Mode Linker Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Using the 64-bit Mode Linker with +compat or +std. . . . . . . . . . . . . .90
Linking Shared Libraries with -dynamic . . . . . . . . . . . . . . . . . . . . . . .93
Linking Archived Libraries with -noshared . . . . . . . . . . . . . . . . . . . . .93
Controlling Archive Library Loading with +[no]forceload. . . . . . . . . .93
Flagging Unsatisfied Symbols with +[no]allowunsats. . . . . . . . . . . . .94
Hiding Symbols from export with +hideallsymbols . . . . . . . . . . . . . . .95
Changing Mapfiles with -k and +nodefaultmap. . . . . . . . . . . . . . . . . .95
Ignoring Dynamic Path Environment Variables with +noenvvar. . . .96
Linking in 64-bit Mode with +std . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Linking in 32-bit Mode Style with +compat . . . . . . . . . . . . . . . . . . . . .96
Controlling Output from the Unwind Table with +stripwind . . . . . . .96
Selecting Verbose Output with +vtype . . . . . . . . . . . . . . . . . . . . . . . . .97
Linking with the 64-bit crt0.o Startup File . . . . . . . . . . . . . . . . . . . . .98
Linker Compatibility Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
Linking to Archive Libraries with Unsatisfied Symbols . . . . . . . . . .100
8
Contents
4. Linker Tools
Changing a Program's Attributes with chatr(1). . . . . . . . . . . . . . . . . . 104
Using chatr for 32-bit Program Attributes . . . . . . . . . . . . . . . . . . . . 104
Using chatr for 64-bit Program Attributes . . . . . . . . . . . . . . . . . . . . 105
Viewing Symbols in an Object file with nm(1) . . . . . . . . . . . . . . . . . . . 107
Viewing the Contents of an Object File with elfdump(1). . . . . . . . . . . 111
Viewing library dependencies with ldd(1). . . . . . . . . . . . . . . . . . . . . . . 113
Viewing the Size of Object File Elements with size(1). . . . . . . . . . . . . 115
Reducing Storage Space with strip(1). . . . . . . . . . . . . . . . . . . . . . . . . . 116
Improving Program Start-up with fastbind(1) . . . . . . . . . . . . . . . . . . . 118
Finding Object Library Ordering Relationships with lorder(1). . . . . . 120
5. Creating and Using Libraries
Overview of Shared and Archive Libraries. . . . . . . . . . . . . . . . . . . . . . 122
What are Archive Libraries? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
What are Shared Libraries? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
The Dynamic Loader dld.sl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Default Behavior When Searching for Libraries at Run Time. . . . . 127
Caution on Using Dynamic Library Searching. . . . . . . . . . . . . . . . . 127
Example Program Comparing Shared and Archive Libraries. . . . . . . 128
Shared Libraries with Debuggers, Profilers, and Static Analysis. . . . 130
Creating Archive Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Overview of Creating an Archive Library . . . . . . . . . . . . . . . . . . . . . 131
Contents of an Archive File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Example of Creating an Archive Library. . . . . . . . . . . . . . . . . . . . . . 133
Replacing, Adding, and Deleting an Object Module . . . . . . . . . . . . . 134
Contents
9
Summary of Keys to the ar(1) Command . . . . . . . . . . . . . . . . . . . . . .135
crt0.o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Archive Library Location. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Creating Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
Creating Position-Independent Code (PIC). . . . . . . . . . . . . . . . . . . . .138
Creating the Shared Library with ld. . . . . . . . . . . . . . . . . . . . . . . . . .139
Shared Library Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140
Updating a Shared Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
Shared Library Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
Improving Shared Library Performance. . . . . . . . . . . . . . . . . . . . . . .145
Version Control with Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . .149
When to Use Shared Library Versioning . . . . . . . . . . . . . . . . . . . . . .149
Maintaining Old Versions of Library Modules . . . . . . . . . . . . . . . . . .150
Library-Level Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150
Intra-Library Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
Switching from Archive to Shared Libraries . . . . . . . . . . . . . . . . . . . . .158
Library Path Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
Relying on Undocumented Linker Behavior. . . . . . . . . . . . . . . . . . . .158
Absolute Virtual Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159
Stack Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
Version Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160
Debugger Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
Using the chroot Command with Shared Libraries . . . . . . . . . . . . . .161
Profiling Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
Summary of HP-UX Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
Caution When Mixing Shared and Archive Libraries. . . . . . . . . . . . . .164
Example 1: Unsatisfied Symbols. . . . . . . . . . . . . . . . . . . . . . . . . . . . .164
Example 2: Using shl_load(3X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
Example 3: Hidden Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
Summary of Mixing Shared and Archive Libraries . . . . . . . . . . . . . .175
10
Contents
Using Shared Libraries in 64-bit mode. . . . . . . . . . . . . . . . . . . . . . . . . 176
Internal Name Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Dynamic Path Searching for Shared Libraries . . . . . . . . . . . . . . . . . 177
Shared Library Symbol Binding Semantics . . . . . . . . . . . . . . . . . . . 178
Mixed Mode Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
64-bit Mode Library Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
6. Shared Library Management Routines
Shared Library Management Routine Summaries . . . . . . . . . . . . . . . 196
The shl_load Routine Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
The dlopen Routines Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Related Files and Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Shared Library Header Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Using Shared Libraries with cc and ld Options . . . . . . . . . . . . . . . . . . 200
Initializers for Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Styles of Initializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
32-bit Mode Initializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
64-bit Mode Initializers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
The shl_load Shared Library Management Routines . . . . . . . . . . . . . 215
The shl_load and cxxshl_load Routines. . . . . . . . . . . . . . . . . . . . . . . 215
The shl_findsym Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
The shl_get and shl_get_r Routines. . . . . . . . . . . . . . . . . . . . . . . . . . 226
The shl_gethandle and shl_gethandle_r Routines . . . . . . . . . . . . . . 230
The shl_definesym Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
The shl_getsymbols Routine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
The shl_unload and cxxshl_unload Routines . . . . . . . . . . . . . . . . . . 238
The dlopen Shared Library Management Routines. . . . . . . . . . . . . . . 240
The dlopen Routine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
The dlerror Routine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Contents
11
The dlsym Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245
The dlget Routine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248
The dlmodinfo Routine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .249
The dlgetname Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252
The dlclose Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253
Dynamic Loader Compatibility Warnings . . . . . . . . . . . . . . . . . . . . . . .256
Unsupported Shared Library Management Routines . . . . . . . . . . . .256
Unsupported Shared Library Management Flags . . . . . . . . . . . . . . .256
7. Position-Independent Code
What Is Relocatable Object Code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260
What is Absolute Object Code?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261
What Is Position-Independent Code? . . . . . . . . . . . . . . . . . . . . . . . . . . .262
Generating Position-Independent Code . . . . . . . . . . . . . . . . . . . . . . . . .263
For More Information: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264
PIC Requirements for Compilers and Assembly Code. . . . . . . . . . . .264
Long Calls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
Long Branches and Switch Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . .265
Assigned GOTO Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
Literal References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
Global and Static Variable References . . . . . . . . . . . . . . . . . . . . . . . .267
Procedure Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
8. Ways to Improve Performance
Linker Optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .270
Invoking Linker Optimizations from the Compile Line. . . . . . . . . . .270
Incompatibilities with other Options . . . . . . . . . . . . . . . . . . . . . . . . .271
Unused Procedure Elimination with +Oprocelim. . . . . . . . . . . . . . . .271
Options to Improve TLB Hit Rates. . . . . . . . . . . . . . . . . . . . . . . . . . . . .273
12
Contents
Profile-Based Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
General Information about PBO . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Using PBO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
When to Use PBO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
How to Use PBO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Instrumenting (+I/-I). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Profiling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Optimizing Based on Profile Data (+P/-P). . . . . . . . . . . . . . . . . . . . . 283
Selecting an Optimization Level with PBO. . . . . . . . . . . . . . . . . . . . 285
Using PBO to Optimize Shared Libraries . . . . . . . . . . . . . . . . . . . . . 286
Using PBO with ld -r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Restrictions and Limitations of PBO. . . . . . . . . . . . . . . . . . . . . . . . . 288
Compatibility with 9.0 PBO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Improving Shared Library Start-Up Time with fastbind . . . . . . . . . . 293
Using fastbind. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Invoking the fastbind Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Invoking fastbind from the Linker. . . . . . . . . . . . . . . . . . . . . . . . . . . 294
How to Tell if fastbind Information is Current . . . . . . . . . . . . . . . . . 294
Removing fastbind Information from a File . . . . . . . . . . . . . . . . . . . 294
Turning off fastbind at Run Time . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
For More Information: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
A. Using Mapfiles
Controlling Mapfiles with the -k Option. . . . . . . . . . . . . . . . . . . . . . . . 296
Mapfile Example: Using -k filename (without +nodefaultmap Option)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Changing Mapfiles with -k filename and +nodefaultmap . . . . . . . . . . 298
Mapfile Example: Using -k mapfile and +nodefaultmap . . . 298
Simple Mapfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Default HP-UX Release 11.0 Mapfile . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Contents
13
Defining Syntax for Mapfile Directives . . . . . . . . . . . . . . . . . . . . . . . . .303
Defining Mapfile Segment Declarations. . . . . . . . . . . . . . . . . . . . . . . . .304
Segment Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304
Mapfile Segment Declaration Examples. . . . . . . . . . . . . . . . . . . . . . .306
Defining Mapfile Section Mapping Directives . . . . . . . . . . . . . . . . . . . .307
Internal Map Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
Placement of Segments in an Executable. . . . . . . . . . . . . . . . . . . . . .309
Mapping Input Sections to Segments . . . . . . . . . . . . . . . . . . . . . . . . .309
Interaction between User-defined and Default Mapfile Directives. .312
Mapfile Option Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313
Fatal Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313
Warnings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
14
Contents
15
Preface
This Guide covers the following topics:
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, “Ways to Improve Performance,” discusses several ways 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:
16
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 64-bit mode dynamic path searching mechanisms.
Add 64-bit mode symbol binding semantics.
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.
17
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 hardware 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.
18
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."
Chapter 1 19
What's New in Recent Releases
1 What'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.
20 Chapter 1
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
/