You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The whole main Swift program seems to reside at fixed addresses. On macOS, everything seems fine.
Repro
The following command creates a simple Swift program that just crashes (and as a side-effect prints addresses), then compiles and executes it 10 times.
Hopefully setting -fpie will also help with some of the obscure linker bugs some people are seeing, since some of the things ELF linkers try to do with non-PIE executables are fundamentally at odds with Swift's resilience goals, such as using copy relocations to copy fixed-size globals into fixed addresses in the executable.
It sounds like we may want to be more specific about when we pass `-pie`, since clang warns about the argument being unused in some situations: https://bugs.swift.org/browse/SR-5721
Additional Detail from JIRA
md5: f27c5ea608b19e3f52b4ecaecf00b78c
relates to:
Issue Description:
Problem
On Linux, Swift executables don't seem to be position-independent executables (https://en.wikipedia.org/wiki/Position-independent_code). That's a security issue as it will make exploitation pretty easy (building a ROP chain (https://en.wikipedia.org/wiki/Return-oriented_programming) from known addresses).
The whole main Swift program seems to reside at fixed addresses. On macOS, everything seems fine.
Repro
The following command creates a simple Swift program that just crashes (and as a side-effect prints addresses), then compiles and executes it 10 times.
Linux
the addresses 0x400a90 and 0x400909 are the same for all the 10 runs.
macOS
as expected, we see different addresses: 0x10150a580, 0x10bb5d580, 0x10b54c580.
Versions and stuff
macOS 10.12.5 (16F2104)
Ubuntu Xenial
Linux swiftc: Swift version 4.0-dev (LLVM 2c7b572db2, Clang 54c8e38855, Swift d9fb110)
The text was updated successfully, but these errors were encountered: