/* BFD back-end for mmo objects (MMIX-specific object-format).
- Copyright 2001, 2002
+ Copyright 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by Hans-Peter Nilsson (hp@bitrange.com).
Infrastructure and other bits originally copied from srec.c and
mmo_data_list_type *tail;
};
+#define mmo_section_data(sec) \
+ ((struct mmo_section_data_struct *) (sec)->used_by_bfd)
+
/* These structures are used in bfd_map_over_sections constructs. */
/* Used when writing out sections; all but the register contents section
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
static long mmo_get_symtab_upper_bound
PARAMS ((bfd *));
-static long mmo_get_symtab
+static long mmo_canonicalize_symtab
PARAMS ((bfd *, asymbol **));
static void mmo_get_symbol_info
PARAMS ((bfd *, asymbol *, symbol_info *));
static void mmo_print_symbol
PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
static bfd_boolean mmo_set_section_contents
- PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
+ PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type));
static int mmo_sizeof_headers
PARAMS ((bfd *, bfd_boolean));
static long mmo_get_reloc_upper_bound
!= (SEC_LOAD | SEC_ALLOC))
return;
- if (infop->addr >= vma && infop->addr < vma + sec->_raw_size)
+ if (infop->addr >= vma && infop->addr < vma + sec->size)
infop->sec = sec;
}
bfd_sec_flags_from_mmo_flags (flags)
| bfd_get_section_flags (abfd, sec)
| (section_length != 0 ? SEC_HAS_CONTENTS : 0))
- || ! bfd_set_section_size (abfd, sec,
- sec->_cooked_size + section_length)
+ || ! bfd_set_section_size (abfd, sec, sec->size + section_length)
/* Set VMA only for the first occurrence. */
|| (! sec->user_set_vma
&& ! bfd_set_section_vma (abfd, sec, section_vma)))
}
loc->next = NULL;
- if (((struct mmo_section_data_struct *) (sec->used_by_bfd))->tail != NULL)
- ((struct mmo_section_data_struct *) (sec->used_by_bfd))->tail->next
- = loc;
+ if (mmo_section_data (sec)->tail != NULL)
+ mmo_section_data (sec)->tail->next = loc;
else
- ((struct mmo_section_data_struct *) (sec->used_by_bfd))->head = loc;
- ((struct mmo_section_data_struct *) (sec->used_by_bfd))->tail = loc;
+ mmo_section_data (sec)->head = loc;
+ mmo_section_data (sec)->tail = loc;
loc->where = section_vma;
return sec;
int size;
{
bfd_size_type allocated_size;
- struct mmo_section_data_struct *sdatap
- = (struct mmo_section_data_struct *) sec->used_by_bfd;
+ struct mmo_section_data_struct *sdatap = mmo_section_data (sec);
struct mmo_data_list_struct *datap = sdatap->head;
struct mmo_data_list_struct *entry;
non-32-bit-aligned sections should do all allocation and
size-setting by themselves or at least set the section size
after the last allocating call to this function. */
- if (vma + size > sec->vma + sec->_raw_size)
- sec->_raw_size += (vma + size) - (sec->vma + sec->_raw_size);
+ if (vma + size > sec->vma + sec->size)
+ sec->size += (vma + size) - (sec->vma + sec->size);
return datap->data + vma - datap->where;
}
/* Update the section size. This happens only when we add contents and
re-size as we go. The section size will then be aligned to 32 bits. */
- if (vma + size > sec->vma + sec->_raw_size)
- sec->_raw_size += (vma + size) - (sec->vma + sec->_raw_size);
+ if (vma + size > sec->vma + sec->size)
+ sec->size += (vma + size) - (sec->vma + sec->size);
return entry->data;
}
asection *sec;
PTR ignored ATTRIBUTE_UNUSED;
{
- sec->_cooked_size = sec->_raw_size;
sec->lma = sec->vma;
}
/* Translate the symbol table. */
static long
-mmo_get_symtab (abfd, alocation)
+mmo_canonicalize_symtab (abfd, alocation)
bfd *abfd;
asymbol **alocation;
{
if (textsec != NULL
&& c->value >= textsec->vma
- && c->value <= textsec->vma + textsec->_cooked_size)
+ && c->value <= textsec->vma + textsec->size)
{
c->section = textsec;
c->value -= c->section->vma;
if (strcmp (sec->name, MMO_TEXT_SECTION_NAME) == 0)
/* FIXME: Output source file name and line number. */
- return
- mmo_write_loc_chunk_list (abfd,
- ((struct mmo_section_data_struct *)
- (sec->used_by_bfd))->head);
+ return mmo_write_loc_chunk_list (abfd, mmo_section_data (sec)->head);
else if (strcmp (sec->name, MMO_DATA_SECTION_NAME) == 0)
- return
- mmo_write_loc_chunk_list (abfd,
- ((struct mmo_section_data_struct *)
- (sec->used_by_bfd))->head);
+ return mmo_write_loc_chunk_list (abfd, mmo_section_data (sec)->head);
else if (strcmp (sec->name, MMIX_REG_CONTENTS_SECTION_NAME) == 0)
/* Not handled here. */
{
int n = atoi (sec->name + strlen (MMIX_OTHER_SPEC_SECTION_PREFIX));
mmo_write_tetra_raw (abfd, (LOP << 24) | (LOP_SPEC << 16) | n);
return (! abfd->tdata.mmo_data->have_error
- && mmo_write_chunk_list (abfd,
- ((struct mmo_section_data_struct *)
- (sec->used_by_bfd))->head));
+ && mmo_write_chunk_list (abfd, mmo_section_data (sec)->head));
}
/* Ignore sections that are just allocated or empty; we write out
_contents_ here. */
else if ((bfd_get_section_flags (abfd, sec) & SEC_HAS_CONTENTS) != 0
- && sec->_raw_size != 0)
+ && sec->size != 0)
{
/* Keep the document-comment formatted the way it is. */
/*
mmo_write_tetra (abfd,
mmo_sec_flags_from_bfd_flags
(bfd_get_section_flags (abfd, sec)));
- mmo_write_octa (abfd, sec->_raw_size);
+ mmo_write_octa (abfd, sec->size);
mmo_write_octa (abfd, bfd_get_section_vma (abfd, sec));
/* Writing a LOP_LOC ends the LOP_SPEC data, and makes data actually
loaded. */
if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
- return
- ! abfd->tdata.mmo_data->have_error
- && mmo_write_loc_chunk_list (abfd,
- ((struct mmo_section_data_struct *)
- (sec->used_by_bfd))->head);
- return
- ! abfd->tdata.mmo_data->have_error
- && mmo_write_chunk_list (abfd,
- ((struct mmo_section_data_struct *)
- (sec->used_by_bfd))->head);
+ return (! abfd->tdata.mmo_data->have_error
+ && mmo_write_loc_chunk_list (abfd,
+ mmo_section_data (sec)->head));
+ return (! abfd->tdata.mmo_data->have_error
+ && mmo_write_chunk_list (abfd, mmo_section_data (sec)->head));
}
return TRUE;
}
mmo_set_section_contents (abfd, sec, location, offset, bytes_to_do)
bfd *abfd ATTRIBUTE_UNUSED;
sec_ptr sec;
- PTR location;
+ const PTR location;
file_ptr offset;
bfd_size_type bytes_to_do;
{
of the register contents section and check that it corresponds to
the length of the section. */
if (z < 32 || z >= 255 || (sec->vma & 7) != 0
- || sec->vma != 256 * 8 - sec->_raw_size - 8)
+ || sec->vma != 256 * 8 - sec->size - 8)
{
bfd_set_error (bfd_error_bad_value);
- if (sec->_raw_size == 0)
+ if (sec->size == 0)
/* There must always be at least one such register. */
(*_bfd_error_handler)
(_("%s: no initialized registers; section length 0\n"),
(*_bfd_error_handler)
(_("%s: too many initialized registers; section length %ld\n"),
bfd_get_filename (abfd),
- (long) sec->_raw_size);
+ (long) sec->size);
else
(*_bfd_error_handler)
(_("%s: invalid start address for initialized registers of\
length %ld: 0x%lx%08lx\n"),
bfd_get_filename (abfd),
- (long) sec->_raw_size,
+ (long) sec->size,
(unsigned long) (sec->vma >> 32), (unsigned long) (sec->vma));
return FALSE;
/* Perhaps we need to adjust this one; mmo labels (originally) without a
leading ':' might more appropriately be called local. */
#define mmo_bfd_is_local_label_name bfd_generic_is_local_label_name
+#define mmo_bfd_is_target_special_symbol \
+ ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
/* Is this one really used or defined by anyone? */
#define mmo_get_lineno _bfd_nosymbols_get_lineno
#define mmo_set_arch_mach bfd_default_set_arch_mach
#define mmo_bfd_relax_section bfd_generic_relax_section
#define mmo_bfd_merge_sections bfd_generic_merge_sections
+#define mmo_bfd_is_group_section bfd_generic_is_group_section
#define mmo_bfd_discard_group bfd_generic_discard_group
+#define mmo_section_already_linked \
+ _bfd_generic_section_already_linked
/* objcopy will be upset if we return -1 from bfd_get_reloc_upper_bound by
using BFD_JUMP_TABLE_RELOCS (_bfd_norelocs) rather than 0. FIXME: Most
#define mmo_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define mmo_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
#define mmo_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#define mmo_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define mmo_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
#define mmo_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data