Kenwood HP 9000 - Manuals
Kenwood HP 9000 – Manual in PDF format online.
Manuals:
Manual Kenwood HP 9000
Summary
2 Legal Notices The information contained in this document is subject to change withoutnotice. Hewlett-Packard makes no warranty of any kind with regard to thismanual, including, but not limited to, the implied warranties ofmerchantability and fitness for a particular purpose. Hewlett-Packardshall n...
Contents 5 Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Printing History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 1. What's New in Recent Releases PA-RISC Changes in Hardware Compatib...
8 Contents 4. Linker Tools Changing a Program's Attributes with chatr(1) . . . . . . . . . . . . . . . . . . 104 Using chatr for 32-bit Program Attributes . . . . . . . . . . . . . . . . . . . . 104Using chatr for 64-bit Program Attributes . . . . . . . . . . . . . . . . . . . . 105 Viewing Symbols ...
10 Contents Using Shared Libraries in 64-bit mode . . . . . . . . . . . . . . . . . . . . . . . . . 176 Internal Name Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176Dynamic Path Searching for Shared Libraries . . . . . . . . . . . . . . . . . 177Shared Library Symbol...
Contents 11 The dlsym Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245The dlget Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248The dlmodinfo Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...
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 w...
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-UXlinker 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: • ...
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 behav...
Chapter 1 21 What's New in Recent Releases PA-RISC Changes in Hardware Compatibility PA-RISC Changes in HardwareCompatibility The HP-UX 10.20 release introduced HP 9000 systems based on thePA-RISC 2.0 architecture. Also, beginning with that release, HPcompilers by default generate executable code fo...
24 Chapter 1 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 theELF (executable and linking format) object file format. The 64-bit linkertoolset provides new tools to display and...
Chapter 1 25 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-UXrelease 11.00. 64-bit Mode Linker Options The ld(1) command supports the following new options in 64-bit mode: Optio...
26 Chapter 1 What's New in Recent Releases New Features for 64-bit Mode Linking 64-bit Mode Linker-defined Symbols The 64-bit linker reserves the following symbol names: a. The linker accepts but ignores this option in 32-bit mode. It creates an executable (a.out). +noenvvar Instructs the dynamic lo...
28 Chapter 1 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 modefeatures. Option or Behavior Description -A name Specifies incremental loading. 64-bit applicationsmust use shared l...
30 Chapter 1 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 dynamicloading model similar to other SVR4 systems. There are two main areaswhere program startup changes in 64-bit mode: • Dyna...
32 Chapter 1 What's New in Recent Releases Changes in Future Releases Changes in Future Releases The following changes are planned in future releases. • Support of ELF 32 object file format A future release will support the ELF 32 object file format. • Future of ld +compat option The +compat linker ...
Chapter 1 33 What's New in Recent Releases Online Help for Linker and Libraries Online Help for Linker and Libraries The Linker and Libraries Online User Guide is available for HP 9000Series 700 and 800 systems. The online help comes with HP C, HP C++,HP aC++, HP Fortran, HP Pascal, and HP Micro Foc...
Chapter 2 35 What Happens When You Compile and Link a Program 2 What Happens When YouCompile and Link a Program This chapter describes the process of compiling and linking a program. • “Compiling Programs on HP-UX: An Example” provides an overview of compiling on HP-UX. • “Looking “inside” a Compile...
Chapter 2 37 What Happens When You Compile and Link a Program Compiling Programs on HP-UX: An Example sum += n; /* add n to sum */ return sum; /* return the value of sum */} main() /* begin main program */{ int n; /* number to input from user */ printf("Enter a number: "); /* prompt for numb...
38 Chapter 2 What Happens When You Compile and Link a Program Looking “inside” a Compiler Looking “inside” a Compiler On the surface, it appears as though an HP-UX compiler generates an a.out file by itself. Actually, an HP-UX compiler is a driver that calls other commands to create the a.out file. ...
40 Chapter 2 What Happens When You Compile and Link a Program What is an Object File? What is an Object File? An object file is basically a file containing machine languageinstructions and data in a form that the linker can use to create anexecutable program. Each routine or data item defined in an ...
Chapter 2 41 What Happens When You Compile and Link a Program Compiler-Linker Interaction Compiler-Linker Interaction As described in “Looking “inside” a Compiler”, the compilersautomatically call ld to create an executable file. To see how the compilers call ld , run the compiler with the -v (verbo...
42 Chapter 2 What Happens When You Compile and Link a Program Linking Programs on HP-UX Linking Programs on HP-UX The HP-UX linker, ld , produces a single executable file from one or more input object files and libraries. In doing so, it matches externalreferences to global definitions contained in ...
Chapter 2 43 What Happens When You Compile and Link a Program Linking Programs on HP-UX The crt0.o Startup File Notice in the example in “Compiler-Linker Interaction” that the firstobject file on the linker command line is /opt/langtools/lib/crt0.o , even though this file was not specified on the co...
44 Chapter 2 What Happens When You Compile and Link a Program Linking Programs on HP-UX In 64-bit mode for dynamically bound executables, the entry point,defined by the symbol $START$ in the dynamic loader ( dld.sl ). The a.out File The information contained in the resulting a.out file depends on wh...
Chapter 2 45 What Happens When You Compile and Link a Program Linking Programs on HP-UX Table 2-1 32-bit Mode Magic Number Linker Options An executable file's magic number can also be changed using the chatr command (see “Changing a Program's Attributes with chatr(1)” on page104). However, chatr can...
46 Chapter 2 What Happens When You Compile and Link a Program Linking with Libraries Linking with Libraries In addition to matching external references to global definitions in objectfiles, ld matches external references to global definitions in libraries. A library is a file containing object code ...
Chapter 2 47 What Happens When You Compile and Link a Program Linking with Libraries $ f77 -v sumnum.f ... /usr/ccs/bin/ld -x /opt/langtools/lib/crt0.o \ sumnum.o -lcl -lisamstub -lc The Default Library Search Path By default, ld searches for libraries in the directory /usr/lib . (If the -p or -G co...
48 Chapter 2 What Happens When You Compile and Link a Program Running the Program Running the Program An executable file is created after the program has been compiled andlinked. The next step is to run or load the program. Loading Programs: exec When you run an executable file created by ld , the p...
Chapter 2 49 What Happens When You Compile and Link a Program Running the Program Deferred Binding is the Default To accelerate program startup time, routines in a shared library are notbound until referenced. (Data items are always bound at programstartup.) This deferred binding of shared library r...
50 Chapter 2 What Happens When You Compile and Link a Program Linker Thread-Safe Features Linker Thread-Safe Features Beginning with the HP-UX 10.30 release, the dynamic loader ( dld.sl ) and its application interface library ( libdld.sl ) are thread-safe. Also, beginning with the HP-UX 10.30 releas...
Chapter 3 51 Linker Tasks 3 Linker Tasks You have a great deal of control over how the linker links your programor library by using ld command-line options. • Using the Compiler Command • “Changing the Default Library Search Path with -Wl, -L” • “Getting Verbose Output with -v” • “Passing Linker Opt...
Chapter 3 53 Linker Tasks Using the Compiler to Link Using the Compiler to Link In many cases, you use your compiler command to compile and linkprograms. Your compiler uses options that directly affect the linker. Changing the Default Library Search Pathwith -Wl, -L By default, the linker searches t...
54 Chapter 3 Linker Tasks Using the Compiler to Link The LPATH environment variable provides another way to override the default search path. For details, see “Changing the Default LibrarySearch Path with -L and LPATH”. Getting Verbose Output with -v The -v option makes a compiler display verbose in...
Chapter 3 55 Linker Tasks Using the Compiler to Link Renaming the Output File with -o The -o name option causes ld to name the output file name instead of a.out . For example, to compile a C program prog.c and name the resulting file sum_num : $ cc -Aa -o sum_num prog.c Compile using -o option. $ su...
Chapter 3 57 Linker Tasks Using Linker commands Using Linker commands This section describes linker commands for the 32-bit and 64-bit linker. NOTE Unless otherwise noted, all examples show 32-bit behavior. Linking with the 32-bit crt0.o Startup File In 32-bit mode, you must always include crt0.o on...
58 Chapter 3 Linker Tasks Using Linker commands Augmenting the Default Linker Search Path with -L The -L option to ld also allows you to add additional directories to the search path. If -L libpath is specified, ld searches the libpath directory before the default places. For example, suppose you ha...
Chapter 3 59 Linker Tasks Using Linker commands Nonfatal Shared Library Binding with -B nonfatal The linker also supports nonfatal binding, which is useful with the -B immediate option. Like immediate binding, nonfatal immediate binding causes all required symbols to be bound at program startup. The...
60 Chapter 3 Linker Tasks Using Linker commands • The program calls shl_definesym to define a symbol that is already defined in a library that was loaded at program startup. If such a program is linked with -B immediate , references to symbols will be bound at program startup, regardless of whether ...
62 Chapter 3 Linker Tasks Using Linker commands Figure 3-1 Symbols inside a Shared Library Visible with -B symbolic Case 2: Building a Shared Library with -h or +e. The -h (hide symbol) and +e (export symbol) options can also optimize the call path in a shared library for symbols that are explicitly...
Chapter 3 63 Linker Tasks Using Linker commands In both cases, main2 will not be able to resolve its reference togal_to_liter() because only the convert_rtn() symbol is exported as shown below: Choosing Archive or Shared Libraries with -a If both an archive and shared version of a particular library...
Chapter 3 65 Linker Tasks Using Linker commands Dynamic Linking with -A and -R This section describes how to do dynamic linking — that is, how to addan object module to a running program. Conceptually, it is very similar toloading a shared library and accessing its symbols (routines and data).In fac...
66 Chapter 3 Linker Tasks Using Linker commands 8. Get the addresses of routines and data that are referenced in the module. Step 1: Determine how much space is required to load themodule. There must be enough contiguous memory to hold the module's text, data, and bss segments. You can make a libera...
Chapter 3 67 Linker Tasks Using Linker commands The useful members of the som_exec_auxhdr structure are: .exec_tsize Size of text (code) segment. .exec_tmem Address at which to load the text (already adjusted foroffset specified by the -R linker option). .exec_tfile Offset into file (location) where...
68 Chapter 3 Linker Tasks Using Linker commands Use an assembly language routine named flush_cache (see “The flush_cache Function” in this chapter). You must assemble this routineseparately (with the as command) and link it with the main program. Step 8: Get the addresses of routines and data that a...
Chapter 3 69 Linker Tasks Using Linker commands The Build Environment. Before seeing the program's source code, it may help to see how the program and the various object files werebuilt. The following shows the makefile used to generate the variousfiles. Makefile Used to Create Dynamic Link Files CF...
70 Chapter 3 Linker Tasks Using Linker commands Note that the line CFLAGS =… causes any C files to be compiled in ANSI mode ( -Aa ) and causes the compiler to search for routines that are defined in the Posix standard ( -D_POSIX_SOURCE ). For details on using make refer to make(1). Source for dynpro...
72 Chapter 3 Linker Tasks Using Linker commands glorp(“foo”); (*counter_ptr) ++; /* update counter indirectly with globalpointer */} void bar(){ glorp(“bar”); counter ++; /* update counter directly */} /**************************************************************** * file2.c - Global counter varia...
Chapter 3 75 Linker Tasks Using Linker commands The base_prog, obj_files, and dest_file parameters are the sameparameters supplied to alloc_load_space . The addr parameter is the address returned by alloc_load_space , and the entry_pt parameter specifies a symbol name that you want to act as the ent...
78 Chapter 3 Linker Tasks Using Linker commands /*----------------------------------------------------------------- * STEP 6: Return a pointer to the entry point specified by -e: */ entry_pt_addr = (unsigned int) aux_hdr.exec_entry; return ((void *) entry_pt_addr);} The flush_cache Function . Since ...
Chapter 3 79 Linker Tasks Using Linker commands copy %arg1,%arg3 ; Copy offset from GR25 to GR23 fdc %arg1(0,%arg0) ; Flush data [email protected]+offsetloop1 addib,>,n -16,%arg1,loop1 ; Decrement offset by cache linesize fdc %arg1(0,%arg0) ; Flush data [email protected]+offset ; flush first word...
Chapter 3 81 Linker Tasks Using Linker commands Exporting Symbols with +ee Like the +e option, the +ee option allows you to export symbols. Unlike the +e option, the option does not alter the visibility of any other symbols in the file. It exports the specified symbol, and does not hide any of thesy...
84 Chapter 3 Linker Tasks Using Linker commands As mentioned previously in the section “Exporting Symbols from mainwith -E”, the -E option forces the export of all symbols from the program, regardless of whether they are referenced by shared libraries on thelinker command line. The +e option allows ...
Chapter 3 85 Linker Tasks Using Linker commands Specifying a Path List with +b The syntax of the +b option is +b path_list where path_list is the list of directories you want the dynamic loader tosearch at run time. For example, the following linker command causesthe path .:/app/lib:: to be stored i...
86 Chapter 3 Linker Tasks Using Linker commands the previous example were /apps/lib::xyz , the dynamic loader would search for /apps/lib/libfoo.sl , /usr/local/lib/libfoo.sl , then ./xyz/libfoo.sl . If the dynamic loader cannot find a required library in any of thedirectories specified in the path l...
Chapter 3 87 Linker Tasks Using Linker commands +e reverse_tree+e preorder_traversal+e shift_reduce_parse ... Note that the linker ignores lines in that option file that begin with apound sign ( # ). You can use such lines as comment lines or to temporarily disable certain linker options in the file...
90 Chapter 3 Linker Tasks Using 64-bit Mode Linker Options Using 64-bit Mode Linker Options This section introduces 64-bit-only linker options. Using the 64-bit Mode Linker with +compat or+std In the HP-UX 11.0 release, the linker toolset supports extended featuresfor linking in 64-bit mode. Since c...
Chapter 3 91 Linker Tasks Using 64-bit Mode Linker Options • +b first means dld looks at the RPATH first when searching for dependent shared libraries. To get the default RPATH , you must specify ld +b . This instructs the linker to construct a default RPATH consisting of the -L directories and LPAT...
Chapter 3 93 Linker Tasks Using 64-bit Mode Linker Options • Looks at the environment variables first, followed by RPATH , and the default directories by default when doing dynamic path searching forstandard-mode dependentshared libraries. Linking Shared Libraries with -dynamic Use the -dynamic opti...
Chapter 3 95 Linker Tasks Using 64-bit Mode Linker Options Hiding Symbols from export with+hideallsymbols Use the +hideallsymbols option to hide all symbols to prevent the linker from exporting them in a shared link. In the following example, main() exports func() and test() . Using +hideallsymbols ...
96 Chapter 3 Linker Tasks Using 64-bit Mode Linker Options Ignoring Dynamic Path EnvironmentVariables with +noenvvar Use the +noenvvar to instruct the dynamic loader not to look at the environment variables relating to dynamic path searching at runtime. Itignores LD_LIBRARY_PATH and SHLIB_PATH envir...
Chapter 3 97 Linker Tasks Using 64-bit Mode Linker Options Selecting Verbose Output with +vtype Use the +vtype option to get verbose output about specified elements of the link operation. The following values specify the type: Parameter Description files Dump information about each object file loade...
98 Chapter 3 Linker Tasks Using 64-bit Mode Linker Options ld main.o +vtype all -L. -lfile1 -lfile2 -lcLoading main.o:main.o:main is DEFINED GLOBAL FUNCprintf is UNDEF GLOBAL FUNClib1_func is UNDEF GLOBAL FUNClib2_func is UNDEF GLOBAL FUNCmain.o: section .text PROG_BITS AX 116 8 added to textsegment...
Chapter 3 99 Linker Tasks Linker Compatibility Warnings Linker Compatibility Warnings Beginning with the HP-UX 10.20 release, the linker generatescompatibility warnings. These warnings include HP 9000 architectureissues, as well as linker features that may change over time.Compatibility warnings can...
103 4 Linker Tools This chapter describes the linker toolset, which provides several tools tohelp you find symbols, display and modify object files, and determine linkorder. Some of these tools are specific to a particular object file type;others are available in both 32-bit and 64-bit mode. The fol...
104 Chapter 4 Linker Tools Changing a Program's Attributes with chatr(1) Changing a Program's Attributes withchatr(1) The chatr command (see chatr(1)) allows you to change various program attributes that were determined at link time. When run without anyoptions, chatr displays the attributes of the ...
Chapter 4 105 Linker Tools Changing a Program's Attributes with chatr(1) a. If +b enable and +s enable are both specified, the order in which they appear determines which search path is used first. Using chatr for 64-bit Program Attributes In 64-bit mode, chatr supports two different command syntaxe...
Chapter 4 107 Linker Tools Viewing Symbols in an Object file with nm(1) Viewing Symbols in an Object file withnm(1) The nm(1) command displays the symbol table of each specified object.file can be a relocatable object file or an executable object file, or anarchive of relocatable or executable objec...
Chapter 4 111 Linker Tools Viewing the Contents of an Object File with elfdump(1) Viewing the Contents of an Object Filewith elfdump(1) NOTE The elfdump command works on 64-bit executables or shared libraries. The elfdump(1) command displays information contained in ELF formatobject files, archives,...
Chapter 4 115 Linker Tools Viewing the Size of Object File Elements with size(1) Viewing the Size of Object File Elementswith size(1) The size(1) command produces section size information for each sectionin your specified object files. It displays the size of the text, data and bss(uninitialized dat...
118 Chapter 4 Linker Tools Improving Program Start-up with fastbind(1) Improving Program Start-up withfastbind(1) The fastbind(1) command prepare an incomplete executable for fasterprogram start-up. It can improve the start-up time of programs that useshared libraries (incomplete executables) by sto...
Chapter 4 119 Linker Tools Improving Program Start-up with fastbind(1) The 32-bit mode fastbind command does not work with EXEC_MAGIC executables. fastbind effectively enforces the binding modes bind-restricted and bind-immediate. For example, consider an executable linkedbind-deferred, which calls ...
120 Chapter 4 Linker Tools Finding Object Library Ordering Relationships with lorder(1) Finding Object Library OrderingRelationships with lorder(1) The lorder command finds the ordering relation for an object library. Youcan specify one or more object or archive library files (see ar(1)) on thecomma...
Chapter 5 121 Creating and Using Libraries 5 Creating and Using Libraries Many libraries come with HP-UX. You can also create and use your ownlibraries on HP-UX. This chapter provides information on the followingtopics: • General Information about Shared and Archive Libraries • “Overview of Shared a...
122 Chapter 5 Creating and Using Libraries Overview of Shared and Archive Libraries Overview of Shared and ArchiveLibraries HP-UX supports two kinds of libraries: archive and shared. A sharedlibrary is also called a dll (dynamically linked library), particularly inthe context of the 64-bit mode link...
Chapter 5 125 Creating and Using Libraries What are Archive Libraries? What are Archive Libraries? An archive library contains one or more object files and is created withthe ar command. When linking an object file with an archive library, ld searches the library for global definitions that match up...
126 Chapter 5 Creating and Using Libraries What are Shared Libraries? What are Shared Libraries? Like an archive library, a shared library contains object code. However, ld treats shared libraries quite differently from archive libraries. When linking an object file with a shared library, ld does no...
Chapter 5 127 Creating and Using Libraries What are Shared Libraries? Default Behavior When Searching forLibraries at Run Time By default, if the dynamic loader cannot find a shared library from thelist, it generates a run-time error and the program aborts. For example,in 32-bit mode, suppose that d...
128 Chapter 5 Creating and Using Libraries Example Program Comparing Shared and Archive Libraries Example Program Comparing Sharedand Archive Libraries As an example, suppose two separate programs, prog1 and prog2 , use shared libc routines heavily. Suppose that the a.out portion of prog1 is 256Kb i...
130 Chapter 5 Creating and Using Libraries Shared Libraries with Debuggers, Profilers, and Static Analysis Shared Libraries with Debuggers,Profilers, and Static Analysis As of the HP-UX 10.0 release, debugging of shared libraries is supportedby the HP/DDE debugger. For details on how to debug shared...
Chapter 5 131 Creating and Using Libraries Creating Archive Libraries Creating Archive Libraries Two steps are required to create an archive library: 1. Compile one or more source files to create object files containing relocatable object code. 2. Combine these object files into a single archive lib...
132 Chapter 5 Creating and Using Libraries Creating Archive Libraries Figure 5-4 summarizes the procedure for creating archive libraries fromthree C source files ( file1.c , file2.c , and file3.c ). The process is identical for other languages, except that you would use a differentcompiler. Figure 5...
Chapter 5 133 Creating and Using Libraries Creating Archive Libraries cosh.o Object modules are displayed. erf.ofabs.ofloor.o . . . . This indicates that the library was built from object files named cosh.o , erf.o , fabs.o , floor.o , and so forth. In other words, module names are the same as the n...
134 Chapter 5 Creating and Using Libraries Creating Archive Libraries Then combine the .o files by running ar with the r key, followed by the library name (say libunits.a ), followed by the names of the object files to place in the library: $ ar r libunits.a length.o volume.o mass.oar: creating libu...
Chapter 5 135 Creating and Using Libraries Creating Archive Libraries Deleting an Object Module To delete an object module from a library, use the d key. For example, to delete volume.o from libunits.a : $ ar d libunits.a volume.o Delete volume.o. $ ar t libunits.a List the contents. length.omass.o ...
136 Chapter 5 Creating and Using Libraries Creating Archive Libraries $ ar tv libunits.arw-rr 265/ 20 230 Feb 2 17:19 1990 length.o rw-rr 265/ 20 228 Feb 2 16:25 1990 mass.o rw-rr 265/ 20 230 Feb 2 16:24 1990 volume.o The next example replaces length.o in libunits.a , only if length.o is more recent...
138 Chapter 5 Creating and Using Libraries Creating Shared Libraries Creating Shared Libraries Two steps are required to create a shared library: 1. “Creating Position-Independent Code (PIC)” by compiling with +z . 2. “Creating the Shared Library with ld” by linking with -b . Shown below are the com...
Chapter 5 139 Creating and Using Libraries Creating Shared Libraries Example Using +z Suppose you have some C functions, stored in length.c , that convert between English and Metric length units. To compile these routines andcreate PIC object files with the C compiler, you could use this command: $ ...
140 Chapter 5 Creating and Using Libraries Creating Shared Libraries $ cc -Aa -c +z length.c volume.c mass.clength.c:volume.c:mass.c:$ ld -b -o libunits.sl length.o volume.o mass.o Once the library is created, be sure it has read and execute permissionsfor all users who will use the library. For exa...
Chapter 5 143 Creating and Using Libraries Creating Shared Libraries 3. mark A , load A 4. mark D , load D 5. mark Q , load Q 6. traverse D 7. D is already marked, so skip D 8. traverse Q 9. Q is already marked, so skip Q 10. traverse Q 11. Q is already marked, so skip Q 12. traverse B 13. mark B , ...
144 Chapter 5 Creating and Using Libraries Creating Shared Libraries libP → libA → libD → libQ → libB → <current search list> Updating a Shared Library The ld command cannot replace or delete object modules in a shared library. Therefore, to update a shared library, you must relink the library...
Chapter 5 145 Creating and Using Libraries Creating Shared Libraries Prior to the HP-UX 9.0 release, moving a shared library caused anyprograms that were linked with the library to fail when they tried to loadthe library. Prior to 9.0, you were required to relink all applications thatused the librar...
146 Chapter 5 Creating and Using Libraries Creating Shared Libraries You may be surprised to find that a shared library exports many moresymbols than necessary for code that uses the library. These extrasymbols add to the size of the library's symbol table and can evendegrade performance (since the ...
148 Chapter 5 Creating and Using Libraries Creating Shared Libraries y.od.o Notice that d.o is now closer to x.o and y.o , which call it. However, this is still not the best information to use because a.o and b.o are separated from x.o and y.o by the module e.o , which is not called by any modules. ...
Chapter 5 149 Creating and Using Libraries Version Control with Shared Libraries Version Control with Shared Libraries HP-UX provides two ways to support incompatible versions of sharedlibrary routines. “Library-Level Versioning” describes how you createmultiple versions of a shared library. “Intra-...
150 Chapter 5 Creating and Using Libraries Version Control with Shared Libraries • As a general rule, when an exported function is changed such that calls to the function from previously compiled object files shouldnot resolve to the new version, the change is incompatible. If thenew version can be ...
Chapter 5 151 Creating and Using Libraries Version Control with Shared Libraries 1. Name the first version of your shared library with an extension of .0 (that's the number zero), for example libA.0 . Use the +h option to designate the internal name of the library, for example, libA.0 : ld -b *.o -o...
152 Chapter 5 Creating and Using Libraries Version Control with Shared Libraries When you run a program that uses shared libraries and was linkedbefore HP-UX 10.0, the dynamic loader first attempts to open the sharedlibrary ending in .0 . If it cannot find that library, it attempts to open the libra...
154 Chapter 5 Creating and Using Libraries Version Control with Shared Libraries Figure 5-6 With these links in place, the loader will load /X/libapp.0 when running the a.out file created above. New applications will link and run with /X/libapp.1 . NOTE Renaming the old version of the .0 version lib...
Chapter 5 155 Creating and Using Libraries Version Control with Shared Libraries • “Shared Library Dependencies and Version Control” • “Adding New Versions to a Shared Library” • “Specifying a Version Date” The Version Number Compiler Directive With intra-library versioning, you assign a version num...
156 Chapter 5 Creating and Using Libraries Version Control with Shared Libraries If a shared library lists a second shared library as a dependency, dld.sl will generate an error if the second shared library has a version numberwhich is older than the version number recorded with the dependency.This ...
Chapter 5 157 Creating and Using Libraries Version Control with Shared Libraries Specifying a Version Date When adding modules to a library for a particular release of the library,it is best to give all modules the same version date. For example, if youcomplete file1.o on 04/93, file2.o on 05/93, an...
158 Chapter 5 Creating and Using Libraries Switching from Archive to Shared Libraries Switching from Archive to SharedLibraries There are cases where a program may behave differently when linkedwith shared libraries than when linked with archive libraries. These arethe result of subtle differences i...
Chapter 5 159 Creating and Using Libraries Switching from Archive to Shared Libraries More commonly, programmers may take advantage of undocumentedlinker behavior to minimize the size of routines copied into the a.out files from archive libraries. This is no longer necessary if all libraries areshar...
160 Chapter 5 Creating and Using Libraries Switching from Archive to Shared Libraries rearrange data in shared libraries, this is no longer guaranteed. Anotherexample is a function that assumes variables it declares statically (forexample, C static variables) reside below the reserved symbol _end in...
Chapter 5 161 Creating and Using Libraries Switching from Archive to Shared Libraries Debugger Limitations Shared libraries can be debugged just like archive libraries with fewexceptions. For details on debugging shared libraries, refer to theHP/DDE Debugger User's Guide or the HP-UX Symbolic Debugg...
162 Chapter 5 Creating and Using Libraries Summary of HP-UX Libraries Summary of HP-UX Libraries What libraries your system has depends on what components werepurchased. For example, if you didn't purchase Starbase Display List,you won't have the Starbase Display List library on your system. HP-UX l...
164 Chapter 5 Creating and Using Libraries Caution When Mixing Shared and Archive Libraries Caution When Mixing Shared andArchive Libraries Mixing shared and archive libraries in an application is notrecommended and should be avoided. That is, an application should useonly shared libraries or only a...
166 Chapter 5 Creating and Using Libraries Caution When Mixing Shared and Archive Libraries Figure 5-10 Compile the new f3() and rebuild the shared library lib3.sl : $ cc -c +z f3.c Compile to relocatable code . $ ld -b -o lib3.sl f3.o Create a new shared library. Figure 5-11 Problem Here's where th...
Chapter 5 171 Creating and Using Libraries Caution When Mixing Shared and Archive Libraries Example 3: Hidden Definitions This example shows how mixing archive libraries and shared librariescan lead to multiple definitions in the application and unexpectedresults. If one of the definitions happens t...
176 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode Using Shared Libraries in 64-bit mode In the HP-UX 11.00 release, HP provides an industry-standard linkertoolset for programs linked in 64-bit mode. The new toolset consists of alinker, dynamic loader, object file class...
Chapter 5 177 Creating and Using Libraries Using Shared Libraries in 64-bit mode • If the dependent library’s internal name contains a relative path, the internal name is inserted at the end of the path where the sharedlibrary is found at link time, replacing the library’s filename in the DT_HP_NEED...
178 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode LD_LIBRARY_PATH and the SHLIB_PATH environment variable to add directories to the run time search path for shared libraries, unless the ld +noenvvar option is set. In the 32-bit mode of the linker toolset (selected by t...
180 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode At link time, there is an outstanding unsatisfied symbol for afunc() when libB is found. The exported symbol for afunc() is not remembered after libA.sl is scanned. At run time, the afunc() symbol that is called is the ...
Chapter 5 181 Creating and Using Libraries Using Shared Libraries in 64-bit mode If these files are compiled and linked as: cc -c main.ccc -c +z lib1.c lib2.cld -b lib1.o lib2.o -o liba.slcc main.o liba.sl -o test2 Using the 32-bit mode linker, test2 executes without error. The module in liba.sl cre...
182 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode cc -c main.ccc -c +z a.c b.cld -b a.o -o libA.slld -b b.o -o libB.slcc main.o libA.sl libB.sl -o test3 The 32-bit mode linker toolset produces: $ test3 object is 1 The 32-bit mode linker toolset defines the object globa...
184 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode 1. First, the dependent shared libraries for libA are built. (Other libraries are also built.) ld -b libD.o -o libD.sl libA dependent shared library ld -b libE.o -o libE.sl libA dependent shared library ld -b libF.o -o ...
186 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode mode library. The loader uses 64-bit mode search techniques on alllibraries except for libfile3.sl , in which case it uses 32-mode search techniques. NOTE Embedded path inheritance is not applied to any mixed mode share...
190 Chapter 5 Creating and Using Libraries Using Shared Libraries in 64-bit mode +-->lib2a.sl| +-->lib2.sl-->lib2b.sl| lib1.sl-->lib3.sl-->lib3a.sl-->lib3aa.sl | | | +-->lib3b.sl +-->lib4.sl In breadth-first searching, the load order is siblings before children: lib1.sl->l...
Chapter 5 191 Creating and Using Libraries Using Shared Libraries in 64-bit mode Library Example: Linking to Libraries with +b path_list in 64-bit Mode. In this example, the program main calls a shared library routine in libbar.sl . The routine in libbar.sl in turn calls a routine in the shared libr...
Chapter 6 195 Shared Library Management Routines 6 Shared Library ManagementRoutines You can explicitly load and use shared libraries from your program. Thelinker toolset provides two families of load routines, shl_load and dlopen . The shl_load routines support the shared library mechanisms provide...
196 Chapter 6 Shared Library Management Routines Shared Library Management Routine Summaries Shared Library Management RoutineSummaries The following sections introduce the shared library managementroutines available for the HP-UX 11.00 release. The shl_load Routine Summary The shl_load family of sh...
Chapter 6 197 Shared Library Management Routines Shared Library Management Routine Summaries Except for shl_get and shl_gethandle , all these routines are thread safe. These routines are described in the shl_load(3x) man page. The dlopen Routines Summary The dlopen family of shared library managemen...
198 Chapter 6 Shared Library Management Routines Shared Library Management Routine Summaries All the dlopen routines are thread-safe. These routines are described in the dl*(3C) man pages. Related Files and Commands These commands and files provide more information about using sharedlibrary manageme...
Chapter 6 199 Shared Library Management Routines Shared Library Header Files Shared Library Header Files The shl_load family of shared library management routines use some special data types (structures) and constants defined in the C-languageheader file /usr/include/dl.h . When using these function...
200 Chapter 6 Shared Library Management Routines Using Shared Libraries with cc and ld Options Using Shared Libraries with cc and ldOptions In 32-bit mode, you can access the shl_load family of routines specifying the -ldld option on the cc(1) or ld(1) command line. In 64-bit mode, you can access th...
Chapter 6 201 Shared Library Management Routines Initializers for Shared Libraries Initializers for Shared Libraries A shared library can have an initialization routine—known as aninitializer—that is called when the load module (a shared library orexecutable) is loaded (initializer) or explicitly un...
202 Chapter 6 Shared Library Management Routines Initializers for Shared Libraries $ ld -b foo.o +I my_10x_init -o libfoo.sl #include <dl.h> void my_10x_init(shl_t handle, int loading) { /* handle is the shl_load API handle for the shared library beinginitialized. */ /* loading is non-zero at ...
Chapter 6 203 Shared Library Management Routines Initializers for Shared Libraries The ld command supports the +fini option to specify theterminator. 32-bit Mode Initializers The 32-bit mode linker supports HP-UX 10.X style initializers. This section contains the following topics: • Using HP-UX 10.X...
204 Chapter 6 Shared Library Management Routines Initializers for Shared Libraries For example, to create a shared library named libfoo.sl that uses an initializer named init_foo , use this linker command line: $ ld -b -o libfoo.sl libfoo.o +I init_foo Order of Execution of Multiple Initializers . M...
Chapter 6 205 Shared Library Management Routines Initializers for Shared Libraries Accessing Initializers' Addresses . Prior to the HP-UX 10.0 release, initializer's addresses could be accessed through the initializerfield of the shared library descriptor which is returned from a call to shl_get() ....
206 Chapter 6 Shared Library Management Routines Initializers for Shared Libraries C Source for libfoo.sl #include <stdio.h>#include <dl.h>/* * This is the local initializer that is called when the libfoo.sl * is loaded and unloaded: */void init_foo(shl_t hndl, int loading){ if (loading)...
Chapter 6 207 Shared Library Management Routines Initializers for Shared Libraries if (shl_findsym(&hndl_foo, “in_to_cm”, TYPE_PROCEDURE, (void *) &in_to_cm)) perror(“shl_findsym: error finding in_to_cm”), exit(1); if (shl_findsym(&hndl_foo, “gal_to_l”, TYPE_PROCEDURE, (void *) &gal_...
Chapter 6 209 Shared Library Management Routines Initializers for Shared Libraries C Source for libtwo.sl #include <stdio.h>void load() /* called after libtwo.sl loaded */{ printf(“libtwo.sl loaded\n”);}void unload() /* called after libtwo.sl unloaded*/{ printf(“libtwo.sl unloaded\n”);} extern...
210 Chapter 6 Shared Library Management Routines Initializers for Shared Libraries TYPE_PROCEDURE, (void *) &oz_to_g)) perror(“shl_findsym: errror finding oz_to_g”), exit(1); /* * Load libtwo.sl and find the required symbols: */ if ((hndl_two = shl_load(“libtwo.sl”, BIND_IMMEDIATE, 0)) ==NULL) p...
Chapter 6 211 Shared Library Management Routines Initializers for Shared Libraries • Init/Fini style: see “Init/Fini Style Initializers” and the topics described in this section: • “Init and Fini Usage Example” • “Ordering Within an Executable or Shared Library” • “Ordering Among Executables and Sha...
212 Chapter 6 Shared Library Management Routines Initializers for Shared Libraries C source for lib3.sl (file lib3.c): lib3(){ printf(“lib3\n”); } #pragma init “lib3_init” voidlib3_init(){ printf(“lib3_init\n”); } #pragma fini “lib3_fini” voidlib3_fini(){ printf(“lib3_fini\n”); } Commands used to bu...
Chapter 6 213 Shared Library Management Routines Initializers for Shared Libraries • HP-UX 10.X style initializers are called in forward order of the +I options specified on the link line when loading a shared library. Theyare then called in reverse order when unloading the library. • HP-UX 10.X sty...
Chapter 6 215 Shared Library Management Routines The shl_load Shared Library Management Routines The shl_load Shared LibraryManagement Routines This section describes the shl_load family of shared library management routines. NOTE You can use these routines in both 32-bit and 64-bit mode. Support fo...
Chapter 6 217 Shared Library Management Routines The shl_load Shared Library Management Routines Causes the dependent libraries to be loaded breadthfirst. By default, the 64-bit mode shl_load loads dependent libraries depth-first. These flags are discussed in detail in“shl_loadExample”. address Spec...
Chapter 6 219 Shared Library Management Routines The shl_load Shared Library Management Routines Once a library is explicitly loaded, use the shl_findsym routine to get pointers to functions or data contained in the library; then call orreference them through the pointers. This is described in detai...
220 Chapter 6 Shared Library Management Routines The shl_load Shared Library Management Routines } /* * Dynamically load the shared library using BIND_IMMEDIATEbinding: */ lib_handle = shl_load( lib_path, BIND_IMMEDIATE, 0); if (lib_handle == NULL) perror(“shl_load: error loading library”), exit(1);...
Chapter 6 221 Shared Library Management Routines The shl_load Shared Library Management Routines BIND_FIRST is typically used when you want to make the symbols in a particular library more visible than the symbols of the same name inother libraries. Compare this with the default behavior, which is t...
222 Chapter 6 Shared Library Management Routines The shl_load Shared Library Management Routines BIND_FIRST | BIND_TOGETHER causes the library being loaded and its dependent libraries to be bound all at the same time, thereby resolvinginterdependencies. If you are not using BIND_FIRST , libraries ar...
Chapter 6 225 Shared Library Management Routines The shl_load Shared Library Management Routines 1. declare a pointer to a data structure of the same type as the data structure to access in the library 2. using shl_findsym with the type parameter set to TYPE_DATA , find the symbol in the shared libr...
Chapter 6 229 Shared Library Management Routines The shl_load Shared Library Management Routines Description To obtain information on currently loaded libraries, use the shl_get function. If you are programming in a threaded environment, use thethread-safe version shl_get_r which is the same as shl_...
230 Chapter 6 Shared Library Management Routines The shl_load Shared Library Management Routines The shl_gethandle and shl_gethandle_rRoutines Returns descriptor information about a loaded shared library. Syntax int shl_gethandle( shl_t handle , struct shl_descriptor ** desc ) Parameters handle The ...
Chapter 6 231 Shared Library Management Routines The shl_load Shared Library Management Routines int show_lib_info(shl_t libH){struct shl_descriptor *desc; if (shl_gethandle(libH, &desc) == -1) { fprintf(stderr, "Invalid library handle.\\n"); return -1; } printf("library path: %s\\n&...
232 Chapter 6 Shared Library Management Routines The shl_load Shared Library Management Routines Return Value If successful, shl_definesym returns 0. Otherwise, it returns − 1 and sets errno accordingly. See shl_definesym(3X) for details. Description The shl_definesym function allows you to add a ne...
Chapter 6 235 Shared Library Management Routines The shl_load Shared Library Management Routines ENOSYM Some symbol required by the shared library could notbe found. EINVAL The specified handle is invalid. ENOMEM memfunc failed to allocate the requested memory. The shl_symbol Structure The members o...
236 Chapter 6 Shared Library Management Routines The shl_load Shared Library Management Routines type The type of symbol you want to display. This is thesame as the type parameter to shl_getsymbols and can have these values: TYPE_PROCEDURE , TYPE_DATA , or TYPE_UNDEFINED . If it is TYPE_UNDEFINED , ...
238 Chapter 6 Shared Library Management Routines The shl_load Shared Library Management Routines printf PROCEDURE shl_get PROCEDURE shl_getsymbols PROCEDURE __d_trap PROCEDURE TOTAL SYMBOLS: 9 Exports: environ DATA 0x40001018 errno STORAGE 0x400011CC _SYSTEM_ID DATA 0x40001008 __dld_loc STORAGE 0x40...
240 Chapter 6 Shared Library Management Routines The dlopen Shared Library Management Routines The dlopen Shared LibraryManagement Routines This section describes the dl* family of shared library management routines. NOTE Use these routines in 64-bit mode only The dlopen Routine Opens a shared libra...
Chapter 6 241 Shared Library Management Routines The dlopen Shared Library Management Routines Return Values A successful dlopen call returns to the process a handle which the process can use on subsequent calls to dlsym and dlclose . This value should not be interpreted in any way by the process. d...
244 Chapter 6 Shared Library Management Routines The dlopen Shared Library Management Routines The symbols introduced by dlopen operations and available through dlsym are those which are “exported” as symbols of global scope by the shared library. For shared libraries, such symbols are typically tho...
Chapter 6 245 Shared Library Management Routines The dlopen Shared Library Management Routines Description dlerror returns a null-terminated character string (with no trailing newline character) that describes the last error that occurred duringdynamic linking processing. If no dynamic linking error...
Chapter 6 247 Shared Library Management Routines The dlopen Shared Library Management Routines necessary information, and use dlsym with RTLD_NEXT to find the “real” malloc , which would perform the actual memory allocation. Of course, this “real” malloc could be another user-defined interface that ...
248 Chapter 6 Shared Library Management Routines The dlopen Shared Library Management Routines The dlget Routine Retrieves information about a loaded module (program or sharedlibrary). Syntax void *dlget(unsigned int index, struct load_module_desc *desc, size_t desc_size); Parameters Return Values I...
Chapter 6 249 Shared Library Management Routines The dlopen Shared Library Management Routines struct load_module_desc { unsigned long text_base; unsigned long text_size; unsigned long data_base; unsigned long data_size; unsigned long unwind_base; unsigned long linkage_ptr; unsigned long phdr_base; ...
252 Chapter 6 Shared Library Management Routines The dlopen Shared Library Management Routines The dlgetname Routine Retrieves the name of a load module given a load module descriptor. Syntax char *dlgetname(struct load_module_desc *desc,size_t desc_size,void *(*read_tgt_mem)(void* buffer, unsigned ...
Chapter 6 253 Shared Library Management Routines The dlopen Shared Library Management Routines Return Values dlgetname returns the pathname of a load module represented by desc. If desc does not describe a loaded module, dlgetname returns NULL. Description dlgetname is one of a family of routines th...
256 Chapter 6 Shared Library Management Routines Dynamic Loader Compatibility Warnings Dynamic Loader CompatibilityWarnings Starting with the HP-UX 10.20 release, the dynamic loader generatescompatibility warnings. These warnings include linker toolset featuresthat may change over time. To display r...
Chapter 7 259 Position-Independent Code 7 Position-Independent Code This chapter discusses • “What Is Relocatable Object Code?” • “What is Absolute Object Code?” • “What Is Position-Independent Code?” • “Generating Position-Independent Code” This chapter is useful mainly to programmers who want to w...
260 Chapter 7 Position-Independent Code What Is Relocatable Object Code? What Is Relocatable Object Code? Relocatable object code is machine code that is generated bycompilers and assemblers and stored in relocatable object files, or .o files. A relocatable object file contains symbolic references t...
Chapter 7 261 Position-Independent Code What is Absolute Object Code? What is Absolute Object Code? Absolute object code is machine code that contains references toactual addresses within the program's address space. When the linkercombines relocatable object files to build a program file, or a.out ...
Chapter 7 263 Position-Independent Code Generating Position-Independent Code Generating Position-Independent Code To be position-independent, object code must restrict all references tocode and data to either PC-relative or indirect references, where allindirect references are collected in a single ...
264 Chapter 7 Position-Independent Code Generating Position-Independent Code NOPLDW -24(%sp),%rp ; restore the original rp LDSID (%rp),%r1 MTSP %r1,%sr0 BE,N 0(%sr0,%rp) ; inter-space return For More Information: The remainder of this section describes how compilers generate PIC forthe following add...
Chapter 7 265 Position-Independent Code Generating Position-Independent Code NOTE Any code which is PIC or which makes calls to PIC must follow thestandard procedure call mechanism. When linking files produced by the assembler, the linker exports onlythose assembly language routines that have been e...
266 Chapter 7 Position-Independent Code Generating Position-Independent Code LDIL L'target,%r1 BE R'target(%sr4,%r1) For PIC, these two instructions must be transformed into fourinstructions, similar to the long call sequence: BL .+8,%r1 ; get pc into r1 ADDIL L'target-L,%r1 ; add pc-relative offset...
Chapter 7 267 Position-Independent Code Generating Position-Independent Code Global and Static Variable References References to global or static variables currently require two instructionseither to form the address of a variable, or to load or store the contents ofthe variable: ; to form the addre...
Chapter 8 269 Ways to Improve Performance 8 Ways to Improve Performance The linker provides several ways you can improve your applicationperformance. • “Linker Optimizations” describes how the linker -O option removes unnecessary ADDIL instructions and “dead” or unused procedures. • “Options to Impr...
270 Chapter 8 Ways to Improve Performance Linker Optimizations Linker Optimizations The linker supports the -O option which performs the following optimizations at link time: • optimizes references to data by removing unnecessary ADDIL instructions from the object code. • removes procedures that can...
Chapter 8 271 Ways to Improve Performance Linker Optimizations NOTE With the HP-UX 10.0 release, you can also invoke linker optimizations atlevels 2 and 3 by using the +Ofastaccess or +Oprocelim option. See Also: For a brief description of compiler optimization options see “Selecting anOptimization ...
272 Chapter 8 Ways to Improve Performance Linker Optimizations subspaces. Merged subspaces can prevent the removal of deadprocedures. Therefore, it is optimal to have each procedure in its ownsubspace. Complete Executables For complete executables, dead procedure elimination removes anytext subspace...
Chapter 8 273 Ways to Improve Performance Options to Improve TLB Hit Rates Options to Improve TLB Hit Rates To improve Translation Lookaside Buffer (TLB) hit rates in anapplication running on a PA 8000-based system, use the following linkeror chatr virtual memory page setting options: • +pd size — r...
274 Chapter 8 Ways to Improve Performance Profile-Based Optimization Profile-Based Optimization In profile-based optimization (PBO), the compiler and linker worktogether to optimize an application based on profile data obtained fromrunning the application on a typical input data set. For instance, i...
Chapter 8 275 Ways to Improve Performance Profile-Based Optimization When to Use PBO PBO should be the last level of optimization you use when building anapplication. As with other optimizations, it should be performed after anapplication has been completely debugged. Most applications will benefit ...
276 Chapter 8 Ways to Improve Performance Profile-Based Optimization A Simple Example Suppose you want to apply PBO to an application called sample . The application is built from a C source file sample.c . Discussed below are the steps involved in optimizing the application. Step 1 Instrumentation ...
278 Chapter 8 Ways to Improve Performance Profile-Based Optimization The Startup File icrt0.o The icrt0.o startup file uses the atexit system call to register the function that writes out profile data. (For 64-bit mode, the initializationcode is in /usr/ccs/lib/pa20_64/fdp_init.0 .) That function is...
Chapter 8 279 Ways to Improve Performance Profile-Based Optimization A simpler approach would be to compile foo.c and bar.c with a single cc command: $ cc -v +I -O -o foobar bar.c foo.c/opt/langtools/lbin/cpp bar.c /var/tmp/ctm352/opt/ansic/lbin/ccom /var/tmp/ctm352 bar.o -O2 -I/opt/langtools/lbin/c...
Chapter 8 281 Ways to Improve Performance Profile-Based Optimization Storing Profile Information for Multiple Programs A single flow.data file can store information for multiple programs. This allows an instrumented program to spawn other instrumentedprograms, all of which share the same flow.data f...
282 Chapter 8 Ways to Improve Performance Profile-Based Optimization Sharing the flow.data File Among Multiple Processes A flow.data file can potentially be accessed by several processes at the same time. For example, this could happen when you run more than oneinstrumented program at the same time ...
284 Chapter 8 Ways to Improve Performance Profile-Based Optimization Using The flow.data File By default, the code generator and linker look for the flow.data file in the current working directory. In other words, the flow.data file created during the profiling phase should be located in the directo...
Chapter 8 285 Ways to Improve Performance Profile-Based Optimization Specifying a Different Program Name (+pgm) When retrieving a program's profile data from the flow.data file, the linker uses the program's basename as a lookup key. For instance, if aprogram were compiled as follows, the linker wou...
286 Chapter 8 Ways to Improve Performance Profile-Based Optimization +O2 Full optimization within each procedure in a file. (Canalso be invoked as -O .) +O3 Full optimization across all procedures in an object file.Includes subprogram inlining. +O4 Full optimization across entire application, perfor...
288 Chapter 8 Ways to Improve Performance Profile-Based Optimization Notice in the example above, that the +pgm option was necessary because the output file name differs from the instrumented program file name. NOTE If you are using -r and C++ templates, check "Known Limitations" in the HP C...
290 Chapter 8 Ways to Improve Performance Profile-Based Optimization $ cc +I +O3 -c file.c Create I-SOM for instrumentation. $ cc +I +O3 file.o Link with instrumentation. $ a.out < input_file Run instrumented executable with representative input data. $ cc +P +O3 file.o Perform PBO and HLO. Repla...
Chapter 8 291 Ways to Improve Performance Profile-Based Optimization nm . The nm command works on I-SOM files. However, since code generation has not yet been performed, some of the imported symbolsthat might appear in an ordinary relocatable object file will not appear inan I-SOM file. ar . I-SOM f...
Chapter 8 293 Ways to Improve Performance Improving Shared Library Start-Up Time with fastbind Improving Shared Library Start-UpTime with fastbind The fastbind tool improves the start-up time of programs that use shared libraries. When fastbind is invoked, it caches relocation information inside the...
294 Chapter 8 Ways to Improve Performance Improving Shared Library Start-Up Time with fastbind Invoking fastbind from the Linker To invoke fastbind from ld , pass the request to the linker from your compiler by using the -Wl , +fb options. For example: $ ld -b convert.o volume.o -o libunits.sl Build...
295 A Using Mapfiles The ld command automatically maps sections from input object files onto output segments in executable files. The mapfile option allows youto change the default mapping provided by the linker. NOTE The mapfile option is supported only in 64-bit mode linking. NOTE In most cases, t...
296 Appendix A Using Mapfiles Controlling Mapfiles with the -k Option Controlling Mapfiles with the -k Option The -k option to ld specifies a text file containing mapfile directives: ld -k mapfile [ flags ] files ... The ld command automatically maps sections from input object files onto output segm...
298 Appendix A Using Mapfiles Changing Mapfiles with -k filename and +nodefaultmap Changing Mapfiles with -k filename and+nodefaultmap The +nodefaultmap option used with -k option prevents the linker from concatenating the default memory map to the map provided byfilename. If you specify +nodefaultm...
300 Appendix A Using Mapfiles Simple Mapfile Simple Mapfile The following directives show how a simple mapfile would appear: # text segment text = LOAD ?RX; text : .rodata ?A; text : $PROGBITS ?AX; # data segment data = LOAD ?RW; data : $PROGBITS ?AW!S; data : $PROGBITS ?AWS; data : $NOBITS ?AWS; da...
Appendix A 303 Using Mapfiles Defining Syntax for Mapfile Directives Defining Syntax for Mapfile Directives A mapfile can have zero or more mapfile directives. There are two typesof mapfile directives: segment declarations and section mappingdirectives. The directives can span across lines and are t...
304 Appendix A Using Mapfiles Defining Mapfile Segment Declarations Defining Mapfile Segment Declarations A segment declaration can create a new segment with a set of attributesor change the attributes of an existing segment. segment_name = { segment_attribute_value }* ; The segment attributes and t...
Appendix A 305 Using Mapfiles Defining Mapfile Segment Declarations The default segment_flags for a LOADable segment is ?RWX . Segment declarations support the following special flags: Flag Action R Readable W Writable X Executable Flag Action s Enables static branch prediction on a segment. This fl...
306 Appendix A Using Mapfiles Defining Mapfile Segment Declarations Mapfile Segment Declaration Examples • The following example declares a segment with segment_type LOAD and segment_flags readable and executable. text = LOAD ?RX; • The following example declares a LOADable segment (default) with se...
Appendix A 307 Using Mapfiles Defining Mapfile Section Mapping Directives Defining Mapfile Section MappingDirectives A section mapping directive specifies how the linker should map theinput section onto output segments. This directive tells the linker whatattributes of a section must be matched in o...
Appendix A 309 Using Mapfiles Internal Map Structure Internal Map Structure The linker use a default map structure corresponding to the defaultmapfile. When you use the mapfile option with the ld command, the linker appends the default mapfile to the end of your user-specifiedmapfile. (You can overr...
Appendix A 313 Using Mapfiles Mapfile Option Error Messages Mapfile Option Error Messages Fatal Errors The following conditions can result in a fatal error: • Specifying more than one -k option on the command line • Mapfile cannot be opened or read • The linker finds a syntax error in the mapfile • ...
Glossary 315 Glossary absolute object code Machinecode that contains absolute virtualaddresses. Created by the linkerwhen it combines relocatableobject files. archive library A library,created by the ar command, which contains one or more objectmodules. By convention, archivelibrary file names end w...
Glossary 317 Glossary dynamic loading library AnSVR4 term for a shared library. dynamic search path Theprocess that allows the location ofshared libraries to be specified atruntime. entry point The location atwhich a program starts runningafter HP-UX loads it into memory.The entry point is defined b...
318 Glossary Glossary header string A string," !<arch>\n ", which identifies a file as an archive created by ar ( \n represents the newline character). hiding a symbol Making asymbol invisible to code outside themodule in which the symbol wasdefined. Accomplished with the -h linker opt...
320 Glossary Glossary is that program executioncontinues even if the dynamicloader cannot resolve symbols. object code See relocatableobject code. object file A file containingmachine language instructions anddata in a form that the linker canuse to create an executableprogram. object module A file ...
Glossary 321 Glossary profile data obtained from runningthe application on a typical inputdata set. relocatable object code Machine code that is generated bycompilers and assemblers. It isrelocatable in the sense that itdoes not contain actual addresses;instead, it contains symbolscorresponding to a...
322 Glossary Glossary standard input/output library A collection of routines thatprovide efficient and portableinput/output services for most Cprograms. standard output The defaultstream for sending characteroutput data — usually connectedto the screen. startup file Also known as crt0.o , this is th...
Index Index 325 Symbols $LIT$ text space and performance , 148 $START$ symbol , 43 $TEXT$ space and performance , 148 +b linker option , 176 , 178 +b path_list linker option , 84 , 104 , 145 +cg linker option , 28 +compat linker option , 25 , 90 +DA compiler option , 21 +df compiler and linker optio...
Kenwood Manuals
-
Kenwood VR-2080
User Manual
-
Kenwood VR-2080
Manual
-
Kenwood CD-224M
User Manual
-
Kenwood CD-224M
Manual
-
Kenwood HTB-505
User Manual
-
Kenwood VR-2090
User Manual
-
Kenwood VR-2090
Manual
-
Kenwood KR-797
User Manual
-
Kenwood KR-797
Manual
-
Kenwood 1070VR
User Manual
-
Kenwood 1070VR
Manual
-
Kenwood 1080VR
User Manual
-
Kenwood 1080VR
Manual
-
Kenwood 144MHz FM TRANSCEIVER K2E
User Manual
-
Kenwood 25th Anniversary Products XXV-02A
User Manual
-
Kenwood 25th Anniversary Products XXV-03A
User Manual
-
Kenwood 411
User Manual
-
Kenwood 411
Manual
-
Kenwood 5-CHANNEL POWER AMPLIFIER KAC-959
User Manual
-
Kenwood 50 MHZ ALL MODE TRANSCEIVER TS-590S
User Manual