Commit Graph

10 Commits

Author SHA1 Message Date
Kuba (Brecka) Mracek
db18deaf91 Add a SWIFT_RUNTIME_MACHO_NO_DYLD stdlib mode that doesn't dynamically look up sections in modules, and only assumes a single static module (#33441) 2020-08-18 11:46:42 -07:00
Saleem Abdulrasool
0c42b57962 ELF: restructure image metadata registration
Restructure the ELF handling to be completely agnostic to the OS.
Rather than usng the loader to query the section information, use the
linker to construct linker tables and synthetic markers for the
beginning and of the table.  Save off the values of these pointers and
pass them along through the constructor to the runtime for registration.

This removes the need for the begin/end objects.  Remove the special
construction of the begin/end objects through the special assembly
constructs, preferring to do this in C with a bit of inline assembly to
ensure that the section is always allocated.

Remove the special handling for the various targets, the empty object
file can be linked on all the targets.

The new object file has no requirements on the ordering.  It needs to
simply be injected into the link.

Name the replacement file `swiftrt.o` mirroring `crt.o` from libc.  Merge
the constructor and the definition into a single object file.

This approach is generally more portable, overall simpler to implement,
and more robust.

Thanks to Orlando Bassotto for help analyzing some of the odd behaviours
when switching over.
2017-11-28 10:04:04 -08:00
Simon Evans
5c993b45db [runtime] Remove swift_addNewDSOImage() call from static ELF binaries
- Create separate swift_begin.o/swift_end.o for lib/swift and
  lib/swift_static. The static swift_begin.o does not call
  swift_addNewDSOImage() at startup.

- Update ToolChains.cpp to use the correct swift_begin.o/swift_end.o
  files for the `-static-stdlib` and `-static-executable` options.
2017-01-27 14:04:58 +00:00
Simon Evans
e07c0d21c2 [runtime] Binary section data loading for extra ELF images
- For ELF targets, keep track of shared objects as they are
  dynamically loaded so that section data can be added to
  the protocol conformance and type metadata caches after
  initialisation (rdar://problem/19045112).
2017-01-27 10:28:46 +00:00
Simon Evans
22b5e6d57b [runtime] Implement lookupSymbol() for ELF static executables 2017-01-09 10:56:29 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
16d6dce62e [gardening] Fix recently introduced typos. 2016-12-16 21:42:09 +01:00
practicalswift
568a3e46ba [gardening] Improve header consistency. 2016-12-02 01:47:38 +01:00
Simon Evans
707588c962 [SR-648] ELF static binary fixes
- Revert the use of SWIFT_RUNTIME_EXPORT in ImageInspectionELF.cpp and
  fix the unittests by explicitly adding the file to the list

- Revert the change of section data names
2016-11-30 18:39:16 +00:00
Simon Evans
1daa3ee1f8 [SR-648] Add option to create statically linked binaries
- Add ImageInspectionStatic.cpp to lookup protocol conformance
  and metadata sections in static binaries

- For Linux, build libswiftImageInspectionShared.a and
  libswiftImageInspectionStatic.a for linking with libswiftCore.a.
  This allows static binaries to be built without linking to
  libdl. libswiftImageInspectionShared (ImageInspectionELF.cpp) is
  automatically compiled into libswiftCore.so

- Adds -static-executable option to swiftc to use along with
  -emit-executable that uses linker arguments in
  static-executable-args.lnk. This also requires a libicu
  to be compiled using the --libicu which has configure options
  that dont require libdl for accessing ICU datafiles

- Static binaries only work on Linux at this time
2016-11-29 13:36:19 +00:00