summaryrefslogtreecommitdiff
path: root/binary_code_generation.c
diff options
context:
space:
mode:
Diffstat (limited to 'binary_code_generation.c')
-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);
}
// ================================================================