HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 11 (of 101)
Chapter 11 Software Development
October 29, 2013
Symbols from HelloWorld.o:
[Index] Value Size Type Bind O Shndx Name
[0] | 0| 0|NOTYP|LOCAL|0| UNDEF|
[8] | 0| 0|SECT
|LOCAL|0|.HP.opt_annot|.HP.opt_annot
[7] | 0| 0|SECT
|LOCAL|0|.IA_64.unwind_info|.IA_64.unwind_info
[3] | 0| 0|SECT
|LOCAL|0|.debug_actual|.debug_actual
[2] | 0| 0|SECT
|LOCAL|0|.debug_line|.debug_line
[6] | 0| 0|SECT
|LOCAL|0|.debug_procs_abbrev|.debug_procs_abbrev
[4] | 0| 0|SECT |LOCAL|0|
.rodata|.rodata
[5] | 0| 0|SECT |LOCAL|0| .text|.text
[1] | 0| 0|FILE |LOCAL|0|
ABS|HelloWorld.c
[10] | 0| 112|FUNC |GLOB |0| .text|main
[9] | 0| 0|FUNC |GLOB |0| UNDEF|printf
$
All addresses of exported symbols are kept relative, all references to imported symbols are left
unspecified. This is important for the link phase. The objects are called relocatable, which means
they can be placed at any address in an executable.
Object files can be collected in archive libraries, using the ar(1) command. This archiving does
not directly contribute to the build process. It is just a possibility to provide a set of objects in a
single file.
Name Mangling
Object oriented programming languages like aC++ and Java allow multiple methods with the
same name, but different parameters. This is called overloading”. Because the linker doesn’t
know and doesn’t care for the parameters of a method, the compiler must somehow encode the
parameter types in the symbol names, to distinguish overloaded methods. This is called name
mangling. The resulting symbol names in the objects and executables can be displayed with
nm(1):
$ cat x.C
void sub(int) {};
void sub(char) {};
$ aCC c x.C
$ nm x.o
On PA: