diff --git a/.cproject b/.cproject new file mode 100755 index 0000000..87a78fb --- /dev/null +++ b/.cproject @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project index bd06dd8..aadac31 100644 --- a/.project +++ b/.project @@ -5,7 +5,30 @@ + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + binutils-2.14 + 2 + D:/develop/workspaces/c1/amigaos-cross-toolchain/.build-m68k/build/binutils-2.14 + + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml new file mode 100755 index 0000000..3069ce3 --- /dev/null +++ b/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bfd/amigaos.c b/bfd/amigaos.c index 0801d9a..f1917b3 100644 --- a/bfd/amigaos.c +++ b/bfd/amigaos.c @@ -231,7 +231,7 @@ static bfd *amiga_openr_next_archived_file PARAMS ((bfd *, bfd *)); static PTR amiga_read_ar_hdr PARAMS ((bfd *)); static int amiga_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); -/*#define DEBUG_AMIGA 1*/ +//#define DEBUG_AMIGA 1 #if DEBUG_AMIGA #include static void @@ -815,6 +815,7 @@ amiga_read_unit (abfd, size) return (bfd_seek (abfd, -4, SEEK_CUR) == 0); case HUNK_DEBUG: +/* SBF: TODO */ /* we don't parse hunk_debug at the moment */ if (!get_long (abfd, &tmp) || bfd_seek (abfd, tmp<<2, SEEK_CUR)) return FALSE; @@ -1066,6 +1067,14 @@ amiga_handle_cdb_hunk (abfd, hunk_type, hunk_number, hunk_attribute, the debug hunk is at the same level as code/data/bss. This will change in the future */ case HUNK_DEBUG: + /* handle .stab and .stabs as real sections. */ + if (current_name && + (0 == strcmp(current_name, ".stab") || 0 == strcmp(current_name, ".stabstr"))) + { + secflags = SEC_HAS_CONTENTS; + goto do_section; + } + /* format of gnu debug hunk is: HUNK_DEBUG N @@ -1441,7 +1450,11 @@ amiga_write_object_contents (abfd) may get some contents later on */ if ((amiga_base_relative || p->_raw_size!=0 || p->_cooked_size!=0) && !(amiga_base_relative && !strcmp (p->name, ".bss"))) - n[2]++; + { + /* don't count debug sections. */ + if (strcmp(p->name, ".stab") && strcmp(p->name, ".stabstr")) + n[2]++; + } else remove_section_index (p, index_map); } @@ -1475,6 +1488,10 @@ amiga_write_object_contents (abfd) if (index_map[p->index] < 0) continue; + /* don't add debug sections. */ + if (!strcmp(p->name, ".stab") || !strcmp(p->name, ".stabstr")) + continue; + if (datadata_relocs && !strcmp(p->name,".text")) extra = datadata_relocs * 4; else if (bss_size && !strcmp (p->name, ".data")) @@ -1532,7 +1549,7 @@ amiga_write_object_contents (abfd) } for (p=abfd->sections; p!=NULL; p=p->next) { - if (p->_raw_size==0 && p->_cooked_size==0) + if (p->_raw_size==0 && p->_cooked_size==0 && strcmp(".text", p->name)) remove_section_index (p, index_map); } } @@ -3122,7 +3139,10 @@ amiga_archive_p (abfd) amiga_ardata(abfd)->defsyms = symbols; amiga_ardata(abfd)->defsym_count = symcount; if (amiga_slurp_armap (abfd)) - return abfd->xvec; + { + bfd_set_error(bfd_error_no_more_archived_files); + return abfd->xvec; + } } return NULL; diff --git a/bfd/amigaoslink.c b/bfd/amigaoslink.c index f713ebd..2bb8181 100644 --- a/bfd/amigaoslink.c +++ b/bfd/amigaoslink.c @@ -436,10 +436,17 @@ amiga_perform_reloc (abfd, r, data, sec, obfd, error_message) } else { - if (amiga_base_relative) - amiga_update_target_section (target_section); - relocation=0; - copy=TRUE; + if (0 == strcmp(sec->name, ".stab") || 0 == strcmp(sec->name, ".stabstr")) + { + relocation=sym->value + target_section->output_offset; + } + else + { + if (amiga_base_relative) + amiga_update_target_section (target_section); + relocation=0; + copy=TRUE; + } } break; @@ -700,7 +707,7 @@ aout_perform_reloc (abfd, r, data, sec, obfd, error_message) else /* Target section and sec need not be the same.. */ { aout_update_target_section (target_section); - +printf("val: %08x offset: %08x sz %08x ", sym->value, target_section->output_offset, target_section->output_section->_raw_size); relocation = sym->value + target_section->output_offset - (AMIGA_DATA(target_section->output_section->owner))->a4init; /* if the symbol is in .bss, subtract the offset that gas has put @@ -713,6 +720,7 @@ aout_perform_reloc (abfd, r, data, sec, obfd, error_message) target_section->owner->filename, target_section->output_offset, r->address)); flags|=ADDEND_UNSIGNED; +printf("reloc %08x %5s %s\n", relocation + (AMIGA_DATA(target_section->output_section->owner))->a4init, target_section->name, sym->name); } DPRINT(10,("target->out=%s(%lx), sec->out=%s(%lx), symbol=%s\n", target_section->output_section->name, diff --git a/bfd/libamiga.h b/bfd/libamiga.h index 691812d..3fa64cb 100644 --- a/bfd/libamiga.h +++ b/bfd/libamiga.h @@ -147,6 +147,9 @@ struct amiga_data { file_ptr sym_filepos; file_ptr str_filepos; /* rest intentionally omitted */ + + carsym *symdefs; /* the symdef entries */ + symindex symdef_count; /* how many there are */ }; typedef struct amiga_data_struct { diff --git a/gas/config/obj-amigahunk.c b/gas/config/obj-amigahunk.c index 95c7f5b..5e39d95 100644 --- a/gas/config/obj-amigahunk.c +++ b/gas/config/obj-amigahunk.c @@ -230,9 +230,9 @@ static void obj_amiga_section(int push) { return; if (0 == strcmp(".rodata", name)) - s_text(); + s_text(push); else - s_data(); + s_data(push); } static void @@ -275,3 +275,28 @@ obj_amiga_weak (ignore) while (c == ','); demand_empty_rest_of_line (); } + + +///* The first entry in a .stab section is special. */ +// +//void +//obj_amiga_init_stab_section (seg) +// segT seg; +//{ +// char *file; +// char *p; +// char *stabstr_name; +// unsigned int stroff; +// +// /* Make space for this first symbol. */ +// p = frag_more (12); +// /* Zero it out. */ +// memset (p, 0, 12); +// as_where (&file, (unsigned int *) NULL); +// stabstr_name = (char *) alloca (strlen (segment_info[seg].name) + 4); +// strcpy (stabstr_name, segment_info[seg].name); +// strcat (stabstr_name, "str"); +// stroff = get_stab_string_offset (file, stabstr_name); +// know (stroff == 1); +// md_number_to_chars (p, stroff, 4); +//} diff --git a/gas/config/obj-amigahunk.h b/gas/config/obj-amigahunk.h index 0b7d80e..62ff407 100644 --- a/gas/config/obj-amigahunk.h +++ b/gas/config/obj-amigahunk.h @@ -45,6 +45,15 @@ extern void obj_amiga_frob_file_before_fix PARAMS ((void)); #define obj_sec_sym_ok_for_reloc(SEC) (1) +/* Put the Stabs into an own section. */ +#define SEPARATE_STAB_SECTIONS 1 + +///* We need 12 bytes at the start of the section to hold some initial +// information. */ +//extern void obj_amiga_init_stab_section PARAMS ((segT)); +//#define INIT_STAB_SECTION(seg) obj_amiga_init_stab_section (seg) + + #endif /* BFD_ASSEMBLER */ #define obj_read_begin_hook() {;} diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index 9e39c64..f3fab95 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -7326,8 +7326,8 @@ md_pcrel_from (fixP) adjust = ((fixP->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80; if (adjust == 64) adjust = -1; - if (OBJ_AMIGAHUNK) - return -adjust; +// if (OBJ_AMIGAHUNK) +// return -adjust; return fixP->fx_where + fixP->fx_frag->fr_address - adjust; } diff --git a/gas/configure b/gas/configure index 6158476..eabbda4 100755 --- a/gas/configure +++ b/gas/configure @@ -3942,8 +3942,10 @@ echo "$as_me: WARNING: GAS support for ${generic_target} is preliminary and a wo m68hc11-*-* | m6811-*-*) fmt=elf ;; m68hc12-*-* | m6812-*-*) fmt=elf ;; - m68*-*-amigaoshunk) fmt=amigahunk em=amiga bfd_gas=yes ;; - m68*-*-amigaos*) fmt=aout em=amiga ;; + m68*-*-amigaosaout) fmt=aout em=amiga ;; +# m68*-*-amigaos*) fmt=aout em=amiga ;; + m68*-*-amigaos*) fmt=amigahunk em=amiga bfd_gas=yes ;; + m68*-*-amigaoshunk) fmt=amigahunk em=amiga bfd_gas=yes ;; m68k-*-vxworks*) fmt=aout em=sun3 ;; m68k-ericsson-ose) fmt=aout em=sun3 ;; m68k-*-sunos*) fmt=aout em=sun3 ;; diff --git a/gas/configure.in b/gas/configure.in index efc4ed8..304118a 100644 --- a/gas/configure.in +++ b/gas/configure.in @@ -328,8 +328,10 @@ changequote([,])dnl m68hc11-*-* | m6811-*-*) fmt=elf ;; m68hc12-*-* | m6812-*-*) fmt=elf ;; - m68k-*-amigaoshunk) fmt=amigahunk em=amiga bfd_gas=yes ;; - m68k-*-amigaos*) fmt=aout em=amiga ;; + m68*-*-amigaosaout) fmt=aout em=amiga ;; + m68*-*-amigaos*) fmt=aout em=amiga ;; +# m68*-*-amigaos*) fmt=amigahunk em=amiga bfd_gas=yes ;; + m68*-*-amigaoshunk) fmt=amigahunk em=amiga bfd_gas=yes ;; m68k-*-vxworks*) fmt=aout em=sun3 ;; m68k-ericsson-ose) fmt=aout em=sun3 ;; m68k-*-sunos*) fmt=aout em=sun3 ;; diff --git a/gas/read.c b/gas/read.c index b4458eb..59d753b 100644 --- a/gas/read.c +++ b/gas/read.c @@ -3235,6 +3235,10 @@ pseudo_set (symbolP) (void) expression (&exp); +#if defined(OBJ_AMIGAHUNK) + exp.X_op = O_constant; +#endif + if (exp.X_op == O_illegal) as_bad (_("illegal expression")); else if (exp.X_op == O_absent) diff --git a/gas/write.c b/gas/write.c index 7d2fc65..a5a151f 100644 --- a/gas/write.c +++ b/gas/write.c @@ -702,6 +702,12 @@ size_seg (abfd, sec, xxx) if (size > 0 && ! seginfo->bss) flags |= SEC_HAS_CONTENTS; +#ifdef OBJ_AMIGAHUNK + if (size == 0 && 0 == strcmp( sec->name, ".text")) + flags |= SEC_HAS_CONTENTS | SEC_CODE; +// fprintf(stderr, "%s: %d\n", sec->name, size); +#endif + /* @@ This is just an approximation. */ if (seginfo && seginfo->fix_root) flags |= SEC_RELOC; @@ -1143,11 +1149,17 @@ write_contents (abfd, sec, xxx) unsigned long offset = 0; fragS *f; + /* Write out the frags. */ if (seginfo == NULL || !(bfd_get_section_flags (abfd, sec) & SEC_HAS_CONTENTS)) return; + +#ifdef OBJ_AMIGAHUNK +// fprintf(stderr, "%s: %x %p\n", sec->name, (bfd_get_section_flags (abfd, sec)), seginfo->frchainP->frch_root); +#endif + for (f = seginfo->frchainP->frch_root; f; f = f->fr_next) @@ -1157,8 +1169,12 @@ write_contents (abfd, sec, xxx) char *fill_literal; long count; +// fprintf(stderr, "fragment %p: %d %d %d\n", f, f->fr_var, f->fr_offset, f->fr_fix); + assert (f->fr_type == rs_fill); - if (f->fr_fix) + if (f->fr_fix + || f->fr_var + ) { x = bfd_set_section_contents (stdoutput, sec, f->fr_literal, (file_ptr) offset,