G
glen herrmannsfeldt
(snip)
Before there was C, there was Fortran and BLOCK DATA, which requires
a similar implementation. So, linkers would already know how to do
this even if implemented before C existed.
The OS/360 linker, for example, takes the first CSECT that it finds
if there are duplicates. That allows for the actual editing in the
name linkage editor. If you need to replace one CSECT in a previously
compiled and linked program, load the new one in, then INCLUDE the
old load module. The linkage editor keeps the new CSECT in place of
the old one with the same name, updates all the address constants,
and everything works.
Or a fancier linker than we usually have.
-- glen
Well, yes. Mechanisms are the domain of implementers, they are outside
the scope of the C standard. Consider files containing the following
lines, among others:
Before there was C, there was Fortran and BLOCK DATA, which requires
a similar implementation. So, linkers would already know how to do
this even if implemented before C existed.
The OS/360 linker, for example, takes the first CSECT that it finds
if there are duplicates. That allows for the actual editing in the
name linkage editor. If you need to replace one CSECT in a previously
compiled and linked program, load the new one in, then INCLUDE the
old load module. The linkage editor keeps the new CSECT in place of
the old one with the same name, updates all the address constants,
and everything works.
The standard says the behavior is undefined if file1 and file2 are both
linked into the same program. Otherwise, if file1 and victim are linked
into a single strictly conforming program, the value of table_max in
that program must be 100. If file2 and victim are linked, it must be
200. The standard doesn't specify the mechanism used to achieve this,
but it does require that some mechanism be used to make it happen.
The difference is that C mandates the behavior we describe, regardless
of what mechanism is used to achieve it. To have the behavior occur at
compile time, as you described, file1.c or file2.c would have to be
#included into victim.c during the compilation phase, rather than linked
to it after compilation. As far as C is concerned, "victim.c + #included
file1.c" is one translation unit, and "victim.c + #included file2.c"
would be a different one.
Or a fancier linker than we usually have.
-- glen