/* BFD back-end for mmo objects (MMIX-specific object-format).
- Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
- Free Software Foundation, Inc.
+ Copyright 2001-2013 Free Software Foundation, Inc.
Written by Hans-Peter Nilsson (hp@bitrange.com).
Infrastructure and other bits originally copied from srec.c and
binary.c.
static void mmo_find_sec_w_addr_grow (bfd *, asection *, void *);
static asection *mmo_make_section (bfd *, const char *);
static void mmo_get_symbol_info (bfd *, asymbol *, symbol_info *);
-static void mmo_print_symbol (bfd *, void *, asymbol *,
+static void mmo_print_symbol (bfd *, void *, asymbol *,
bfd_print_symbol_type);
static void mmo_init (void);
static bfd_boolean mmo_mkobject (bfd *);
if (sec == NULL)
return NULL;
- if (! sec->user_set_vma)
- bfd_set_section_vma (abfd, sec, vma);
+ if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma))
+ return NULL;
+
if (! bfd_set_section_flags (abfd, sec,
bfd_get_section_flags (abfd, sec)
| SEC_CODE | SEC_LOAD | SEC_ALLOC))
if (sec == NULL)
return NULL;
- if (! sec->user_set_vma)
- bfd_set_section_vma (abfd, sec, vma);
+ if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma))
+ return NULL;
+
if (! bfd_set_section_flags (abfd, sec,
bfd_get_section_flags (abfd, sec)
| SEC_LOAD | SEC_ALLOC))
/* If there's still no suitable section, make a new one. */
sprintf (sec_name, ".MMIX.sec.%d", abfd->tdata.mmo_data->sec_no++);
sec = mmo_make_section (abfd, sec_name);
- if (! sec->user_set_vma)
- bfd_set_section_vma (abfd, sec, vma);
+
+ if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma))
+ return NULL;
if (! bfd_set_section_flags (abfd, sec,
bfd_get_section_flags (abfd, sec)
mmo_write_chunk (bfd *abfd, const bfd_byte *loc, unsigned int len)
{
bfd_boolean retval = TRUE;
+ struct mmo_data_struct *mmop = abfd->tdata.mmo_data;
/* Fill up a tetra from bytes remaining from a previous chunk. */
- if (abfd->tdata.mmo_data->byte_no != 0)
+ if (mmop->byte_no != 0)
{
- while (abfd->tdata.mmo_data->byte_no < 4 && len != 0)
+ while (mmop->byte_no < 4 && len != 0)
{
- abfd->tdata.mmo_data->buf[abfd->tdata.mmo_data->byte_no++] = *loc++;
+ mmop->buf[mmop->byte_no++] = *loc++;
len--;
}
- if (abfd->tdata.mmo_data->byte_no == 4)
+ if (mmop->byte_no == 4)
{
- mmo_write_tetra (abfd,
- bfd_get_32 (abfd, abfd->tdata.mmo_data->buf));
- abfd->tdata.mmo_data->byte_no = 0;
+ mmo_write_tetra (abfd, bfd_get_32 (abfd, mmop->buf));
+ mmop->byte_no = 0;
}
}
mmo_write_tetra_raw (abfd, LOP_QUOTE_NEXT);
retval = (retval
- && ! abfd->tdata.mmo_data->have_error
+ && ! mmop->have_error
&& 4 == bfd_bwrite (loc, 4, abfd));
loc += 4;
if (len)
{
- memcpy (abfd->tdata.mmo_data->buf, loc, len);
- abfd->tdata.mmo_data->byte_no = len;
+ memcpy (mmop->buf, loc, len);
+ mmop->byte_no = len;
}
if (! retval)
- abfd->tdata.mmo_data->have_error = TRUE;
+ mmop->have_error = TRUE;
return retval;
}
asection *sec = bfd_make_section_old_way (abfd, MMO_TEXT_SECTION_NAME);
asection *non_spec_sec = NULL;
bfd_vma non_spec_vma = 0;
- char *current_filename = NULL;
bfd_size_type nbytes_read = 0;
/* Buffer with room to read a 64-bit value. */
bfd_byte buf[8];
long stab_loc = -1;
char *file_names[256];
+ abfd->symcount = 0;
memset (file_names, 0, sizeof (file_names));
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
goto error_return;
}
- current_filename = file_names[y];
lineno = 0;
break;
mmo_write_symbols_and_terminator (bfd *abfd)
{
int count = bfd_get_symcount (abfd);
- asymbol *maintable[2];
asymbol **table;
asymbol **orig_table = bfd_get_outsymbols (abfd);
int serno;
fakemain->value = bfd_get_start_address (abfd);
fakemain->name = MMIX_START_SYMBOL_NAME;
fakemain->section = bfd_abs_section_ptr;
- maintable[0] = fakemain;
- maintable[1] = NULL;
memset (&root, 0, sizeof (root));
#define mmo_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define mmo_bfd_gc_sections bfd_generic_gc_sections
+#define mmo_bfd_lookup_section_flags bfd_generic_lookup_section_flags
#define mmo_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define mmo_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
#define mmo_bfd_link_add_symbols _bfd_generic_link_add_symbols
0, /* leading underscore */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
+ 0, /* match priority. */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */