HP-UX Linker and Libraries User's Guide

The linker command line gets lengthy and difficult to read if several such options are specified. In
fact, you exceed the maximum HP-UX command line length if you specify too many options. To
get around this, use ld linker option files, described under “Passing Linker Options in a file with
-c (page 44) . You can specify any number of -h or +e options in this file.
You can use -h or +e options when building a shared library (with -b), combining .o files ( with
-r), and when linking to create an a.out file.
Emitting debug information in a separate file
Valid for executable and shared library links with +noobjdebug option. Instructs the linker to
dump all debug information in a separate file specified in filename and not include them in the
executable. The HP debugger (WDB 6.2 and later) supports the separate debug information file
during debugging. This option is useful to create an executable without debug information and
retain the debug information for later use. It also helps to reduce the size of the executable.
Use the +dbgfile option to create a separate debug information file. This option takes a filename
as an argument.
The following example shows the result of creating a separate debug information file using the
+dbgfile option.
Example 1 Create a separate debug information file using +dbgfile option
$cc -g example.c -Wl,+dbgfile,a.out.dbg -o a.out
$elfdump -S -h a.out.dbg | grep '\.debug'
31 PBIT 00000000 0000051a 000003fb .debug_macinfo
32 PBIT 00000000 00000915 000000c7 .debug_abbrev
33 PBIT 00000000 000009dc 00000405 .debug_info
34 PBIT 00000000 00000de1 000000df .debug_line
35 PBIT 00000000 00000ec0 00000032 .debug_actual
36 PBIT 00000000 00000ef2 00000030 .debug_procs_abbrev
37 PBIT 00000000 00000f22 0000005b .debug_procs_info
In this example, the name of the separate debug information file is a.out.dbg and it is provided
as the argument to the linker option +dbgfile. This creates a file by name a.out.dbg which
contains all the debug information.
Linker gives out information about the debug file in the executable, and the debugger automatically
picks up the debug information file. As seen through the elfdump output, all the .debug_ sections
are in a.out.dbg file.
This feature is available only on Integrity systems.
Exporting Symbols with +ee
Like the +e option, the +ee option allows you to export symbols. However, this option, the option
does not alter the visibility of other symbols in the file. It exports the specified symbol, and does
not hide any of the symbols exported by default.
Exporting Symbols from main with -E
In PA-32 mode, the linker exports from a program only those symbols that were imported by a
shared library. For example, if a shared executable's libraries do not reference the program's main
routine, the linker does not include the main symbol in the a.out file's export list. Normally, this
is a problem only when a program calls shared library management routines (described in “Shared
Library Management Routines” (page 136)). To make the linker export all symbols from a program,
invokeld with the -E option.
In IPF/PA-64 mode, the behavior is specified by -E is the default behavior. The +e option allows
you to be more selective about which symbols are exported, resulting in better performance. For
more information on +e, see “Exporting Symbols with +e (page 37).
38 Determining How to Link Programs or Libraries (Linker Tasks)