[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Patchless modification of Lua source code
- From: Philipp Janda <siffiejoe@...>
- Date: Sat, 24 Nov 2018 02:40:24 +0100
Am 23.11.18 um 06:47 schröbte Sean Conner:
8 All external object and function references are resolved. Library
components are linked to satisfy external references to functions
and objects not defined in the current translation. All such
translator output is collected into a program image which contains
information needed for execution in its execution environment.
I interpret this to mean, "if the given object files do not include an
object or function with external linkage, then said objects or functions can
be pulled from a "library".
Which library if there were multiple ones containing the same external
I interpret it differently. I think "translation" still means the
translation of a single translation unit (i.e. a single object file) as
in all other translation phases before. So you resolve as many undefined
external references in the object file as you can using libraries, and
the remaining ones are resolved from other compiled translation units
when "all such translator output is collected into a program image".
Anyway, the effect is exactly the same as with your interpretation as
long as "In the set of translation units and libraries that constitutes
an entire program, each declaration of a particular identifier with
external linkage denotes the same object or function" (6.2.2) and
"somewhere in the entire program there shall be exactly one external
definition for the identifier; otherwise, there shall be no more than
Btw., GNU ld is in violation of your interpretation of the C standard as
I have shown in one of my examples earlier (details here):
$ gcc -o main main.c a.o -L. -lb
./libb.a(b.o): In function `a':
b.c:(.text+0x0): multiple definition of `a'
a.o:a.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
Function `a()` shouldn't have been pulled from `libb.a` because `a.o`
already contains an external definition for that identifier.
GNU ld doesn't pull individual functions or objects from the library. It
just filters out those object files in the library that it thinks it
-spc (If at this point you don't think this interpretation holds, I'd like to
hear the argument against it)