From fff0444f6c9f666e5956dd9a7f7f2443d6d3d58f Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sun, 22 Sep 2024 16:54:14 -0400 Subject: [PATCH] make mld file executable --- mld/link.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mld/link.c b/mld/link.c index 5696973..5a8e151 100644 --- a/mld/link.c +++ b/mld/link.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "link.h" #include "mips.h" @@ -573,7 +574,13 @@ static int write_file(struct linker *linker) extern char *current_file; current_file = linker->args->out_file; - FILE *out = fopen(linker->args->out_file, "w"); + int fd = open(linker->args->out_file, O_RDWR | O_CREAT, 0711); + if (fd < 0) { + PERROR("cannot write"); + return M_ERROR; + } + + FILE *out = fdopen(fd, "w"); if (out == NULL) { PERROR("cannot write"); return M_ERROR;