From 16625dd3719dae95abff59b13127748a64265d80 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Wed, 16 Oct 2024 16:00:23 +0100 Subject: [PATCH] Link ELKS objects --- Makefile.p32 | 2 +- Makefile.pdw | 2 +- Makefile.unix | 2 +- Makefile.w32 | 2 +- aout.h | 40 ++--------- aout.c => elks.c | 171 +++++++++++++++++++++++++++-------------------- elks.h | 62 +++++++++++++++++ ld.c | 42 ++++++------ ld.h | 12 ++-- 9 files changed, 197 insertions(+), 138 deletions(-) rename aout.c => elks.c (75%) create mode 100644 elks.h diff --git a/Makefile.p32 b/Makefile.p32 index 4f335bc..40bbfc4 100644 --- a/Makefile.p32 +++ b/Makefile.p32 @@ -6,7 +6,7 @@ CC=gcc386 LD=ld386 COPTS=-S -O2 -fno-common -ansi -I. -I./include -I../pdos/pdpclib -I../pdos/src -D__PDOS386__ -D__32BIT__ -D__NOBIVA__ -D__PDOS__ -Wall -Werror -ansi -m32 -pedantic -COBJ=aout.c hashtab.o ld.o lib.o report.o vector.o write7x.o +COBJ=elks.c hashtab.o ld.o lib.o report.o vector.o write7x.o all: clean slink.exe diff --git a/Makefile.pdw b/Makefile.pdw index b61185a..a1bee13 100644 --- a/Makefile.pdw +++ b/Makefile.pdw @@ -6,7 +6,7 @@ CC=gccwin LD=ldwin COPTS=-S -O2 -fno-common -ansi -I. -I./include -I../pdos/pdpclib -I../pdos/src -D__WIN32__ -D__NOBIVA__ -D__PDOS__ -Wall -Werror -ansi -m32 -pedantic -COBJ=aout.c hashtab.o ld.o lib.o report.o vector.o write7x.o +COBJ=elks.c hashtab.o ld.o lib.o report.o vector.o write7x.o all: clean slink.exe diff --git a/Makefile.unix b/Makefile.unix index 1289dc3..e9625c6 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -9,7 +9,7 @@ VPATH := $(SRCDIR) CC := gcc CFLAGS := -D_FILE_OFFSET_BITS=64 -I$(OBJDIR) -I$(SRCDIR)/include -O2 -Wall -Werror -Wextra -ansi -pedantic -std=c90 -CSRC := aout.c hashtab.c ld.c lib.c report.c vector.c write7x.c +CSRC := elks.c hashtab.c ld.c lib.c report.c vector.c write7x.c ifeq ($(OS), Windows_NT) all: slink.exe diff --git a/Makefile.w32 b/Makefile.w32 index ee7f0f7..f3aaa1c 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -9,7 +9,7 @@ VPATH := $(SRCDIR) CC := gcc CFLAGS := -D_FILE_OFFSET_BITS=64 -I$(OBJDIR) -I$(SRCDIR)/include -O2 -Wall -Werror -Wextra -ansi -pedantic -std=c90 -CSRC := aout.c hashtab.c ld.c lib.c report.c vector.c write7x.c +CSRC := elks.c hashtab.c ld.c lib.c report.c vector.c write7x.c all: slink.exe diff --git a/aout.h b/aout.h index 87d9e4e..a7443bb 100644 --- a/aout.h +++ b/aout.h @@ -4,30 +4,7 @@ #ifndef _AOUT_H #define _AOUT_H -struct ia16_aout_exec { - - unsigned char a_magic[2]; - unsigned char a_flags; - unsigned char a_cpu; - unsigned char a_hdrlen; - unsigned char a_unused; - unsigned char a_version[2]; - - unsigned char a_text[4]; - unsigned char a_data[4]; - unsigned char a_bss[4]; - unsigned char a_entry[4]; - unsigned char a_total[4]; - unsigned char a_syms[4]; - - unsigned char a_trsize[4]; - unsigned char a_drsize[4]; - unsigned char a_trbase[4]; - unsigned char a_drbase[4]; - -}; - -struct i386_aout_exec { +struct aout_exec { unsigned char a_info[4]; unsigned char a_text[4]; @@ -55,18 +32,6 @@ struct relocation_info { #define N_EXT 0x01 -struct nlist { - - unsigned char n_strx[4]; - unsigned char n_type; - - unsigned char n_value[4]; - -}; - -#define OMAGIC 0407 -#define ZMAGIC 0413 - /*struct aout_nlist { unsigned char n_strx[4]; @@ -82,4 +47,7 @@ struct nlist { #define N_TYPE 0x1e int create_executable_from_aout_objects (void); +#define OMAGIC 0407 +#define ZMAGIC 0413 + #endif /* _AOUT_H */ diff --git a/aout.c b/elks.c similarity index 75% rename from aout.c rename to elks.c index a1effc9..2e1a244 100644 --- a/aout.c +++ b/elks.c @@ -1,5 +1,5 @@ /****************************************************************************** - * @file aout.c + * @file elks.c *****************************************************************************/ #include #include @@ -8,6 +8,7 @@ #include #include "aout.h" +#include "elks.h" #include "ld.h" #include "lib.h" #include "report.h" @@ -31,24 +32,24 @@ static void *data = 0, *output = 0, *text = 0; struct gr { long relocations_count, relocations_max; - struct relocation_info *relocations; + struct elks_relocation_info *relocations; }; static struct gr tgr = { 0, 64, NULL }; static struct gr dgr = { 0, 64, NULL }; -static int get_symbol (struct aout_object **obj_out, long *index, const char *name, int quiet) { +static int get_symbol (struct elks_object **obj_out, long *index, const char *name, int quiet) { long object_i, symbol_i; - for (object_i = 0; object_i < state->nb_aout_objs; ++object_i) { + for (object_i = 0; object_i < state->nb_elks_objs; ++object_i) { - struct aout_object *obj = state->aout_objs[object_i]; + struct elks_object *obj = state->elks_objs[object_i]; for (symbol_i = 0; symbol_i < obj->symtab_count; symbol_i++) { - struct nlist *sym = &obj->symtab[symbol_i]; + struct elks_nlist *sym = &obj->symtab[symbol_i]; char *symname = obj->strtab + GET_INT32 (sym->n_strx); if ((sym->n_type & N_EXT) == 0) { @@ -87,7 +88,7 @@ static int get_symbol (struct aout_object **obj_out, long *index, const char *na static unsigned long get_entry (void) { - struct aout_object *symobj; + struct elks_object *symobj; long symidx; if (get_symbol (&symobj, &symidx, state->entry, 1)) { @@ -114,13 +115,13 @@ static void number_to_chars (unsigned char *p, unsigned long number, unsigned lo static long objtextsize = 0, objdatasize = 0, objbsssize = 0; static unsigned long text_ptr = 0, data_ptr = 0, bss_ptr = 0; -static void apply_slides (struct aout_object *object) { +static void apply_slides (struct elks_object *object) { long i; for (i = 0; i < object->symtab_count; i++) { - struct nlist *symbol = &object->symtab[i]; + struct elks_nlist *symbol = &object->symtab[i]; unsigned long final_slide = 0, n_value = GET_UINT32 (symbol->n_value); if ((symbol->n_type & N_TYPE) != N_TEXT && (symbol->n_type & N_TYPE) != N_DATA && (symbol->n_type & N_TYPE) != N_BSS) { @@ -173,7 +174,7 @@ static void apply_slides (struct aout_object *object) { for (i = 0; i < object->trelocs_count; i++) { - struct relocation_info *rel = &object->trelocs[i]; + struct elks_relocation_info *rel = &object->trelocs[i]; long r_address = GET_INT32 (rel->r_address); r_address += object->text_slide; @@ -184,7 +185,7 @@ static void apply_slides (struct aout_object *object) { for (i = 0; i < object->drelocs_count; i++) { - struct relocation_info *rel = &object->drelocs[i]; + struct elks_relocation_info *rel = &object->drelocs[i]; long r_address = GET_INT32 (rel->r_address); r_address += state->text_size + object->data_slide; @@ -195,9 +196,9 @@ static void apply_slides (struct aout_object *object) { } -static void paste (struct aout_object *object) { +static void paste (struct elks_object *object) { - struct i386_aout_exec *header = object->header; + struct elks_exec *header = object->header; char *obj_text, *obj_data; unsigned long obj_text_size, obj_data_size, obj_bss_size; @@ -238,13 +239,13 @@ static void paste (struct aout_object *object) { } -static void undef_collect (struct aout_object *object) { +static void undef_collect (struct elks_object *object) { long i, val; for (i = 0; i < object->symtab_count; i++) { - struct nlist *sym = &object->symtab[i]; + struct elks_nlist *sym = &object->symtab[i]; char *symname = object->strtab + GET_INT32 (sym->n_strx); if ((sym->n_type & N_TYPE) != N_UNDF || GET_UINT32 (sym->n_value) == 0) { @@ -265,7 +266,7 @@ static void undef_collect (struct aout_object *object) { } -static int add_relocation (struct gr *gr, struct relocation_info *r) { +static int add_relocation (struct gr *gr, struct elks_relocation_info *r) { if (gr->relocations == NULL) { @@ -296,9 +297,9 @@ static int add_relocation (struct gr *gr, struct relocation_info *r) { } -static int relocate (struct aout_object *object, struct relocation_info *r, int is_data) { +static int relocate (struct elks_object *object, struct elks_relocation_info *r, int is_data) { - struct nlist *symbol; + struct elks_nlist *symbol; unsigned char *p; unsigned long r_symbolnum = GET_UINT32 (r->r_symbolnum); @@ -347,7 +348,7 @@ static int relocate (struct aout_object *object, struct relocation_info *r, int char *symname = object->strtab + GET_INT32 (symbol->n_strx); - struct aout_object *symobj; + struct elks_object *symobj; long symidx; if (!get_symbol (&symobj, &symidx, symname, 0)) { @@ -366,7 +367,7 @@ static int relocate (struct aout_object *object, struct relocation_info *r, int if (!ext || (symbol->n_type & N_TYPE) == N_BSS || (symbol->n_type & N_TYPE) == N_DATA || (symbol->n_type & N_TYPE) == N_TEXT) { - struct relocation_info new_relocation; + struct elks_relocation_info new_relocation; unsigned long r_symbolnum; long r_address; @@ -449,7 +450,7 @@ static int relocate (struct aout_object *object, struct relocation_info *r, int } -static int glue (struct aout_object *object) { +static int glue (struct elks_object *object) { long i, err = 0; @@ -478,12 +479,12 @@ static int glue (struct aout_object *object) { } -static int init_aout_object (void) { +static int init_elks_object (void) { if (state->format == LD_FORMAT_I386_AOUT) { - header_size = sizeof (struct i386_aout_exec); + header_size = sizeof (struct aout_exec); } else if (state->format == LD_FORMAT_IA16_AOUT) { - header_size = sizeof (struct ia16_aout_exec); + header_size = sizeof (struct elks_exec); } if (!state->impure) { @@ -505,39 +506,39 @@ static int init_aout_object (void) { } -static int write_aout_object (unsigned long a_entry) { +static int write_elks_object (unsigned long a_entry) { if (state->format == LD_FORMAT_I386_AOUT) { - struct i386_aout_exec *aout_hdr = output; + struct aout_exec *header = output; - write741_to_byte_array (aout_hdr->a_info, state->impure ? OMAGIC : ZMAGIC); - write741_to_byte_array (aout_hdr->a_text, state->text_size); - write741_to_byte_array (aout_hdr->a_data, state->data_size); - write741_to_byte_array (aout_hdr->a_bss, state->bss_size); - write741_to_byte_array (aout_hdr->a_entry, a_entry); - write741_to_byte_array (aout_hdr->a_trsize, tgr.relocations_count * sizeof (struct relocation_info)); - write741_to_byte_array (aout_hdr->a_drsize, dgr.relocations_count * sizeof (struct relocation_info)); + write741_to_byte_array (header->a_info, state->impure ? OMAGIC : ZMAGIC); + write741_to_byte_array (header->a_text, state->text_size); + write741_to_byte_array (header->a_data, state->data_size); + write741_to_byte_array (header->a_bss, state->bss_size); + write741_to_byte_array (header->a_entry, a_entry); + write741_to_byte_array (header->a_trsize, tgr.relocations_count * sizeof (struct relocation_info)); + write741_to_byte_array (header->a_drsize, dgr.relocations_count * sizeof (struct relocation_info)); } else if (state->format == LD_FORMAT_IA16_AOUT) { - struct ia16_aout_exec *aout_hdr = output; + struct elks_exec *header = output; - aout_hdr->a_magic[0] = 0x01; - aout_hdr->a_magic[1] = 0x03; + header->a_magic[0] = (ELKS_MAGIC >> 8) & 0xff; + header->a_magic[1] = ELKS_MAGIC & 0xff; - aout_hdr->a_flags = 0x10; - aout_hdr->a_cpu = 0x04; - aout_hdr->a_hdrlen = sizeof (*aout_hdr); + header->a_flags = 0x10; + header->a_cpu = 0x04; + header->a_hdrlen = sizeof (*header); - write741_to_byte_array (aout_hdr->a_text, state->text_size); - write741_to_byte_array (aout_hdr->a_data, state->data_size); - write741_to_byte_array (aout_hdr->a_bss, state->bss_size); - write741_to_byte_array (aout_hdr->a_entry, a_entry); - write721_to_byte_array (aout_hdr->a_total, (state->text_size + state->data_size) + 0x8000); + write741_to_byte_array (header->a_text, state->text_size); + write741_to_byte_array (header->a_data, state->data_size); + write741_to_byte_array (header->a_bss, state->bss_size); + write741_to_byte_array (header->a_entry, a_entry); + write721_to_byte_array (header->a_total, (state->text_size + state->data_size) + 0x8000); - write741_to_byte_array (aout_hdr->a_trsize, tgr.relocations_count * sizeof (struct relocation_info)); - write741_to_byte_array (aout_hdr->a_drsize, dgr.relocations_count * sizeof (struct relocation_info)); + write741_to_byte_array (header->a_trsize, tgr.relocations_count * sizeof (struct elks_relocation_info)); + write741_to_byte_array (header->a_drsize, dgr.relocations_count * sizeof (struct elks_relocation_info)); } @@ -548,23 +549,51 @@ static int write_aout_object (unsigned long a_entry) { } - if (tgr.relocations_count > 0) { + if (state->format == LD_FORMAT_I386_AOUT) { - if (fwrite (tgr.relocations, tgr.relocations_count * sizeof (struct relocation_info), 1, state->ofp) != 1) { + if (tgr.relocations_count > 0) { - report_at (program_name, 0, REPORT_ERROR, "failed to write text relocations to '%s'", state->ofile); - return 1; + if (fwrite (tgr.relocations, tgr.relocations_count * sizeof (struct relocation_info), 1, state->ofp) != 1) { + + report_at (program_name, 0, REPORT_ERROR, "failed to write text relocations to '%s'", state->ofile); + return 1; + + } + + } + + if (dgr.relocations_count > 0) { + + if (fwrite (dgr.relocations, dgr.relocations_count * sizeof (struct relocation_info), 1, state->ofp) != 1) { + + report_at (program_name, 0, REPORT_ERROR, "failed to write data relocations to '%s'", state->ofile); + return 1; + + } } - } - - if (dgr.relocations_count > 0) { + } else if (state->format == LD_FORMAT_IA16_AOUT) { - if (fwrite (dgr.relocations, dgr.relocations_count * sizeof (struct relocation_info), 1, state->ofp) != 1) { + if (tgr.relocations_count > 0) { - report_at (program_name, 0, REPORT_ERROR, "failed to write data relocations to '%s'", state->ofile); - return 1; + if (fwrite (tgr.relocations, tgr.relocations_count * sizeof (struct elks_relocation_info), 1, state->ofp) != 1) { + + report_at (program_name, 0, REPORT_ERROR, "failed to write text relocations to '%s'", state->ofile); + return 1; + + } + + } + + if (dgr.relocations_count > 0) { + + if (fwrite (dgr.relocations, dgr.relocations_count * sizeof (struct elks_relocation_info), 1, state->ofp) != 1) { + + report_at (program_name, 0, REPORT_ERROR, "failed to write data relocations to '%s'", state->ofile); + return 1; + + } } @@ -575,9 +604,9 @@ static int write_aout_object (unsigned long a_entry) { } -int create_executable_from_aout_objects (void) { +int create_executable_from_elks_objects (void) { - struct aout_object *object; + struct elks_object *object; long i; unsigned long entry = 0; @@ -598,7 +627,7 @@ int create_executable_from_aout_objects (void) { } else if (state->format == LD_FORMAT_IA16_AOUT || state->format == LD_FORMAT_I386_AOUT) { - if (init_aout_object ()) { + if (init_elks_object ()) { report_at (program_name, 0, REPORT_ERROR, "failed to initialize a.out object"); return EXIT_FAILURE; @@ -607,25 +636,25 @@ int create_executable_from_aout_objects (void) { } - for (i = 0; i < state->nb_aout_objs; ++i) { - paste (state->aout_objs[i]); + for (i = 0; i < state->nb_elks_objs; ++i) { + paste (state->elks_objs[i]); } - for (i = 0; i < state->nb_aout_objs; ++i) { - apply_slides (state->aout_objs[i]); + for (i = 0; i < state->nb_elks_objs; ++i) { + apply_slides (state->elks_objs[i]); } - for (i = 0; i < state->nb_aout_objs; ++i) { - undef_collect (state->aout_objs[i]); + for (i = 0; i < state->nb_elks_objs; ++i) { + undef_collect (state->elks_objs[i]); } if (!state->impure) { state->bss_size = ALIGN_UP (state->bss_size, SECTION_ALIGNMENT); } - for (i = 0; i < state->nb_aout_objs; ++i) { + for (i = 0; i < state->nb_elks_objs; ++i) { - if (glue (state->aout_objs[i])) { + if (glue (state->elks_objs[i])) { err = 1; } @@ -639,9 +668,9 @@ int create_executable_from_aout_objects (void) { entry = get_entry (); } - for (i = 0; i < state->nb_aout_objs; i++) { + for (i = 0; i < state->nb_elks_objs; i++) { - if ((object = state->aout_objs[i]) == NULL) { + if ((object = state->elks_objs[i]) == NULL) { return EXIT_FAILURE; } @@ -654,7 +683,7 @@ int create_executable_from_aout_objects (void) { } - state->nb_aout_objs = 0; + state->nb_elks_objs = 0; /*if (state->mapfile) { @@ -683,7 +712,7 @@ int create_executable_from_aout_objects (void) { } else if (state->format == LD_FORMAT_IA16_AOUT || state->format == LD_FORMAT_I386_AOUT) { - if (write_aout_object (entry)) { + if (write_elks_object (entry)) { report_at (program_name, 0, REPORT_ERROR, "failed to write a.out object"); return EXIT_FAILURE; diff --git a/elks.h b/elks.h new file mode 100644 index 0000000..dfbe08f --- /dev/null +++ b/elks.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * @file aout.h + *****************************************************************************/ +#ifndef _ELKS_H +#define _ELKS_H + +struct elks_exec { + + unsigned char a_magic[2]; + unsigned char a_flags; + unsigned char a_cpu; + unsigned char a_hdrlen; + unsigned char a_unused; + unsigned char a_version[2]; + + unsigned char a_text[4]; + unsigned char a_data[4]; + unsigned char a_bss[4]; + unsigned char a_entry[4]; + unsigned char a_total[4]; + unsigned char a_syms[4]; + + unsigned char a_trsize[4]; + unsigned char a_drsize[4]; + unsigned char a_trbase[4]; + unsigned char a_drbase[4]; + +}; + +#define N_UNDF 0x00 +#define N_ABS 0x02 +#define N_TEXT 0x04 +#define N_DATA 0x06 +#define N_BSS 0x08 + +struct elks_relocation_info { + + unsigned char r_address[4]; + unsigned char r_symbolnum[4]; + +}; + +#define N_EXT 0x01 + +struct elks_nlist { + + unsigned char n_strx[4]; + unsigned char n_type; + + unsigned char n_other; + unsigned char n_desc[2]; + + unsigned char n_value[4]; + +}; + +#define N_TYPE 0x1e +int create_executable_from_elks_objects (void); + +#define ELKS_MAGIC 0403 + +#endif /* _ELKS_H */ diff --git a/ld.c b/ld.c index cf640e8..5fc9b81 100644 --- a/ld.c +++ b/ld.c @@ -5,7 +5,7 @@ #include #include -#include "aout.h" +#include "elks.h" #include "hashtab.h" #include "ld.h" #include "lib.h" @@ -31,9 +31,9 @@ static void cleanup (void) { } - for (i = 0; i < state->nb_aout_objs; ++i) { + for (i = 0; i < state->nb_elks_objs; ++i) { - struct aout_object *obj = state->aout_objs[i]; + struct elks_object *obj = state->elks_objs[i]; if (obj == NULL) { continue; @@ -68,15 +68,15 @@ static unsigned long conv_dec (char *str, long max) { static struct hashtab hashtab_globals = { 0 }; static struct vector vec_undef = { 0 }; -static int process_aout (void *obj, unsigned long sz, const char *fname, int quiet) { +static int process_elks (void *obj, unsigned long sz, const char *fname, int quiet) { - struct i386_aout_exec *hdr = obj; + struct elks_exec *hdr = obj; - struct aout_object *data_obj; - struct nlist *symtab; + struct elks_object *data_obj; + struct elks_nlist *symtab; - struct relocation_info *trelocs; - struct relocation_info *drelocs; + struct elks_relocation_info *trelocs; + struct elks_relocation_info *drelocs; long symtab_count, trelocs_count, drelocs_count; unsigned long symtab_off, strtab_off, trelocs_off, drelocs_off; @@ -84,7 +84,7 @@ static int process_aout (void *obj, unsigned long sz, const char *fname, int qui char *strtab; long i; - if (!(hdr->a_info[0] == 0x39 && hdr->a_info[1] == 0x01 && hdr->a_info[2] == 0x64 && hdr->a_info[3] == 0x00)) { + if (!(hdr->a_magic[0] == ((ELKS_MAGIC >> 8) & 0xff) && hdr->a_magic[1] == (ELKS_MAGIC & 0xff))) { if (!quiet) { report_at (program_name, 0, REPORT_ERROR, "'%s' is not a valid object", fname); @@ -94,9 +94,9 @@ static int process_aout (void *obj, unsigned long sz, const char *fname, int qui } - for (i = 0; i < state->nb_aout_objs; ++i) { + for (i = 0; i < state->nb_elks_objs; ++i) { - struct aout_object *obj_to_compare = state->aout_objs[i]; + struct elks_object *obj_to_compare = state->elks_objs[i]; if (obj_to_compare->size != sz) { continue; @@ -155,11 +155,11 @@ static int process_aout (void *obj, unsigned long sz, const char *fname, int qui data_obj->drelocs_count = drelocs_count; data_obj->symtab_count = symtab_count; - dynarray_add (&state->aout_objs, &state->nb_aout_objs, data_obj); + dynarray_add (&state->elks_objs, &state->nb_elks_objs, data_obj); for (i = 0; i < symtab_count; ++i) { - struct nlist *sym = &symtab[i]; + struct elks_nlist *sym = &symtab[i]; char *symname = strtab + GET_INT32 (sym->n_strx); if ((sym->n_type & N_TYPE) == N_UNDF) { @@ -284,7 +284,7 @@ static int read_ar_obj (FILE *ar_file, const char *root_fname, unsigned long ind memset (path, 0, len); sprintf (path, "%s(%s)", root_fname, fname); - if (process_aout (obj, sz, path, 1)) { + if (process_elks (obj, sz, path, 1)) { free (obj); return 1; @@ -293,7 +293,7 @@ static int read_ar_obj (FILE *ar_file, const char *root_fname, unsigned long ind } else { - if (process_aout (obj, sz, "", 1)) { + if (process_elks (obj, sz, "", 1)) { free (obj); return 1; @@ -510,13 +510,13 @@ static int process_archive (FILE *ar_file, const char *root_fname) { memset (path, 0, len); sprintf (path, "%s(%s)", root_fname, fname); - if ((err = process_aout (obj, sz, path, 1))) { + if ((err = process_elks (obj, sz, path, 1))) { free (obj); } } else { - if ((err = process_aout (obj, sz, "", 1))) { + if ((err = process_elks (obj, sz, "", 1))) { free (obj); } @@ -609,7 +609,7 @@ static int process_file (const char *fname) { } - if ((err = process_aout (obj, obj_sz, fname, 1))) { + if ((err = process_elks (obj, obj_sz, fname, 1))) { report_at (fname, 0, REPORT_ERROR, "file format not recognized"); free (obj); @@ -677,9 +677,9 @@ int main (int argc, char **argv) { } - if (state->nb_aout_objs > 0) { + if (state->nb_elks_objs > 0) { - if (create_executable_from_aout_objects ()) { + if (create_executable_from_elks_objects ()) { return EXIT_FAILURE; } diff --git a/ld.h b/ld.h index 32ce20c..852066b 100644 --- a/ld.h +++ b/ld.h @@ -6,17 +6,17 @@ #include "aout.h" -struct aout_object { +struct elks_object { const char *filename; void *raw; unsigned long size; - struct i386_aout_exec *header; - struct relocation_info *trelocs, *drelocs; + struct elks_exec *header; + struct elks_relocation_info *trelocs, *drelocs; - struct nlist *symtab; + struct elks_nlist *symtab; char *strtab; long symtab_count, trelocs_count, drelocs_count; @@ -40,8 +40,8 @@ struct ld_state { int format, impure; int psp; - struct aout_object **aout_objs; - long nb_aout_objs; + struct elks_object **elks_objs; + long nb_elks_objs; unsigned long text_size, data_size, bss_size; char *entry; -- 2.34.1