summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-06-09 20:44:46 +0200
committerMitya Selivanov <automainint@guattari.tech>2024-06-09 20:44:46 +0200
commit31f95ee266e507a3155a82899531851c7202f0a3 (patch)
tree7f829fe4fcd62a5dd7d18d2095ea7698400443f4
parent279e17589876bb1c4c262df847bfcc80564a42ca (diff)
downloadbxgen-31f95ee266e507a3155a82899531851c7202f0a3.zip
Use fchmod
-rwxr-xr-xbinary_code_generation.c15
1 files 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 <stdlib.h>
#include <string.h>
#include <assert.h>
+
+#ifdef __unix__
#include <sys/types.h>
#include <sys/stat.h>
+#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);
}
// ================================================================