fix archive scanning, linking and support more amiga mem types

This commit is contained in:
bebbo 2017-12-21 19:15:35 +01:00
parent 72e25c3819
commit 146f10290b
8 changed files with 73 additions and 24 deletions

View File

@ -2031,7 +2031,7 @@ determine_type (r)
return 0;
case H_ABS16: /* 16 bit absolute */
return 1;
return 0; // not working properly?
case H_PC32: /* 32 bit pcrel */
return 2;
@ -2304,6 +2304,13 @@ amiga_write_section_contents (abfd, section, data_sec, datadata_relocs,
if (reloc_count > 0)
{
/* do not use H_ABS32 and H_ABS16 simultaneous. */
if (reloc_counts[0] && reloc_counts[1])
{
}
/* Sample every reloc type */
for (i = 0; i < NB_RELOC_TYPES; i++)
{
@ -2726,6 +2733,8 @@ amiga_new_section_hook (abfd, newsect)
newsect->alignment_power = 2;
if (!strcmp (newsect->name, ".data_chip") || !strcmp (newsect->name, ".bss_chip"))
amiga_per_section(newsect)->attribute |= MEMF_CHIP;
if (!strcmp (newsect->name, ".data_fast") || !strcmp (newsect->name, ".bss_fast"))
amiga_per_section(newsect)->attribute |= MEMF_FAST;
return TRUE;
}
@ -2843,6 +2852,12 @@ amiga_slurp_symbol_table (abfd)
amiga_per_section_type *astab = amiga_per_section(stab);
amiga_per_section_type *astabstr = amiga_per_section(stabstr);
if (sbss == 0)
sbss = amiga_make_unique_section (abfd, ".bss");
if (sdata == 0)
sdata = amiga_make_unique_section (abfd, ".data");
unsigned char * stabstrdata = (unsigned char *) bfd_alloc (abfd, astabstr->disk_size);
if (!stabstrdata)
return FALSE;

View File

@ -123,6 +123,7 @@ amiga_reloc_link_order PARAMS ((bfd *, struct bfd_link_info *, asection *,
enum { ADDEND_UNSIGNED=0x01, RELOC_SIGNED=0x02 };
int relocation;
/* This one is nearly identical to bfd_generic_get_relocated_section_contents
in reloc.c */
@ -245,6 +246,7 @@ get_relocated_section_contents (abfd, link_info, link_order, data,
default:
DPRINT(10,("get_rel_sec_cont fails, perform reloc "
"returned $%x\n",r));
fprintf(stderr, "%s: %s reloc for %s is out of range: %08x\n", abfd->filename, (*(*parent)->sym_ptr_ptr)->section->name, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), relocation);
abort ();
break;
}
@ -387,7 +389,7 @@ amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
sec_ptr target_section; /* reloc is relative to this section */
bfd_reloc_status_type ret;
bfd_boolean copy;
int relocation,flags;
int flags;
DPRINT(5,("Entering APR\nflavour is %d (amiga_flavour=%d, aout_flavour=%d)\n",
bfd_get_flavour (sec->owner), bfd_target_amiga_flavour,
@ -425,6 +427,7 @@ amiga_perform_reloc (abfd, r, data, sec, obfd, error_message)
DPRINT(5,("%s: size=%u\n",r->howto->name,bfd_get_reloc_size(r->howto)));
switch (r->howto->type)
{
case H_ABS16:
case H_ABS32:
if (bfd_is_abs_section(target_section)) /* Ref to absolute hunk */
relocation=sym->value;

View File

@ -89,7 +89,7 @@ char *myname;
segT reg_section, expr_section;
segT text_section, data_section, bss_section;
#ifdef OBJ_AMIGAHUNK
segT data_chip_section, bss_chip_section;
segT data_chip_section, data_fast_section, data_far_section, bss_chip_section, bss_fast_section, bss_far_section;
#endif
#endif
@ -1049,7 +1049,11 @@ perform_an_assembly_pass (argc, argv)
bss_section = subseg_new (BSS_SECTION_NAME, 0);
#ifdef OBJ_AMIGAHUNK
data_chip_section = subseg_new (".data_chip", 0);
data_fast_section = subseg_new (".data_fast", 0);
data_far_section = subseg_new (".data_far", 0);
bss_chip_section = subseg_new (".bss_chip", 0);
bss_fast_section = subseg_new (".bss_fast", 0);
bss_far_section = subseg_new (".bss_far", 0);
#endif
/* @@ FIXME -- we're setting the RELOC flag so that sections are assumed
to have relocs, otherwise we don't find out in time. */
@ -1064,7 +1068,13 @@ perform_an_assembly_pass (argc, argv)
#ifdef OBJ_AMIGAHUNK
bfd_set_section_flags (stdoutput, data_chip_section,
applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC));
bfd_set_section_flags (stdoutput, data_fast_section,
applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC));
bfd_set_section_flags (stdoutput, data_far_section,
applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC));
bfd_set_section_flags (stdoutput, bss_chip_section, applicable & SEC_ALLOC);
bfd_set_section_flags (stdoutput, bss_fast_section, applicable & SEC_ALLOC);
bfd_set_section_flags (stdoutput, bss_far_section, applicable & SEC_ALLOC);
#endif
seg_info (bss_section)->bss = 1;

View File

@ -25,6 +25,7 @@
#include "obstack.h"
#include "subsegs.h"
#include "dwarf2dbg.h"
#include "struc-symbol.h"
#include "opcode/m68k.h"
#include "m68k-parse.h"
@ -1576,7 +1577,8 @@ m68k_ip (instring)
case 'B': /* FOO */
if (opP->mode != ABSL
|| (flag_long_jumps
&& strncmp (instring, "jbsr", 4) == 0))
&& opP->disp.exp.X_add_symbol->bsym && opP->disp.exp.X_add_symbol->bsym->name[0] != '.'
&& (strncmp (instring, "jbsr", 4) == 0 || strncmp (instring, "jra", 3) == 0)))
losing++;
break;
@ -7176,8 +7178,8 @@ md_show_usage (stream)
target has/lacks memory-management unit coprocessor\n\
[default yes for 68020 and up]\n\
-pic, -k generate position independent code\n\
-S turn jbsr into jsr\n\
-smallcode, -sc small code model\n\
-S turn jbsr into jsr and keeps jra for non local labels.\n\
-smallcode, -sc small code model - does nothing atm\n\
--pcrel never turn PC-relative branches into absolute jumps\n\
--register-prefix-optional\n\
recognize register names without prefix character\n\

View File

@ -49,7 +49,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#endif
#ifdef OBJ_AMIGAHUNK
extern segT data_chip_section, bss_chip_section;
extern segT data_chip_section, data_fast_section, data_far_section, bss_chip_section, bss_fast_section, bss_far_section;
#endif
/* Set by the object-format or the target. */
@ -282,7 +282,12 @@ static const pseudo_typeS potable[] = {
{"common.s", s_mri_common, 1},
{"data", s_data, 0},
#ifdef OBJ_AMIGAHUNK
{"datachip", s_data_chip, 0},
{"datachip", s_data_amiga, 0},
{"datafast", s_data_amiga, 1},
{"datafar", s_data_amiga, 2},
{"bsschip", s_data_amiga, 0+8},
{"bssfast", s_data_amiga, 1+8},
{"bssfar", s_data_amiga, 2+8},
#endif
{"dc", cons, 2},
{"dc.b", cons, 1},
@ -1565,11 +1570,30 @@ s_data (ignore)
#ifdef OBJ_AMIGAHUNK
void
s_data_chip (ignore)
int ignore ATTRIBUTE_UNUSED;
s_data_amiga (which)
int which;
{
int temp = get_absolute_expression ();
subseg_set (data_chip_section, (subsegT) temp);
switch (which) {
case 0:
subseg_set (data_chip_section, (subsegT) temp);
break;
case 1:
subseg_set (data_fast_section, (subsegT) temp);
break;
case 2:
subseg_set (data_far_section, (subsegT) temp);
break;
case 8:
subseg_set (bss_chip_section, (subsegT) temp);
break;
case 9:
subseg_set (bss_fast_section, (subsegT) temp);
break;
case 10:
subseg_set (bss_far_section, (subsegT) temp);
break;
}
demand_empty_rest_of_line ();
}
#endif

View File

@ -145,7 +145,7 @@ extern void s_bad_endr PARAMS ((int));
extern void s_comm PARAMS ((int));
extern void s_data PARAMS ((int));
#ifdef OBJ_AMIGAHUNK
extern void s_data_chip PARAMS ((int));
extern void s_data_amiga PARAMS ((int));
#endif
extern void s_desc PARAMS ((int));
extern void s_else PARAMS ((int arg));

View File

@ -207,11 +207,9 @@ s_stab_generic (what, stab_secname, stabstr_secname)
{
int length;
string = demand_copy_C_string (&length);
/* FIXME: We should probably find some other temporary storage
for string, rather than leaking memory if someone else
happens to use the notes obstack. */
saved_string_obstack_end = notes.next_free;
string = strdup(demand_copy_C_string (&length));
saved_string_obstack_end = string;
SKIP_WHITESPACE ();
if (*input_line_pointer == ',')
input_line_pointer++;
@ -348,12 +346,6 @@ s_stab_generic (what, stab_secname, stabstr_secname)
}
stroff = get_stab_string_offset (string, stabstr_secname);
if (what == 's')
{
/* Release the string, if nobody else has used the obstack. */
if (saved_string_obstack_end == notes.next_free)
obstack_free (&notes, string);
}
/* At least for now, stabs in a special stab section are always
output as 12 byte blocks of information. */
@ -401,6 +393,9 @@ s_stab_generic (what, stab_secname, stabstr_secname)
#endif
}
if (saved_string_obstack_end)
free(string);
demand_empty_rest_of_line ();
}

View File

@ -1,4 +1,4 @@
/* struct_symbol.h - Internal symbol structure
/* struc-symbol.h - Internal symbol structure
Copyright 1987, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.