From 6b06dcd053bc883327993ae4f4da0c69d4c24b58 Mon Sep 17 00:00:00 2001 From: Cecill Etheredge Date: Sun, 26 May 2024 00:59:02 +0200 Subject: [PATCH 1/3] fix: ELF fopen should be binary. --- src/ld/elfobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ld/elfobj.c b/src/ld/elfobj.c index abd3b1a98..e5ea8d61d 100644 --- a/src/ld/elfobj.c +++ b/src/ld/elfobj.c @@ -143,7 +143,7 @@ void elfobj_init(ElfObj *elfobj) { bool open_elf(const char *fn, ElfObj *elfobj) { FILE *fp; - if (!is_file(fn) || (fp = fopen(fn, "r")) == NULL) { + if (!is_file(fn) || (fp = fopen(fn, "rb")) == NULL) { fprintf(stderr, "cannot open: %s\n", fn); } else { if (read_elf(elfobj, fp, fn)) From 592815479024d5ab5df3865ae525fa34bfbd8d11 Mon Sep 17 00:00:00 2001 From: Cecill Etheredge Date: Sun, 26 May 2024 00:59:38 +0200 Subject: [PATCH 2/3] fix: ar fopen should be binary. --- src/util/archive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/archive.c b/src/util/archive.c index e62b8a78f..eacf72290 100644 --- a/src/util/archive.c +++ b/src/util/archive.c @@ -18,7 +18,7 @@ static uint32_t read4be(FILE *fp) { Archive *load_archive(const char *filename) { FILE *fp; - if (!is_file(filename) || (fp = fopen(filename, "r")) == NULL) + if (!is_file(filename) || (fp = fopen(filename, "rb")) == NULL) return NULL; Archive *ar = malloc_or_die(sizeof(*ar)); From 44a7a4abaa4b94291b0723c7c3412708fe963598 Mon Sep 17 00:00:00 2001 From: Cecill Etheredge Date: Sun, 26 May 2024 00:59:50 +0200 Subject: [PATCH 3/3] fix: WASM fopen should be binary. --- src/wcc/wasm_linker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wcc/wasm_linker.c b/src/wcc/wasm_linker.c index 9eb8f4a41..58fc47445 100644 --- a/src/wcc/wasm_linker.c +++ b/src/wcc/wasm_linker.c @@ -1423,7 +1423,7 @@ bool read_wasm_obj(WasmLinker *linker, const char *filename) { char *ext = get_ext(filename); if (strcasecmp(ext, "o") == 0) { FILE *fp; - if (!is_file(filename) || (fp = fopen(filename, "r")) == NULL) { + if (!is_file(filename) || (fp = fopen(filename, "rb")) == NULL) { fprintf(stderr, "cannot open: %s\n", filename); return false; }