Implement ELF protocol conformance loading.

This works by loading the protocols from a specially named symbol,
which is generated by the linker through the help of a linker script
that merges all of the protocol conformance blocks into one section
with its size at the start of it and points a global symbol at
the section.

We do all this because unlike MachO, section information does not
survive to be loaded into memory with ELF binaries. Instead,
the mappings that survive are 'segments', which contain one or
more sections. Information about how these relate to their original
sections is difficult, if not impossible, to obtain at runtime.

Swift SVN r23518
This commit is contained in:
Graham Batty
2014-11-21 17:09:48 +00:00
parent 9ba13cd93a
commit 17b1721f8f
9 changed files with 160 additions and 67 deletions

View File

@@ -669,6 +669,10 @@ Job *linux::Linker::constructJob(const JobAction &JA,
Arguments.push_back("-lswiftCore");
// Add the linker script that coalesces protocol conformance sections.
Arguments.push_back("-Xlinker");
Arguments.push_back("-Tswift.ld");
// This should be the last option, for convenience in checking output.
Arguments.push_back("-o");
Arguments.push_back(Output->getPrimaryOutputFilename().c_str());