Link with mixed IR/non-IR objects

Cary Coutant ccoutant@gmail.com
Tue May 3 05:51:00 GMT 2011


>> For something more like the object-inside-a-section solution, I don't
>> see why section groups couldn't be made to work. ELF has a group type
>> that currently defines only the one type of group (COMDAT). You could
>> define a new type of group that would contain the mixed compiled-code
>> and IR sections from a mixed-IR input file, and the result of an ld -r
>> over a mixed input would contain regular sections representing the
>> combination of the non-IR inputs, and a group of sections for each IR
>> input.
>
> Won't work without using separate symbol tables or an extension to
> mark symbols as IR-only.  The linker should detect when a symbol is
> only defined in IR files and report an error if the symbol is then
> referenced in a relocation.

No extension is necessary -- if the symbol is defined in an IR input,
the st_shndx field will point to a member of an IR section group.
There shouldn't be a problem with relocations that reference such a
symbol -- it would be just like a non-IR object that references a
symbol defined in an IR file. Just like COMDAT groups, it's OK to
reference a global symbol from outside the group, but not OK to
reference a local symbol from outside.

In this model, the plugin would tell the linker that it's claiming the
IR section groups but leaving everything else as if it was a normal
object file to be linked. The linker would then ignore the IR groups,
treating symbol definitions in those groups as UNDEFs, with any
relocations to those symbols being references from outside the IR
world.

For complete consistency, IR files generated by the compiler should
put all the sections inside an IR group. Then we'd have a consistent
model -- IR-only files would have just IR sections in an IR group;
"fat" files would have both IR and compiled sections in an IR group;
and "mixed" (ld -r) files would have multiple IR groups plus regular
compiled sections not in an IR group.

IR groups could be IR-only or fat. When running without a plugin, the
linker would process fat groups as regular sections (ignoring the IR
sections like it does today), and would need to give an error if it
finds an IR-only group (don't remember if we're smart enough to do
that today with an IR-only file).

-cary



More information about the Binutils mailing list