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)) 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)); 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; }