diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-22 23:08:54 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-22 23:08:54 +0000 |
commit | b5caf439b4c7ff9bbeddf87e7c19065f81ea730d (patch) | |
tree | b02dcfef3604dfbf833e7d33fd67abfb353e7650 /misc | |
parent | b809a139fa845066eb21a2602f1642b98f841151 (diff) | |
download | nuttx-b5caf439b4c7ff9bbeddf87e7c19065f81ea730d.tar.gz nuttx-b5caf439b4c7ff9bbeddf87e7c19065f81ea730d.tar.bz2 nuttx-b5caf439b4c7ff9bbeddf87e7c19065f81ea730d.zip |
Defs for new relocation types
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1927 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc')
-rw-r--r-- | misc/buildroot/toolchain/nxflat/Makefile | 2 | ||||
-rw-r--r-- | misc/buildroot/toolchain/nxflat/ldnxflat.c | 107 | ||||
-rw-r--r-- | misc/buildroot/toolchain/nxflat/nxflat.h | 161 | ||||
-rw-r--r-- | misc/buildroot/toolchain/nxflat/readnxflat.c (renamed from misc/buildroot/toolchain/nxflat/readxflat.c) | 73 |
4 files changed, 190 insertions, 153 deletions
diff --git a/misc/buildroot/toolchain/nxflat/Makefile b/misc/buildroot/toolchain/nxflat/Makefile index 287dda7d6..93a0fa288 100644 --- a/misc/buildroot/toolchain/nxflat/Makefile +++ b/misc/buildroot/toolchain/nxflat/Makefile @@ -39,7 +39,7 @@ LIBS = -lbfd -liberty -lz LDNXFLAT_OBJS = ldnxflat.o MKNXFLAT_OBJS = mknxflat.o -READNXFLAT_OBJS = readxflat.o +READNXFLAT_OBJS = readnxflat.o OBJS = $(LDNXFLAT_OBJS) $(MKNXFLAT_OBJS) $(READNXFLAT_OBJS) BIN = ldnxflat mknxflat readnxflat diff --git a/misc/buildroot/toolchain/nxflat/ldnxflat.c b/misc/buildroot/toolchain/nxflat/ldnxflat.c index 21ff59ad6..5a6505ed2 100644 --- a/misc/buildroot/toolchain/nxflat/ldnxflat.c +++ b/misc/buildroot/toolchain/nxflat/ldnxflat.c @@ -138,6 +138,12 @@ # define RAW_SIZE rawsize #endif +#define NXFLAT_RELOC_TARGET_TEXT 0 +#define NXFLAT_RELOC_TARGET_DATA 1 +#define NXFLAT_RELOC_TARGET_RODATA 2 +#define NXFLAT_RELOC_TARGET_BSS 3 +#define NXFLAT_RELOC_TARGET_UNKNOWN 4 + /*********************************************************************** * Private Types ***********************************************************************/ @@ -456,7 +462,7 @@ put_special_symbol(asymbol * begin_sym, asymbol * end_sym, begin_sect_vma = begin_sym->section->vma; - file_offset = NXFLAT_HDR_SIZE + /* Size of the xFLT header */ + file_offset = NXFLAT_HDR_SIZE + /* Size of the NXFLAT header */ begin_sect_vma + /* Virtual address of section */ begin_sym_value + /* Value of the symbol */ offset; /* Additional file offset */ @@ -591,7 +597,7 @@ static void put_entry_point(struct nxflat_hdr_s *hdr) } } - /* Put the entry point into the xFLT header. */ + /* Put the entry point into the NXFLAT header. */ put_xflat32(&hdr->h_entry, entry_point); } @@ -600,7 +606,7 @@ static void put_entry_point(struct nxflat_hdr_s *hdr) * get_reloc_type ***********************************************************************/ -static int get_reloc_type(asection * sym_section, segment_info ** sym_segment) +static int get_reloc_type(asection *sym_section, segment_info **sym_segment) { int i; @@ -623,7 +629,7 @@ static int get_reloc_type(asection * sym_section, segment_info ** sym_segment) { *sym_segment = &bss_info; } - return NXFLAT_RELOC_TYPE_BSS; + return NXFLAT_RELOC_TARGET_BSS; } } @@ -641,7 +647,7 @@ static int get_reloc_type(asection * sym_section, segment_info ** sym_segment) { *sym_segment = &text_info; } - return NXFLAT_RELOC_TYPE_TEXT; + return NXFLAT_RELOC_TARGET_TEXT; } } @@ -656,14 +662,17 @@ static int get_reloc_type(asection * sym_section, segment_info ** sym_segment) vdbg("Sym section %s is DATA\n", sym_section->name); if (sym_segment) - *sym_segment = &data_info; - return NXFLAT_RELOC_TYPE_DATA; + { + *sym_segment = &data_info; + } + return NXFLAT_RELOC_TARGET_DATA; } } err("Could not find region for sym_section \"%s\" (%p)\n", sym_section->name, sym_section); - return NXFLAT_RELOC_TYPE_NONE; + + return NXFLAT_RELOC_TARGET_UNKNOWN; } /*********************************************************************** @@ -682,7 +691,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, int i; int j; - nxflat_relocs = *relocs; + nxflat_relocs = *relocs; nxflat_reloc_count = *n_relocs; for (i = 0; i < inf->nsubsects; i++) @@ -924,7 +933,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, /* And tuck in the new relocation. */ - nxflat_relocs[nxflat_reloc_count].r_info = NXFLAT_RELOC(reltype, relpp[j]->address); + nxflat_relocs[nxflat_reloc_count].r_info = NXFLAT_RELOC(NXFLAT_RELOC_TYPE_ABS32, relpp[j]->address); nxflat_reloc_count++; } } @@ -1053,7 +1062,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, /* Locate the address referred to by the section type. */ reltype = get_reloc_type(rel_section, NULL); - if (reltype == NXFLAT_RELOC_TYPE_TEXT) + if (reltype == NXFLAT_RELOC_TARGET_TEXT) { err("Symbol in GOT32 relocation is in TEXT\n"); err(" At addr %08x to sym '%s' [%08x]\n", @@ -1087,7 +1096,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, /* Locate the address referred to by the section type. */ reltype = get_reloc_type(rel_section, NULL); - if (reltype != NXFLAT_RELOC_TYPE_DATA) + if (reltype != NXFLAT_RELOC_TARGET_DATA) { err("Symbol in GOT32 relocation is not .data\n"); err(" At addr %08x to sym '%s' [%08x]\n", @@ -1102,7 +1111,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, /* And tuck in the new relocation. */ - nxflat_relocs[nxflat_reloc_count].r_info = NXFLAT_RELOC(reltype, relpp[j]->address); + nxflat_relocs[nxflat_reloc_count].r_info = NXFLAT_RELOC(NXFLAT_RELOC_TYPE_REL32D, relpp[j]->address); nxflat_reloc_count++; #endif } @@ -1143,7 +1152,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, /* Locate the address referred to by section type. */ reltype = get_reloc_type(rel_section, NULL); - if (reltype != NXFLAT_RELOC_TYPE_TEXT) + if (reltype != NXFLAT_RELOC_TARGET_TEXT) { err("Symbol in GOTPC relocation is not .text\n"); err(" At addr %08x to sym '%s' [%08x]\n", @@ -1158,7 +1167,7 @@ resolve_segment_relocs(bfd * input_bfd, segment_info * inf, asymbol ** syms, /* And tuck in the new relocation. */ - nxflat_relocs[nxflat_reloc_count].r_info = NXFLAT_RELOC(reltype, relpp[j]->address); + nxflat_relocs[nxflat_reloc_count].r_info = NXFLAT_RELOC(NXFLAT_RELOC_TYPE_REL32I, relpp[j]->address); nxflat_reloc_count++; } } @@ -1480,10 +1489,10 @@ static struct nxflat_reloc_s *output_relocs(bfd * input_bfd, asymbol ** symbols, int rc; int i; - *n_relocs = 0; - nxflat_relocs = NULL; + *n_relocs = 0; + nxflat_relocs = NULL; nxflat_reloc_count = 0; - rc = 0; + rc = 0; vdbg("Before map high mark %08x cooked %08x raw %08x \n", (int)bss_info.high_mark, (int)bss_info.subsect[0]->COOKED_SIZE, @@ -1637,19 +1646,16 @@ static void show_usage(void) fprintf(stderr, "Where options are one or more of the following. Note\n"); fprintf(stderr, "that a space is always required between the option and\n"); fprintf(stderr, "any following arguments.\n\n"); - fprintf(stderr, " -d Use dynamic symbol table [symtab]\n"); + fprintf(stderr, " -d Use dynamic symbol table [Default: symtab]\n"); fprintf(stderr, " -e <entry-point>\n"); - fprintf(stderr, " Entry point to module [%s for executable]\n", + fprintf(stderr, " Entry point to module [Default: %s]\n", default_exe_entry_name); - fprintf(stderr, " NULL for shared library\n"); fprintf(stderr, " -o <out-filename>\n"); - fprintf(stderr, " Output to <out-filename> [<bfd-filename>.xflt]\n"); + fprintf(stderr, " Output to <out-filename> [Default: <bfd-filename>.nxf]\n"); fprintf(stderr, " -s <stack-size>\n"); - fprintf(stderr, " Set stack size to <stack-size>. Ignored if -l also\n"); - fprintf(stderr, " selected. [%d]\n", DEFAULT_STACK_SIZE); - fprintf(stderr, " -v Verbose output [no verbose output]\n"); - fprintf(stderr, " If -v is applied twice, additional debug output\n"); - fprintf(stderr, " be enabled.\n"); + fprintf(stderr, " Set stack size to <stack-size> [Default: %d]\n", DEFAULT_STACK_SIZE); + fprintf(stderr, " -v Verbose outpu.t If -v is applied twice, additional\n"); + fprintf(stderr, " debug output is enabled [Default: no verbose output].\n"); fprintf(stderr, "\n"); exit(2); } @@ -1683,7 +1689,6 @@ static void parse_args(int argc, char **argv) { switch (opt) { - case 'd': dsyms++; break; @@ -1801,29 +1806,29 @@ int main(int argc, char **argv, char **envp) dbg("Reading section %s\n", s->name); /* ignore blatantly useless sections */ - if (is_unwanted_section(s)) - continue; - if (s->flags == SEC_ALLOC) - { - vdbg(" Section %s is ALLOC only\n", s->name); - register_section(s, &bss_info); - continue; - } - if ((s->flags & SEC_CODE) && (s->flags & SEC_ALLOC)) - { - vdbg(" Section %s is CODE\n", s->name); - register_section(s, &text_info); - continue; - } - if ((s->flags & SEC_DATA) && (s->flags & SEC_ALLOC)) + if (!is_unwanted_section(s)) { - vdbg(" Section %s is DATA\n", s->name); - register_section(s, &data_info); - continue; + if (s->flags == SEC_ALLOC) + { + vdbg(" Section %s is ALLOC only\n", s->name); + register_section(s, &bss_info); + } + else if ((s->flags & SEC_CODE) != 0 && (s->flags & SEC_ALLOC) != 0) + { + vdbg(" Section %s is CODE\n", s->name); + register_section(s, &text_info); + } + else if ((s->flags & SEC_DATA) != 0 && (s->flags & SEC_ALLOC) != 0) + { + vdbg(" Section %s is DATA\n", s->name); + register_section(s, &data_info); + } + else + { + vdbg("WARNING: ignoring section %s\n", s->name); + } } - - vdbg("WARNING: ignoring section %s\n", s->name); } /* Fixup high and low water VMA address */ @@ -1925,9 +1930,9 @@ int main(int argc, char **argv, char **envp) reloc = (u_int32_t*)output_relocs(bf, symbol_table, number_of_symbols, &reloc_len); - /* Fill in the xFLT file header */ + /* Fill in the NXFLAT file header */ - memcpy(hdr.h_magic, "xFLT", 4); + memcpy(hdr.h_magic, NXFLAT_MAGIC, 4); put_xflat32(&hdr.h_datastart, NXFLAT_HDR_SIZE + text_info.size); put_xflat32(&hdr.h_dataend, NXFLAT_HDR_SIZE + text_info.size + data_info.size); @@ -1966,7 +1971,7 @@ int main(int argc, char **argv, char **envp) { out_filename = malloc(strlen(bfd_filename) + 5); /* 5 to add suffix */ strcpy(out_filename, bfd_filename); - strcat(out_filename, ".xflt"); + strcat(out_filename, ".nxf"); } fd = open(out_filename, O_WRONLY | O_PLATFORM | O_CREAT | O_TRUNC, 0744); diff --git a/misc/buildroot/toolchain/nxflat/nxflat.h b/misc/buildroot/toolchain/nxflat/nxflat.h index e8419426a..577d6a9e7 100644 --- a/misc/buildroot/toolchain/nxflat/nxflat.h +++ b/misc/buildroot/toolchain/nxflat/nxflat.h @@ -62,55 +62,73 @@ ****************************************************************************/ struct nxflat_hdr_s - { - /* The "magic number" identifying the file type. This field should contain - * "NxFT". NOTE that there is no other versioning information other than - * this magic number. */ - - char h_magic[4]; - - /* The following fields provide the memory map for the nxflat binary. - * h_entry - Offset to the the first executable insruction from the - * beginning of the file. h_datastart - Offset to the beginning of the data - * segment from the beginning of the file. This field can also interpreted - * as the size of the ISpace segment. h_dataend - Offset to the end of the - * data segment from the beginning of the file. h_bssend - Offset to the - * end of bss segment from the beginning of the file. The text segment can - * be considered to be the contiguous (unrelocated) address space range - * from address zero through (but not including) h_datastart. The size of - * the data/bss segment includes (as a minimum) the data and bss regions - * (bss_end - data_start) as well as the size of the stack. At run time, - * this region will also include program arguments and environement - * variables. The bss segment is data_end through bss_end. */ - - u_int32_t h_entry; - u_int32_t h_datastart; - u_int32_t h_dataend; - u_int32_t h_bssend; - - /* Size of stack, in bytes */ - - u_int32_t h_stacksize; - - /* Relocation entries h_relocstart - Offset to the beginning of an array of - * relocation records (struct nxflat_reloc). The offset is relative to the - * start of the file h_reloccount - The number of relocation records in the - * arry */ - - u_int32_t h_relocstart; /* Offset of relocation records */ - u_int32_t h_reloccount; /* Number of relocation records */ - - /* Imported symbol table (NOTE no symbols are exported) h_importsymbols - - * Offset to the beginning of an array of imported symbol structures - * (struct nxflat_import). The h_importsymbols offset is relative to the - * beginning of the file. Each entry of the array contains an u_int32_t - * offset (again from the beginning of the file) to the name of a symbol - * string. This string is null-terminated. h_importcount - The number of - * records in the h_exportsymbols array. */ - - u_int32_t h_importsymbols; /* Offset to list of imported symbols */ - u_int16_t h_importcount; /* Number of imported symbols */ - }; +{ + /* The "magic number" identifying the file type. This field should contain + * "NxFT". NOTE that there is no other versioning information other than + * this magic number. + */ + + char h_magic[4]; + + /* The following fields provide the memory map for the nxflat binary. + * + * h_entry - Offset to the the first executable insruction from + * the beginning of the file. + * h_datastart - Offset to the beginning of the data segment from + * the beginning of the file. This field can also + * interpreted as the size of the ISpace segment. + * h_dataend - Offset to the end of the data segment from the + * beginning of the file. + * h_bssend - Offset to the end of bss segment from the beginning + * of the file. + * + * The text segment can be considered to be the contiguous (unrelocated) + * address space range from address zero through (but not including) + * h_datastart. + * + * The size of the data/bss segment includes (as a minimum) the data + * and bss regions (bss_end - data_start) as well as the size of the + * stack. At run time, this region will also include program arguments + * and environement variables. + * + * The bss segment is data_end through bss_end. + */ + + u_int32_t h_entry; + u_int32_t h_datastart; + u_int32_t h_dataend; + u_int32_t h_bssend; + + /* Size of stack, in bytes */ + + u_int32_t h_stacksize; + + /* Relocation entries: + * + * h_relocstart - Offset to the beginning of an array of relocation + * records (struct nxflat_reloc). The offset is + * relative to the start of the file + * h_reloccount - The number of relocation records in the arry + */ + + u_int32_t h_relocstart; /* Offset of relocation records */ + u_int32_t h_reloccount; /* Number of relocation records */ + + /* Imported symbol table (NOTE no symbols are exported): + * + * h_importsymbols - Offset to the beginning of an array of imported + * symbol structures (struct nxflat_import). The + * h_importsymbols offset is relative to the + * beginning of the file. Each entry of the + * array contains an uint32 offset (again from + * the beginning of the file) to the name of + * a symbol string. This string is null-terminated. + * h_importcount - The number of records in the h_exportsymbols array. + */ + + u_int32_t h_importsymbols; /* Offset to list of imported symbols */ + u_int16_t h_importcount; /* Number of imported symbols */ +}; /**************************************************************************** * NXFLAT Relocation types. @@ -119,33 +137,46 @@ struct nxflat_hdr_s ****************************************************************************/ struct nxflat_reloc_s - { - u_int32_t r_info; /* Bit-encoded relocation info */ - }; +{ + u_int32_t r_info; /* Bit-encoded relocation info */ +}; /* Pack the type and the offset into one 32-bit value */ -#define NXFLAT_RELOC(t,o) (((u_int32_t)((t) & 3) << 28) | ((o) & 0x1fffffff)) +#define NXFLAT_RELOC(t,o) (((u_int32_t)((t) & 3) << 30) | ((o) & 0x1fffffff)) /* The top three bits of the relocation info is the relocation type (see the * NXFLAT_RELOC_TYPE_* definitions below. This is an unsigned value. */ -#define NXFLAT_RELOC_TYPE(r) ((u_int32_t)(r) >> 28) +#define NXFLAT_RELOC_TYPE(r) ((u_int32_t)(r) >> 30) /* The bottom 28 bits of the relocation info is the (non-negative) offset into * the D-Space that needs the fixup. */ -#define NXFLAT_RELOC_OFFSET(r) ((u_int32_t)(r) & 0x1fffffff) +#define NXFLAT_RELOC_OFFSET(r) ((u_int32_t)(r) & 0x3fffffff) -/* These are possible values for the relocation type */ +/* These are possible values for the relocation type: + * + * NXFLAT_RELOC_TYPE_REL32I Meaning: Object file contains a 32-bit offset + * into I-Space at the the offset. + * Fixup: Add mapped I-Space address to the offset. + * NXFLAT_RELOC_TYPE_REL32D Meaning: Object file contains a 32-bit offset + * into D-Space at the the offset. + * Fixup: Add allocated D-Space address to the + * offset. + * NXFLAT_RELOC_TYPE_ABS32 Meaning: Offset refers to a struct nxflat_import_s + * describing a function pointer to be + * imported. + * Fixup: Provide the absolute function address + * in the struct nxflat_import_s instance. + */ -#define NXFLAT_RELOC_TYPE_NONE 0 /* Invalid relocation type */ -#define NXFLAT_RELOC_TYPE_TEXT 1 /* Symbol lies in .text region */ -#define NXFLAT_RELOC_TYPE_DATA 2 /* Symbol lies in .data region */ -#define NXFLAT_RELOC_TYPE_BSS 3 /* Symbol lies in .bss region */ -#define NXFLAT_RELOC_TYPE_NUM 4 +#define NXFLAT_RELOC_TYPE_REL32I 0 +#define NXFLAT_RELOC_TYPE_REL32D 1 +#define NXFLAT_RELOC_TYPE_ABS32 2 +#define NXFLAT_RELOC_TYPE_NUM 3 /* Number of relocation types */ /**************************************************************************** * NXFLAT Imported symbol type @@ -155,10 +186,10 @@ struct nxflat_reloc_s ****************************************************************************/ struct nxflat_import_s - { - u_int32_t i_funcname; /* Offset to name of imported function */ - u_int32_t i_funcaddress; /* Resolved address of imported function */ - }; +{ + u_int32_t i_funcname; /* Offset to name of imported function */ + u_int32_t i_funcaddress; /* Resolved address of imported function */ +}; #endif /* __TOOLCHAIN_NXFLAT_NXFLAT_H */ diff --git a/misc/buildroot/toolchain/nxflat/readxflat.c b/misc/buildroot/toolchain/nxflat/readnxflat.c index d4131bc75..783ffabb7 100644 --- a/misc/buildroot/toolchain/nxflat/readxflat.c +++ b/misc/buildroot/toolchain/nxflat/readnxflat.c @@ -94,16 +94,14 @@ static int big_endian = 0; /* Assume little-endian */ static const char unknown[] = "UNKNOWN"; -static const char header_reloc_none[] = "RELOC_NONE"; -static const char header_reloc_text[] = "RELOC_TEXT"; -static const char header_reloc_data[] = "RELOC_DATA"; -static const char header_reloc_bss[] = "RELOC_BSS"; +static const char hdr_reloc_rel32i[] = "RELOC_REL32I"; +static const char hdr_reloc_rel32d[] = "RELOC_REL32D"; +static const char hdr_reloc_abs32[] = "RELOC_ABS32"; static const char *reloc_type_string[] = { - header_reloc_none, - header_reloc_text, - header_reloc_data, - header_reloc_bss, + hdr_reloc_rel32i, + hdr_reloc_rel32d, + hdr_reloc_abs32, unknown }; @@ -287,31 +285,34 @@ static void disassemble_text(FILE * in_stream, struct nxflat_hdr_s *header) * dump_imported_symbols ***********************************************************************/ -static void dump_imported_symbols(FILE * in_stream, struct nxflat_hdr_s *header) +static void dump_imported_symbols(FILE *in_stream, struct nxflat_hdr_s *header) { struct nxflat_import_s import; u_int32_t import_offset; - u_int32_t file_offset; + u_int32_t data_start; + u_int32_t struct_offset; + u_int32_t name_offset; char imported_symbol_name[NXFLAT_MAX_STRING_SIZE]; int status; int i; printf("\nIMPORTED SYMBOLS:\n"); - printf(" ADDRESS DATA SEGM SYMBOL NAME\n\n"); + printf(" OFFSET ADDRESS SYMBOL NAME\n\n"); import_offset = get_nxflat32(&header->h_importsymbols); + data_start = get_nxflat32(&header->h_datastart); for (i = 0; i < get_nxflat16(&header->h_importcount); i++) { /* Seek to the next imported symbol */ - file_offset = i * sizeof(struct nxflat_import_s) + import_offset; + struct_offset = i * sizeof(struct nxflat_import_s) + import_offset; - if (fseek(in_stream, file_offset, SEEK_SET) != 0) + if (fseek(in_stream, struct_offset, SEEK_SET) != 0) { fprintf(stderr, "ERROR: fseek to imported symbol %d struct failed\n", i); - fprintf(stderr, " file_offset: %d, errno: %d\n", file_offset, + fprintf(stderr, " struct_offset: %d, errno: %d\n", struct_offset, errno); exit(1); } @@ -330,7 +331,7 @@ static void dump_imported_symbols(FILE * in_stream, struct nxflat_hdr_s *header) if (big_endian) { - import.i_funcname = nxflat_swap32(import.i_funcname); + import.i_funcname = nxflat_swap32(import.i_funcname); import.i_funcaddress = nxflat_swap32(import.i_funcaddress); } @@ -344,13 +345,13 @@ static void dump_imported_symbols(FILE * in_stream, struct nxflat_hdr_s *header) /* Seek to the function name in the file */ - file_offset = import.i_funcname + NXFLAT_HDR_SIZE; - if (0 != fseek(in_stream, file_offset, SEEK_SET)) + name_offset = import.i_funcname + NXFLAT_HDR_SIZE; + if (0 != fseek(in_stream, name_offset, SEEK_SET)) { fprintf(stderr, "ERROR: fseek to imported symbol %d name failed\n", i); - fprintf(stderr, " file_offset: %d, errno: %d\n", - file_offset, errno); + fprintf(stderr, " name_offset: %d, errno: %d\n", + name_offset, errno); exit(1); } @@ -369,7 +370,7 @@ static void dump_imported_symbols(FILE * in_stream, struct nxflat_hdr_s *header) /* And print it */ - printf("%5d ", i + 1); + printf("%5d %08x ", i + 1, (int)struct_offset - data_start); if (import.i_funcaddress) { @@ -377,7 +378,7 @@ static void dump_imported_symbols(FILE * in_stream, struct nxflat_hdr_s *header) } else { - printf("UNKNOWN "); + printf("UNKNOWN "); } printf("%s\n", imported_symbol_name); @@ -404,7 +405,7 @@ static void dump_relocation_entries(FILE * in_stream, struct nxflat_hdr_s *heade } printf("\nRELOCATION ENTRIES:\n"); - printf(" DATA OFFS RELOC TYPE\n\n"); + printf(" OFFSET RELOC TYPE\n\n"); for (i = 0; i < get_nxflat32(&header->h_reloccount); i++) { @@ -436,7 +437,7 @@ static void dump_relocation_entries(FILE * in_stream, struct nxflat_hdr_s *heade } else { - printf("%5d %08x %s\n", + printf("%5d %08x %-13s\n", i + 1, NXFLAT_RELOC_OFFSET(reloc.r_info), reloc_type_string[NXFLAT_RELOC_TYPE(reloc.r_info)]); } @@ -452,25 +453,25 @@ static void dump_hdr(struct nxflat_hdr_s *header) /* Print the contents of the FLT header */ printf("\nXFLAT HEADER:\n"); - printf("\nMagic %c%c%c%c\n", + printf("\nMagic %c%c%c%c\n", header->h_magic[0], header->h_magic[1], header->h_magic[2], header->h_magic[3]); printf("\nMEMORY MAP:\n"); - printf(" Text start %08lx\n", NXFLAT_HDR_SIZE); - printf(" Entry point %08x\n", get_nxflat32(&header->h_entry)); - printf(" Data start %08x\n", get_nxflat32(&header->h_datastart)); - printf(" Data end %08x\n", get_nxflat32(&header->h_dataend) - 1); - printf(" Bss start %08x\n", get_nxflat32(&header->h_dataend)); - printf(" Bss end %08x\n", get_nxflat32(&header->h_bssend) - 1); - printf("TOTAL SIZE %08x\n\n", get_nxflat32(&header->h_bssend)); - printf("Stack size %08x\n", get_nxflat32(&header->h_stacksize)); + printf(" Text start %08lx\n", NXFLAT_HDR_SIZE); + printf(" Entry point %08x\n", get_nxflat32(&header->h_entry)); + printf(" Data start %08x\n", get_nxflat32(&header->h_datastart)); + printf(" Data end %08x\n", get_nxflat32(&header->h_dataend) - 1); + printf(" Bss start %08x\n", get_nxflat32(&header->h_dataend)); + printf(" Bss end %08x\n", get_nxflat32(&header->h_bssend) - 1); + printf("TOTAL SIZE %08x\n\n", get_nxflat32(&header->h_bssend)); + printf("Stack size %08x\n", get_nxflat32(&header->h_stacksize)); printf("\nRELOCATIONS:\n"); - printf(" Reloc start %08x\n", get_nxflat32(&header->h_relocstart)); - printf(" reloc count %d\n", get_nxflat32(&header->h_reloccount)); + printf(" Reloc start %08x\n", get_nxflat32(&header->h_relocstart)); + printf(" reloc count %d\n", get_nxflat32(&header->h_reloccount)); printf("\nIMPORTED SYMBOLS:\n"); - printf(" Import start %08x\n", get_nxflat32(&header->h_importsymbols)); - printf(" Import count %d\n\n", get_nxflat16(&header->h_importcount)); + printf(" Import start %08x\n", get_nxflat32(&header->h_importsymbols)); + printf(" Import count %d\n", get_nxflat16(&header->h_importcount)); } /*********************************************************************** |