/* BFD back-end for PDP-11 a.out binaries.
- Copyright 2001, 2002 Free Software Foundation, Inc.
+ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
static bfd_boolean MY(write_object_contents) PARAMS ((bfd *abfd));
#define MY_text_includes_header 1
-bfd_vma bfd_getp32 PARAMS ((const bfd_byte *));
-bfd_signed_vma bfd_getp_signed_32 PARAMS ((const bfd_byte *));
-void bfd_putp32 PARAMS ((bfd_vma, bfd_byte *));
+static bfd_vma bfd_getp32 (const void *);
+static bfd_signed_vma bfd_getp_signed_32 (const void *);
+static void bfd_putp32 (bfd_vma, void *);
#define MY_BFD_TARGET
if (! NAME(aout,make_sections) (abfd))
return NULL;
- obj_datasec (abfd)->_raw_size = execp->a_data;
- obj_bsssec (abfd)->_raw_size = execp->a_bss;
+ obj_datasec (abfd)->size = execp->a_data;
+ obj_bsssec (abfd)->size = execp->a_bss;
obj_textsec (abfd)->flags =
(execp->a_trsize != 0
struct exec *execp = exec_hdr (abfd);
obj_textsec (abfd)->size = N_TXTSIZE(*execp);
- obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp);
/* data and bss are already filled in since they're so standard */
/* The virtual memory addresses of the sections */
if (execp->a_entry != 0
|| (execp->a_entry >= obj_textsec(abfd)->vma
- && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
+ && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->size))
abfd->flags |= EXEC_P;
#ifdef STAT_FOR_EXEC
else
else
vma = obj_textsec (abfd)->vma;
- pos += obj_textsec (abfd)->_raw_size;
- vma += obj_textsec (abfd)->_raw_size;
+ pos += obj_textsec (abfd)->size;
+ vma += obj_textsec (abfd)->size;
/* Data. */
if (!obj_datasec (abfd)->user_set_vma)
#if 0 /* ?? Does alignment in the file image really matter? */
pad = align_power (vma, obj_datasec (abfd)->alignment_power) - vma;
#endif
- obj_textsec (abfd)->_raw_size += pad;
+ obj_textsec (abfd)->size += pad;
pos += pad;
vma += pad;
obj_datasec (abfd)->vma = vma;
else
vma = obj_datasec (abfd)->vma;
obj_datasec (abfd)->filepos = pos;
- pos += obj_datasec (abfd)->_raw_size;
- vma += obj_datasec (abfd)->_raw_size;
+ pos += obj_datasec (abfd)->size;
+ vma += obj_datasec (abfd)->size;
/* BSS. */
if (! obj_bsssec (abfd)->user_set_vma)
#if 0
pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma;
#endif
- obj_datasec (abfd)->_raw_size += pad;
+ obj_datasec (abfd)->size += pad;
pos += pad;
vma += pad;
obj_bsssec (abfd)->vma = vma;
pad = obj_bsssec (abfd)->vma - vma;
if (pad > 0)
{
- obj_datasec (abfd)->_raw_size += pad;
+ obj_datasec (abfd)->size += pad;
pos += pad;
}
}
obj_bsssec (abfd)->filepos = pos;
/* Fix up the exec header. */
- execp->a_text = obj_textsec (abfd)->_raw_size;
- execp->a_data = obj_datasec (abfd)->_raw_size;
- execp->a_bss = obj_bsssec (abfd)->_raw_size;
+ execp->a_text = obj_textsec (abfd)->size;
+ execp->a_data = obj_datasec (abfd)->size;
+ execp->a_bss = obj_bsssec (abfd)->size;
N_SET_MAGIC (*execp, OMAGIC);
}
/* Find start of data. */
if (ztih)
{
- text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size;
+ text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->size;
text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
}
else
/* Note that if page_size == zmagic_disk_block_size, then
filepos == page_size, and this case is the same as the ztih
case. */
- text_end = obj_textsec (abfd)->_raw_size;
+ text_end = obj_textsec (abfd)->size;
text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
text_end += obj_textsec (abfd)->filepos;
}
- obj_textsec (abfd)->_raw_size += text_pad;
+ obj_textsec (abfd)->size += text_pad;
text_end += text_pad;
/* Data. */
if (!obj_datasec(abfd)->user_set_vma)
{
bfd_vma vma;
- vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size;
+ vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->size;
obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
}
if (abdp && abdp->zmagic_mapped_contiguous)
{
text_pad = (obj_datasec(abfd)->vma
- obj_textsec(abfd)->vma
- - obj_textsec(abfd)->_raw_size);
- obj_textsec(abfd)->_raw_size += text_pad;
+ - obj_textsec(abfd)->size);
+ obj_textsec(abfd)->size += text_pad;
}
obj_datasec (abfd)->filepos = (obj_textsec (abfd)->filepos
- + obj_textsec (abfd)->_raw_size);
+ + obj_textsec (abfd)->size);
/* Fix up exec header while we're at it. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
+ execp->a_text = obj_textsec(abfd)->size;
if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
execp->a_text += adata(abfd).exec_bytes_size;
if (obj_aout_subformat (abfd) == q_magic_format)
N_SET_MAGIC (*execp, ZMAGIC);
/* Spec says data section should be rounded up to page boundary. */
- obj_datasec(abfd)->_raw_size
- = align_power (obj_datasec(abfd)->_raw_size,
+ obj_datasec(abfd)->size
+ = align_power (obj_datasec(abfd)->size,
obj_bsssec(abfd)->alignment_power);
- execp->a_data = BFD_ALIGN (obj_datasec(abfd)->_raw_size,
+ execp->a_data = BFD_ALIGN (obj_datasec(abfd)->size,
adata(abfd).page_size);
- data_pad = execp->a_data - obj_datasec(abfd)->_raw_size;
+ data_pad = execp->a_data - obj_datasec(abfd)->size;
/* BSS. */
if (!obj_bsssec(abfd)->user_set_vma)
obj_bsssec(abfd)->vma = (obj_datasec(abfd)->vma
- + obj_datasec(abfd)->_raw_size);
+ + obj_datasec(abfd)->size);
/* If the BSS immediately follows the data section and extra space
in the page is left after the data section, fudge data
in the header so that the bss section looks smaller by that
could have explicitly set the BSS vma to immediately follow
the data section.) */
if (align_power (obj_bsssec(abfd)->vma, obj_bsssec(abfd)->alignment_power)
- == obj_datasec(abfd)->vma + obj_datasec(abfd)->_raw_size)
- execp->a_bss = (data_pad > obj_bsssec(abfd)->_raw_size) ? 0 :
- obj_bsssec(abfd)->_raw_size - data_pad;
+ == obj_datasec(abfd)->vma + obj_datasec(abfd)->size)
+ execp->a_bss = (data_pad > obj_bsssec(abfd)->size) ? 0 :
+ obj_bsssec(abfd)->size - data_pad;
else
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
+ execp->a_bss = obj_bsssec(abfd)->size;
}
static void
obj_textsec(abfd)->vma = vma;
else
vma = obj_textsec(abfd)->vma;
- pos += obj_textsec(abfd)->_raw_size;
- vma += obj_textsec(abfd)->_raw_size;
+ pos += obj_textsec(abfd)->size;
+ vma += obj_textsec(abfd)->size;
/* Data. */
obj_datasec(abfd)->filepos = pos;
vma = obj_datasec(abfd)->vma;
/* Since BSS follows data immediately, see if it needs alignment. */
- vma += obj_datasec(abfd)->_raw_size;
+ vma += obj_datasec(abfd)->size;
pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
- obj_datasec(abfd)->_raw_size += pad;
- pos += obj_datasec(abfd)->_raw_size;
+ obj_datasec(abfd)->size += pad;
+ pos += obj_datasec(abfd)->size;
/* BSS. */
if (!obj_bsssec(abfd)->user_set_vma)
vma = obj_bsssec(abfd)->vma;
/* Fix up exec header. */
- execp->a_text = obj_textsec(abfd)->_raw_size;
- execp->a_data = obj_datasec(abfd)->_raw_size;
- execp->a_bss = obj_bsssec(abfd)->_raw_size;
+ execp->a_text = obj_textsec(abfd)->size;
+ execp->a_data = obj_datasec(abfd)->size;
+ execp->a_bss = obj_bsssec(abfd)->size;
N_SET_MAGIC (*execp, NMAGIC);
}
if (adata(abfd).magic != undecided_magic)
return TRUE;
- obj_textsec(abfd)->_raw_size =
- align_power(obj_textsec(abfd)->_raw_size,
+ obj_textsec(abfd)->size =
+ align_power(obj_textsec(abfd)->size,
obj_textsec(abfd)->alignment_power);
- *text_size = obj_textsec (abfd)->_raw_size;
+ *text_size = obj_textsec (abfd)->size;
/* Rule (heuristic) for when to pad to a new page. Note that there
are (at least) two ways demand-paged (ZMAGIC) files have been
handled. Most Berkeley-based systems start the text segment at
}
str;
}),
- obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
+ obj_textsec(abfd)->vma, obj_textsec(abfd)->size,
obj_textsec(abfd)->alignment_power,
- obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
+ obj_datasec(abfd)->vma, obj_datasec(abfd)->size,
obj_datasec(abfd)->alignment_power,
- obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size,
+ obj_bsssec(abfd)->vma, obj_bsssec(abfd)->size,
obj_bsssec(abfd)->alignment_power);
#endif
#endif
#ifdef BFD_AOUT_DEBUG
fprintf (stderr, " text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
- obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
+ obj_textsec(abfd)->vma, obj_textsec(abfd)->size,
obj_textsec(abfd)->filepos,
- obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
+ obj_datasec(abfd)->vma, obj_datasec(abfd)->size,
obj_datasec(abfd)->filepos,
- obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size);
+ obj_bsssec(abfd)->vma, obj_bsssec(abfd)->size);
#endif
return TRUE;
NAME(aout,set_section_contents) (abfd, section, location, offset, count)
bfd *abfd;
sec_ptr section;
- PTR location;
+ const PTR location;
file_ptr offset;
bfd_size_type count;
{
\f
long
-NAME(aout,get_symtab) (abfd, location)
+NAME(aout,canonicalize_symtab) (abfd, location)
bfd *abfd;
asymbol **location;
{
return TRUE;
#endif
- natsize = bfd_get_section_size_before_reloc (section);
+ natsize = section->size;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native)
return FALSE;
}
}
-/*ARGSUSED*/
void
NAME(aout,print_symbol) (abfd, afile, symbol, how)
bfd * abfd;
includes_hash_initialized = TRUE;
/* Figure out the largest section size. Also, if generating
- relocateable output, count the relocs. */
+ relocatable output, count the relocs. */
trsize = 0;
drsize = 0;
max_contents_size = 0;
{
size_t sz;
- if (info->relocateable)
+ if (info->relocatable)
{
if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
{
work out the number of relocs needed, and then multiply
by the reloc size. */
(*_bfd_error_handler)
- ("%s: relocateable link from %s to %s not supported",
+ ("%s: relocatable link from %s to %s not supported",
bfd_get_filename (abfd),
sub->xvec->name, abfd->xvec->name);
bfd_set_error (bfd_error_invalid_operation);
if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
{
- sz = bfd_section_size (sub, obj_textsec (sub));
+ sz = obj_textsec (sub)->size;
if (sz > max_contents_size)
max_contents_size = sz;
- sz = bfd_section_size (sub, obj_datasec (sub));
+ sz = obj_datasec (sub)->size;
if (sz > max_contents_size)
max_contents_size = sz;
}
}
- if (info->relocateable)
+ if (info->relocatable)
{
if (obj_textsec (abfd) != (asection *) NULL)
trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
PTR relocs;
/* Get the section contents. */
- input_size = bfd_section_size (input_bfd, input_section);
+ input_size = input_section->size;
if (! bfd_get_section_contents (input_bfd, input_section,
(PTR) finfo->contents,
(file_ptr) 0, input_size))
input_size))
return FALSE;
- /* If we are producing relocateable output, the relocs were
+ /* If we are producing relocatable output, the relocs were
modified, and we now write them out. */
- if (finfo->info->relocateable && rel_size > 0)
+ if (finfo->info->relocatable && rel_size > 0)
{
if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
return FALSE;
struct aout_link_hash_entry *, PTR, bfd_byte *, bfd_boolean *,
bfd_vma *));
bfd *output_bfd;
- bfd_boolean relocateable;
+ bfd_boolean relocatable;
struct external_nlist *syms;
char *strings;
struct aout_link_hash_entry **sym_hashes;
BFD_ASSERT (input_bfd->xvec->header_byteorder
== output_bfd->xvec->header_byteorder);
- relocateable = finfo->info->relocateable;
+ relocatable = finfo->info->relocatable;
syms = obj_aout_external_syms (input_bfd);
strings = obj_aout_external_strings (input_bfd);
sym_hashes = obj_aout_sym_hashes (input_bfd);
howto = howto_table_pdp11 + howto_idx;
}
- if (relocateable)
+ if (relocatable)
{
- /* We are generating a relocateable output file, and must
+ /* We are generating a relocatable output file, and must
modify the reloc accordingly. */
if (r_extern)
{
}
/* end of modified aoutx.h */
-bfd_vma
-bfd_getp32 (addr)
- const bfd_byte *addr;
+static bfd_vma
+bfd_getp32 (const void *p)
{
- return (((((bfd_vma)addr[1] << 8) | addr[0]) << 8)
- | addr[3]) << 8 | addr[2];
+ const bfd_byte *addr = p;
+ unsigned long v;
+ v = (unsigned long) addr[1] << 24;
+ v |= (unsigned long) addr[0] << 16;
+ v |= (unsigned long) addr[3] << 8;
+ v |= (unsigned long) addr[2];
+ return v;
}
#define COERCE32(x) (((bfd_signed_vma) (x) ^ 0x80000000) - 0x80000000)
-bfd_signed_vma
-bfd_getp_signed_32 (addr)
- const bfd_byte *addr;
+static bfd_signed_vma
+bfd_getp_signed_32 (const void *p)
{
- return COERCE32((((((bfd_vma)addr[1] << 8) | addr[0]) << 8)
- | addr[3]) << 8 | addr[2]);
+ const bfd_byte *addr = p;
+ unsigned long v;
+ v = (unsigned long) addr[1] << 24;
+ v |= (unsigned long) addr[0] << 16;
+ v |= (unsigned long) addr[3] << 8;
+ v |= (unsigned long) addr[2];
+ return COERCE32 (v);
}
-void
-bfd_putp32 (data, addr)
- bfd_vma data;
- bfd_byte *addr;
+static void
+bfd_putp32 (bfd_vma data, void *p)
{
- addr[0] = (bfd_byte)(data >> 16);
- addr[1] = (bfd_byte)(data >> 24);
- addr[2] = (bfd_byte)data;
- addr[3] = (bfd_byte)(data >> 8);
+ bfd_byte *addr = p;
+ addr[0] = (data >> 16) & 0xff;
+ addr[1] = (data >> 24) & 0xff;
+ addr[2] = (data >> 0) & 0xff;
+ addr[3] = (data >> 8) & 0xff;
}