aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-09-27 07:39:58 +0200
committerGitHub <noreply@github.com>2023-09-27 07:39:58 +0200
commit7a43f45908fda0ad8513ab4d7692018cdf801150 (patch)
tree6b0494c0892b5733ee9223adcbb5ea489c8081bb /src/link.zig
parentd1e39b6914ba0f79fb25c5bba7375964d865a69a (diff)
parente30f396b732f7fcb68a701f1b385bb47eba48b89 (diff)
downloadzig-7a43f45908fda0ad8513ab4d7692018cdf801150.tar.gz
zig-7a43f45908fda0ad8513ab4d7692018cdf801150.zip
Merge pull request #17284 from ziglang/elf-tests
elf: link against musl libc, add ELF test harness, dynamically allocate misc SHF_ALLOC sections
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/link.zig b/src/link.zig
index 6c3e31ce3e..dd94ed9a56 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -465,9 +465,10 @@ pub const File = struct {
.Exe => {},
}
switch (base.tag) {
- .coff, .elf, .macho, .plan9, .wasm => if (base.file) |f| {
+ .elf => if (base.file) |f| {
if (build_options.only_c) unreachable;
- if (base.intermediary_basename != null) {
+ const use_lld = build_options.have_llvm and base.options.use_lld;
+ if (base.intermediary_basename != null and use_lld) {
// The file we have open is not the final file that we want to
// make executable, so we don't have to close it.
return;
@@ -480,6 +481,22 @@ pub const File = struct {
.linux => std.os.ptrace(std.os.linux.PTRACE.DETACH, pid, 0, 0) catch |err| {
log.warn("ptrace failure: {s}", .{@errorName(err)});
},
+ else => return error.HotSwapUnavailableOnHostOperatingSystem,
+ }
+ }
+ },
+ .coff, .macho, .plan9, .wasm => if (base.file) |f| {
+ if (build_options.only_c) unreachable;
+ if (base.intermediary_basename != null) {
+ // The file we have open is not the final file that we want to
+ // make executable, so we don't have to close it.
+ return;
+ }
+ f.close();
+ base.file = null;
+
+ if (base.child_pid) |pid| {
+ switch (builtin.os.tag) {
.macos => base.cast(MachO).?.ptraceDetach(pid) catch |err| {
log.warn("detaching failed with error: {s}", .{@errorName(err)});
},