summaryrefslogtreecommitdiff
path: root/bxgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'bxgen.c')
-rwxr-xr-xbxgen.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/bxgen.c b/bxgen.c
index c123f70..4eeff93 100755
--- a/bxgen.c
+++ b/bxgen.c
@@ -37,6 +37,7 @@ exit $?
// - ELF + x86_64 executable
// - x86_64 object file
// - Linking libraries
+// - String table for names
// - Proper error handling
// - Proper prefixes for identifiers
// - Effective entity allocation
@@ -1127,6 +1128,18 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
READ(addralign);
READ(entsize);
+ if (type == 0) {
+ printf("\n");
+ continue;
+ }
+
+ if (type == 2 || type == 4 || type == 9) // sym/rela/rel
+ printf("%s", "\x1b[32m");
+ else if ((flags & 2) != 0) // alloc
+ printf("%s", "\x1b[34m");
+ else
+ printf("%s", "\x1b[31m");
+
// Search for the name in the string table
//
{
@@ -1154,16 +1167,17 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
}
printf(
- "%-18s",
- type >= 1 && type <= 8 ?
+ "%-10s",
+ type >= 1 && type <= 9 ?
(c8 const *[]) {
- "Program data",
+ "Program",
"Symbols",
- "String table",
- "Rel width addends",
+ "Strings",
+ "Rel add",
+ "Hash",
"Dynamic",
"Note",
- "No data",
+ "Zeros",
"Rel",
}[type - 1] :
type == 17 ?
@@ -1171,17 +1185,26 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
""
);
- if ((flags & 1) == 1)
- printf(" Writable");
if ((flags & 2) == 2)
- printf(" Alloc");
+ printf("R");
+ else
+ printf("_");
+ if ((flags & 1) == 1)
+ printf("W");
+ else
+ printf("_");
if ((flags & 4) == 4)
- printf(" Executable");
+ printf("X");
+ else
+ printf("_");
+
+ if (size > 0)
+ printf(" - %lld bytes", size);
// NOTE
// Only alloc sections should be written to the output binary.
- printf("\n");
+ printf("%s\n", "\x1b[37m");
}
printf("\n");
@@ -1396,8 +1419,6 @@ void u_entry_point(i64 unit, i64 proc) {
}
void u_elf_x86_64(i64 unit, c8 *output_file_name) {
- printf("Writing ELF x86_64 executable...\n");
-
i64 out = io_open_write(strlen(output_file_name), output_file_name, NULL);
unit_write(&g_pool, unit, FORMAT_ELF | ARCH_X86_64, out, NULL);
@@ -1450,6 +1471,8 @@ int main(int argc, char **argv) {
u_add(u, main);
u_entry_point(u, main);
l_static(u, "/lib/x86_64-linux-gnu/libc.a");
+
+ printf("Writing ELF x86_64 executable...\n");
u_elf_x86_64(u, "test_foo");
printf("\nBye!\n");