#define N_SET_FLAGS(execp, flags) do { } while (0)
#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
&& N_MAGIC(x) != NMAGIC \
+ && N_MAGIC(x) != IMAGIC \
&& N_MAGIC(x) != ZMAGIC)
#include "sysdep.h"
#define A_MAGIC2 NMAGIC
#define NMAGIC 0410 /* Pure executable. */
#define ZMAGIC 0413 /* Demand-paged executable. */
-#define A_MAGIC3 0411 /* Separated I&D. */
+#define IMAGIC 0411 /* Separated I&D. */
+#define A_MAGIC3 IMAGIC
#define A_MAGIC4 0405 /* Overlay. */
#define A_MAGIC5 0430 /* Auto-overlay (nonseparate). */
#define A_MAGIC6 0431 /* Auto-overlay (separate). */
#undef N_REG
#undef N_FN
#undef N_EXT
+#undef N_STAB
#define N_TYPE 0x1f /* Type mask. */
#define N_UNDF 0x00 /* Undefined. */
#define N_ABS 0x01 /* Absolute. */
#define N_REG 0x14 /* Register symbol. */
#define N_FN 0x1f /* File name. */
#define N_EXT 0x20 /* External flag. */
+#define N_STAB 0xc0 /* Not relevant; modified aout64.h's 0xe0 to avoid N_EXT. */
#define RELOC_SIZE 2
struct external_nlist *output_syms;
};
+/* Copy of the link_info.separate_code boolean to select the output format with
+ separate instruction and data spaces selected by --imagic */
+static bfd_boolean separate_i_d = FALSE;
+
reloc_howto_type howto_table_pdp11[] =
{
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
environment's "finish up" function just before returning, to
handle any last-minute setup. */
-const bfd_target *
+bfd_cleanup
NAME (aout, some_aout_object_p) (bfd *abfd,
struct internal_exec *execp,
- const bfd_target *(*callback_to_real_object_p) (bfd *))
+ bfd_cleanup (*callback_to_real_object_p) (bfd *))
{
struct aout_data_struct *rawptr, *oldrawptr;
- const bfd_target *result;
+ bfd_cleanup cleanup;
size_t amt = sizeof (struct aout_data_struct);
rawptr = bfd_zalloc (abfd, amt);
}
else if (N_MAGIC (execp) == OMAGIC)
adata (abfd).magic = o_magic;
+ else if (N_MAGIC (execp) == IMAGIC)
+ adata (abfd).magic = i_magic;
else
{
/* Should have been checked with N_BADMAG before this routine
adata(abfd)->segment_size = SEGMENT_SIZE;
adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
- return abfd->xvec;
+ return _bfd_no_cleanup;
/* The architecture is encoded in various ways in various a.out variants,
or is not encoded at all in some of them. The relocation size depends
header, should cope with them in this callback as well. */
#endif /* DOCUMENTATION */
- result = (*callback_to_real_object_p)(abfd);
+ cleanup = (*callback_to_real_object_p)(abfd);
/* Now that the segment addresses have been worked out, take a better
guess at whether the file is executable. If the entry point
}
#endif /* STAT_FOR_EXEC */
- if (!result)
+ if (!cleanup)
{
free (rawptr);
abfd->tdata.aout_data = oldrawptr;
}
- return result;
+ return cleanup;
}
/* Initialize ABFD for use with a.out files. */
vma += pad;
bss->vma = vma;
}
- else
+ else if (data->size > 0 || bss->size > 0) /* PR25677: for objcopy --extract-symbol */
{
/* The VMA of the .bss section is set by the VMA of the
.data section plus the size of the .data section. We may
N_SET_MAGIC (execp, NMAGIC);
}
+static void
+adjust_i_magic (bfd *abfd, struct internal_exec *execp)
+{
+ file_ptr pos = adata (abfd).exec_bytes_size;
+ bfd_vma vma = 0;
+ int pad;
+ asection *text = obj_textsec (abfd);
+ asection *data = obj_datasec (abfd);
+ asection *bss = obj_bsssec (abfd);
+
+ /* Text. */
+ text->filepos = pos;
+ if (!text->user_set_vma)
+ text->vma = vma;
+ else
+ vma = text->vma;
+ pos += execp->a_text;
+
+ /* Data. */
+ data->filepos = pos;
+ if (!data->user_set_vma)
+ data->vma = 0;
+ vma = data->vma;
+
+ /* Since BSS follows data immediately, see if it needs alignment. */
+ vma += data->size;
+ pad = align_power (vma, bss->alignment_power) - vma;
+ execp->a_data = data->size + pad;
+ pos += execp->a_data;
+
+ /* BSS. */
+ if (!bss->user_set_vma)
+ bss->vma = vma;
+ else
+ vma = bss->vma;
+
+ /* Fix up exec header. */
+ execp->a_bss = bss->size;
+ N_SET_MAGIC (execp, IMAGIC);
+}
+
bfd_boolean
NAME (aout, adjust_sizes_and_vmas) (bfd *abfd)
{
I understand it better now, but I haven't time to do the cleanup this
minute. */
- if (abfd->flags & WP_TEXT)
+ if (separate_i_d)
+ adata (abfd).magic = i_magic;
+ else if (abfd->flags & WP_TEXT)
adata (abfd).magic = n_magic;
else
adata (abfd).magic = o_magic;
{
case n_magic: str = "NMAGIC"; break;
case o_magic: str = "OMAGIC"; break;
+ case i_magic: str = "IMAGIC"; break;
case z_magic: str = "ZMAGIC"; break;
default: abort ();
}
case n_magic:
adjust_n_magic (abfd, execp);
break;
+ case i_magic:
+ adjust_i_magic (abfd, execp);
+ break;
default:
abort ();
}
else
return FALSE;
- in->symbol.value = GET_SWORD (abfd, ext->e_value);
+ in->symbol.value = GET_WORD (abfd, ext->e_value);
/* TODO: is 0 a safe value here? */
in->desc = 0;
in->other = 0;
return TRUE;
-error_return:
+ error_return:
_bfd_stringtab_free (strtab);
return FALSE;
}
size_t filelen, funclen;
char *buf;
- *filename_ptr = abfd->filename;
+ *filename_ptr = bfd_get_filename (abfd);
*functionname_ptr = 0;
*line_ptr = 0;
if (discriminator_ptr)
if (bfd_link_pic (info))
abfd->flags |= DYNAMIC;
+ separate_i_d = info->separate_code;
aout_info.info = info;
aout_info.output_bfd = abfd;
aout_info.contents = NULL;
discarding such symbols. */
if (strip != strip_all
&& (strip != strip_some
- || bfd_hash_lookup (flaginfo->info->keep_hash, input_bfd->filename,
+ || bfd_hash_lookup (flaginfo->info->keep_hash,
+ bfd_get_filename (input_bfd),
FALSE, FALSE) != NULL)
&& discard != discard_all)
{
H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
- input_bfd->filename, FALSE);
+ bfd_get_filename (input_bfd), FALSE);
if (strtab_index == (bfd_size_type) -1)
return FALSE;
PUT_WORD (output_bfd, strtab_index, outsym->e_strx);