diff --git a/src/panfrost/compiler/cmdline.c b/src/panfrost/compiler/cmdline.c index 9982bfc6755..4b1955dd86a 100644 --- a/src/panfrost/compiler/cmdline.c +++ b/src/panfrost/compiler/cmdline.c @@ -31,6 +31,8 @@ #include "valhall/disassemble.h" #include "panfrost/lib/pan_props.h" +#include "util/os_file.h" + unsigned gpu_id = 0x72120000; int verbose = 0; @@ -44,18 +46,13 @@ disassemble(const char *filename) FILE *fp = fopen(filename, "rb"); assert(fp); - fseek(fp, 0, SEEK_END); - unsigned filesize = ftell(fp); - rewind(fp); - - uint32_t *code = malloc(filesize); - unsigned res = fread(code, 1, filesize, fp); - if (res != filesize) { - printf("Couldn't read full file\n"); + size_t filesize = 0; + uint32_t *code = (uint32_t *)os_read_file(filename, &filesize); + if (!code) { + fprintf(stderr, "Couldn't read full file\n"); + return; } - fclose(fp); - void *entrypoint = code; if (filesize && code[0] == BI_FOURCC('M', 'B', 'S', '2')) {