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, the linker does not export these two routines in the
a.out.
ld main.o +hideallsymbols -L. -lfoo -lc
elfdump -t a.out
a.out:
...
.symtab
index Type Bind Other SectValueSizeName
1 FUNC LOCL 00xb 0x4000000000001104 0test
...
10FUNCLOCL00xb0x40000000000012000func
Changing Mapfiles with -k and +nodefaultmap
The linker automatically maps sections from input object files onto
output segments in executable files. These options to the ld command
allow you to change the linker’s default mapping.
Use the -k filename option to provide a memory map. The linker uses
the file specified by filename as the output file memory map.
The +nodefaultmap option used with -k option prevents the linker
from concatenating the default memory map to the map provided by
filename. If you specify +nodefaultmap, the linker does not append the
default mapfile to your mapfile. If you do not specify +nodefaultmap
with -k, the linker appends the output file to the default mapfile.
NOTE In most cases, the linker produces a correct executable without the use of
the mapfile option. The mapfile option is an advanced feature of the
linker toolset intended for systems programming use, not application
programming use. When using the mapfile option, you can create
executable files that do not execute.
For more information on mapfiles and examples using these options, see
Appendix A, “Using Mapfiles,” on page 295.