File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,16 @@ extension GenericUnixToolchain {
119119 }
120120 }
121121
122+ if targetTriple. os == . openbsd && targetTriple. arch == . aarch64 {
123+ let btcfiEnabled = targetInfo. target. openbsdBTCFIEnabled ?? false
124+ if !btcfiEnabled {
125+ commandLine. appendFlag ( " -Xlinker " )
126+ commandLine. appendFlag ( " -z " )
127+ commandLine. appendFlag ( " -Xlinker " )
128+ commandLine. appendFlag ( " nobtcfi " )
129+ }
130+ }
131+
122132 let staticStdlib = parsedOptions. hasFlag ( positive: . staticStdlib,
123133 negative: . noStaticStdlib,
124134 default: false )
Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ public struct FrontendTargetInfo: Codable {
101101 /// Whether the Swift libraries need to be referenced in their system
102102 /// location (/usr/lib/swift) via rpath.
103103 let librariesRequireRPath : Bool
104+
105+ let openbsdBTCFIEnabled : Bool ?
104106 }
105107
106108 @_spi ( Testing) public struct Paths : Codable {
Original file line number Diff line number Diff line change @@ -164,12 +164,14 @@ public final class GenericUnixToolchain: Toolchain {
164164 }
165165
166166 if driver. targetTriple. os == . openbsd && driver. targetTriple. arch == . aarch64 {
167- commandLine. appendFlag ( . Xcc)
168- commandLine. appendFlag ( " -Xclang=-msign-return-address=non-leaf " )
169- commandLine. appendFlag ( . Xcc)
170- commandLine. appendFlag ( " -Xclang=-msign-return-address-key=a_key " )
171- commandLine. appendFlag ( . Xcc)
172- commandLine. appendFlag ( " -Xclang=-mbranch-target-enforce " )
167+ if frontendTargetInfo. target. openbsdBTCFIEnabled ?? false {
168+ commandLine. appendFlag ( . Xcc)
169+ commandLine. appendFlag ( " -Xclang=-msign-return-address=non-leaf " )
170+ commandLine. appendFlag ( . Xcc)
171+ commandLine. appendFlag ( " -Xclang=-msign-return-address-key=a_key " )
172+ commandLine. appendFlag ( . Xcc)
173+ commandLine. appendFlag ( " -Xclang=-mbranch-target-enforce " )
174+ }
173175 }
174176 }
175177}
You can’t perform that action at this time.
0 commit comments