On May 19, 2:34 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
Quote:
The Architect wrote:
Quote:
If I have the same symbol in the .data section of 2 obj files, LD
gives a multiple declaration error on linking? Would like to know the
reason for this (diab only issues a warning)
Quote:
I would *guess* is that LD is not designed to handle multiple
definitions of the same symbol. BTW, that is what the C++ language
Standard also requires: one and only one definition of any symbol in
your program. So, your linker seems to be enforcing the ODR.
Only very, very partially. It probably won't complain if he has
`extern double x;' in once module, and `int x;' in another.
Quote:
Quote:
Also what if the symbols were in any other section (.rdata
or .text)?
Quote:
The term "section" is not defined by the language Standard.
And the usual word for them is "segment":-).
Classically, a linker will expect that there is one, and only
one, definition for each symbol, regardless of the segment it's
in. Most linkers also support other conventions as well,
depending on how the symbol is declared in the object file
(which, of course, is up to the compiler): support for Fortran's
common data or for multiple template instantiations (usually by
means of weak references) comes to mind. (Some early C
compilers declared each global variable as if it were a Fortran
common data; this isn't conform with the standard, however.)
Quote:
Quote:
Or which sections of obj files can be merged even if they
have overlapping symbol names?
Quote:
That's seems like a question you need to ask in the compiler-
or platform-specific newsgroup.
While this isn't really the place for such questions, there is a
lot of commonality in how linkers work---comp.compilers might be
an acceptable place. (I would suggest a good book about linking
first, but I don't know of one off hand.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34