target/hexagon/idef-parser: open input file in binary mode
On Windows, opening a file in text mode causes fread() to return fewer bytes than ftell() reported, because CRLF sequences are translated to LF on read. This causes idef-parser to report an error and abort. Open the input file in binary mode ("rb") so that ftell() and fread() agree on the file size across all platforms. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Brian Cain committed
Jun 22, 2026 at 15:29 UTC
8e84f24c83d355699db4dd5093c37639f670ac2e
1 file changed
+1
-1
target/hexagon/idef-parser/idef-parser.y
+1
-1
@@ -869,7 +869,7 @@ int main(int argc, char **argv)
869
context.header_str = g_string_new(NULL);
870
context.ternary = g_array_new(FALSE, TRUE, sizeof(Ternary));
871
/* Read input file */
872
- FILE *input_file = fopen(argv[ARG_INDEX_IDEFS], "r");
872
+ FILE *input_file = fopen(argv[ARG_INDEX_IDEFS], "rb");
873
fseek(input_file, 0L, SEEK_END);
874
long input_size = ftell(input_file);
875
context.input_buffer = (char *) calloc(input_size + 1, sizeof(char));