Binding of References
eld Manual—527255-009
3-17
Accepting Multiply-Defined Symbols
In linkfiles, entries in the ELF symbol table tell the source language for each symbol.
When there are multiple entries of the same name that have been defined and
allocated by the compiler or assembler, the rules followed by the linker in deciding
which copy to keep are found in
Accepting Multiply-Defined Symbols
on page 3-17.
If there is only one entry that has been defined and allocated by the compiler or
assembler, the linker keeps that one. If there are no such entries, but there is an entry
for the symbol as common data, the linker will choose such an entry and allocate the
symbol in the
.bss
section. If there are multiple common data entries for a symbol, the
linker chooses the first one among those with the largest size. Otherwise all the
entries are just external references, and the symbol remains an external reference in
the output file, with the linker keeping the first one it sees.
The
-y
option tells the linker to print out information about a symbol of a given name,
telling the names of the linkfiles that mentioned the symbol in their ELF symbol tables
and giving the information provided about the symbol in each of those files.
Object files also contain DWARF symbol table information for the use of debuggers.
See
Updating Or Stripping DWARF Symbol Table Information
on page 4-14.
Accepting Multiply-Defined Symbols
This section is only concerned with symbols that are defined and allocated by the
compiler or assembler, not with symbols that are external references or common data.
This section covers global definitions, which make it possible to have multiple
definitions of the same symbol. Multiple definitions are only allowed if all the definitions
are as data items, or if all the definitions are as procedures, with different rules for the
two cases as described below.
Rules For Data Items
Here are the rules concerning multiple definitions of a data item:
•
A symbol of a given name that occurs in one the sections named
.dat
a,
.sdat
a,
.bs
s, and
.sbs
s, is allowed to come up in different sections among these four
possibilities in different linkfiles. Similarly, a symbol of a given name that occurs
in one of the sections named
.rdata
and
.srdata
is allowed to come up in
different setions among these two possibilities in different linkfiles. A symbol
that occurs in any other data section must only occur in that same named data
section in all the linker’s input linkfiles.
•
eld
reports an error if an initialized data item (including "zero-initialized" data
items found in the .bss or .sbss sections, which in the case of C++ also
includes data that was not explicitly initialized in the source) is defined in more
than one C or C++ file unless the
STO_MULTIPLE_DEF_OK
bit is set in all the
corresponding ELF symbol table entries. HP’s definitions of C and C++ say
that it is an error for users to create such situations, but the
STO_MULTIPLE_DEF_OK
bit allows the compiler to do it.
Содержание eld
Страница 4: ......
Страница 8: ...Contents eld Manual 527255 009 iv ...
Страница 12: ...What s New in This Manual eld Manual 527255 009 viii Changes to the 527255 005 Manual ...
Страница 34: ...Introduction to eld eld Manual 527255 009 1 14 Example of Use ...
Страница 54: ...eld Input and Output eld Manual 527255 009 2 20 Using Archives ...
Страница 98: ...Other eld Processing eld Manual 527255 009 4 20 Merging Source RTDUs ...
Страница 242: ...Output Listings and Error Handling eld Manual 527255 009 6 132 Glossary of Errors ...