From 31f95ee266e507a3155a82899531851c7202f0a3 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Sun, 9 Jun 2024 20:44:46 +0200 Subject: Use fchmod --- binary_code_generation.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/binary_code_generation.c b/binary_code_generation.c index 994f7d4..053baa6 100755 --- a/binary_code_generation.c +++ b/binary_code_generation.c @@ -17,19 +17,25 @@ exit $? // - No configuration required // - No dynamic memory management // -// TODO +// To-Do list // // - ELF + x86_64 executable // - x86_64 object file // - Linking libraries +// - Proper error handling // - Effective entity allocation // - Linked lists for large entities // - Sea of Nodes // - Optimization layers // - Multithreading +// - Memory reallocation when necessary // - COFF, PE, OMF, Mach-O // - i386, RISC-V, ARM // +// Done +// +// - ELF header +// // ================================================================ // // Basic declarations @@ -40,8 +46,11 @@ exit $? #include #include #include + +#ifdef __unix__ #include #include +#endif typedef signed char i8; typedef signed short i16; @@ -478,8 +487,10 @@ void u_elf_x86_64(i64 unit, c8 const *output_file_name) { FILE *f = fopen(output_file_name, "wb"); assert(f != NULL); unit_write(&g_pool, unit, FORMAT_ELF | ARCH_X86_64, f); +#ifdef __unix__ + fchmod(fileno(f), 0775); +#endif fclose(f); - chmod(output_file_name, 0775); } // ================================================================ -- cgit v1.2.3