| ... | @@ -395,7 +395,7 @@ pub const Object = struct { | ... | @@ -395,7 +395,7 @@ pub const Object = struct { |
| 395 | } | 395 | } |
| 396 | | 396 | |
| 397 | { | 397 | { |
| 398 | var module_flags = try std.array_list.Managed(Builder.Metadata).initCapacity(o.gpa, 8); | 398 | var module_flags = try std.array_list.Managed(Builder.Metadata).initCapacity(o.gpa, 11); |
| 399 | defer module_flags.deinit(); | 399 | defer module_flags.deinit(); |
| 400 | | 400 | |
| 401 | const behavior_error = try o.builder.metadataConstant(try o.builder.intConst(.i32, 1)); | 401 | const behavior_error = try o.builder.metadataConstant(try o.builder.intConst(.i32, 1)); |
| ... | @@ -492,6 +492,20 @@ pub const Object = struct { | ... | @@ -492,6 +492,20 @@ pub const Object = struct { |
| 492 | })); | 492 | })); |
| 493 | } | 493 | } |
| 494 | | 494 | |
| | 495 | // The frontend should eventually offer options to control these. |
| | 496 | if (target.cpu.arch.isAarch64() and target.os.tag == .openbsd) { |
| | 497 | module_flags.appendAssumeCapacity(try o.builder.metadataTuple(&.{ |
| | 498 | behavior_min, |
| | 499 | (try o.builder.metadataString("branch-target-enforcement")).toMetadata(), |
| | 500 | try o.builder.metadataConstant(try o.builder.intConst(.i32, 2)), |
| | 501 | })); |
| | 502 | module_flags.appendAssumeCapacity(try o.builder.metadataTuple(&.{ |
| | 503 | behavior_min, |
| | 504 | (try o.builder.metadataString("sign-return-address")).toMetadata(), |
| | 505 | try o.builder.metadataConstant(try o.builder.intConst(.i32, 2)), |
| | 506 | })); |
| | 507 | } |
| | 508 | |
| 495 | try o.builder.addNamedMetadata(try o.builder.string("llvm.module.flags"), module_flags.items); | 509 | try o.builder.addNamedMetadata(try o.builder.string("llvm.module.flags"), module_flags.items); |
| 496 | } | 510 | } |
| 497 | | 511 | |
| ... | @@ -2228,6 +2242,22 @@ pub const Object = struct { | ... | @@ -2228,6 +2242,22 @@ pub const Object = struct { |
| 2228 | // above, this should be revisited if `softfp` support is added. | 2242 | // above, this should be revisited if `softfp` support is added. |
| 2229 | try attributes.addFnAttr(.noimplicitfloat, &o.builder); | 2243 | try attributes.addFnAttr(.noimplicitfloat, &o.builder); |
| 2230 | } | 2244 | } |
| | 2245 | |
| | 2246 | // The frontend should eventually offer options to control these. |
| | 2247 | if (target.cpu.arch.isAarch64() and target.os.tag == .openbsd) { |
| | 2248 | try attributes.addFnAttr(.{ .string = .{ |
| | 2249 | .kind = try o.builder.string("branch-target-enforcement"), |
| | 2250 | .value = try o.builder.string(""), |
| | 2251 | } }, &o.builder); |
| | 2252 | try attributes.addFnAttr(.{ .string = .{ |
| | 2253 | .kind = try o.builder.string("sign-return-address"), |
| | 2254 | .value = try o.builder.string("non-leaf"), |
| | 2255 | } }, &o.builder); |
| | 2256 | try attributes.addFnAttr(.{ .string = .{ |
| | 2257 | .kind = try o.builder.string("sign-return-address-key"), |
| | 2258 | .value = try o.builder.string("a_key"), |
| | 2259 | } }, &o.builder); |
| | 2260 | } |
| 2231 | } | 2261 | } |
| 2232 | | 2262 | |
| 2233 | pub fn addCallingConventionFnAttributes( | 2263 | pub fn addCallingConventionFnAttributes( |