target jump vector for a specific target.
This information is further split out into more specific files for each
-machine, including @code{sunos.c} - for sun3 and sun4 and
-@code{demo64} for a demonstration of a 64 bit a.out format.
+machine, including @code{sunos.c} for sun3 and sun4, @code{newsos3.c} for
+the Sony NEWS, and @code{demo64.c} for a demonstration of a 64 bit a.out
+format.
The base file @code{aoutx.h} defines general mechanisms for reading
and writing records to and from disk, and various other methods which
*/
bfd_target *
-DEFUN(NAME(aout,some_aout_object_p),(abfd, callback_to_real_object_p),
+DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p),
bfd *abfd AND
+ struct internal_exec *execp AND
bfd_target *(*callback_to_real_object_p) ())
{
- struct external_exec exec_bytes;
- struct internal_exec *execp;
struct container *rawptr;
- if (bfd_seek (abfd, 0L, false) < 0) {
- bfd_error = system_call_error;
- return 0;
- }
-
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- bfd_error = wrong_format;
- return 0;
- }
-
- /* Use an intermediate variable for clarity */
rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container));
-
if (rawptr == NULL) {
bfd_error = no_memory;
return 0;
}
- set_tdata (abfd, rawptr);
- exec_hdr (abfd) = execp = &(rawptr->e);
- NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, execp);
+ set_tdata (abfd, &rawptr->a);
+ exec_hdr (abfd) = &rawptr->e;
+ *exec_hdr (abfd) = *execp; /* Copy in the internal_exec struct */
+ execp = exec_hdr (abfd); /* Switch to using the newly malloc'd one */
/* Set the file flags */
abfd->flags = NO_FLAGS;
/* The default relocation entry size is that of traditional V7 Unix. */
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ /* The default symbol entry size is that of traditional Unix. */
+ obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
+
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
obj_textsec (abfd) = (asection *)NULL;
obj_bsssec (abfd)->size = execp->a_bss;
obj_textsec (abfd)->size = execp->a_text;
- if (abfd->flags & D_PAGED) {
- obj_textsec (abfd)->size -= EXEC_BYTES_SIZE;
- }
-
-
obj_textsec (abfd)->flags = (execp->a_trsize != 0 ?
- (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
- (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
+ (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
obj_datasec (abfd)->flags = (execp->a_drsize != 0 ?
- (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
- (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
+ (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
obj_bsssec (abfd)->flags = SEC_ALLOC;
#ifdef THIS_IS_ONLY_DOCUMENTATION
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
}
+ adata(abfd)->page_size = PAGE_SIZE;
+ adata(abfd)->segment_size = SEGMENT_SIZE;
+ adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
+
return abfd->xvec;
/* The architecture is encoded in various ways in various a.out variants,
file_ptr offset AND
bfd_size_type count)
{
+ file_ptr text_end;
+ bfd_size_type text_header_size; /* exec_bytes_size if if included in
+ text size. */
+ bfd_size_type text_size;
if (abfd->output_has_begun == false)
{ /* set by bfd.c handler */
switch (abfd->direction)
bfd_error = invalid_operation;
return false;
}
- /*if (abfd->flags & D_PAGED) {
- obj_textsec(abfd)->filepos = 0;
+ obj_textsec(abfd)->size =
+ align_power(obj_textsec(abfd)->size,
+ obj_textsec(abfd)->alignment_power);
+ 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 (PAGE_SIZE). However, newer
+ * versions of SUNOS start the text segment right after the
+ * exec header; the latter is counted in the text segment size,
+ * and is paged in by the kernel with the rest of the text. */
+ if (!(abfd->flags & D_PAGED))
+ { /* Not demand-paged. */
+ obj_textsec(abfd)->filepos = adata(abfd)->exec_bytes_size;
+ }
+ else if (obj_textsec(abfd)->vma % adata(abfd)->page_size
+ < adata(abfd)->exec_bytes_size)
+ { /* Old-style demand-paged. */
+ obj_textsec(abfd)->filepos = adata(abfd)->page_size;
+ }
+ else
+ { /* Sunos-style demand-paged. */
+ obj_textsec(abfd)->filepos = adata(abfd)->exec_bytes_size;
+ text_size += adata(abfd)->exec_bytes_size;
+ }
+ text_end = obj_textsec(abfd)->size + obj_textsec(abfd)->filepos;
+ if (abfd->flags & (D_PAGED|WP_TEXT))
+ {
+ bfd_size_type text_pad =
+ ALIGN(text_size, adata(abfd)->segment_size) - text_size;
+ text_end += text_pad;
+ obj_textsec(abfd)->size += text_pad;
}
- else*/ {
- obj_textsec(abfd)->filepos = EXEC_BYTES_SIZE;
- }
- obj_textsec(abfd)->size = align_power(obj_textsec(abfd)->size,
- obj_textsec(abfd)->alignment_power);
- obj_datasec(abfd)->filepos = obj_textsec (abfd)->size + EXEC_BYTES_SIZE;
- obj_datasec(abfd)->size = align_power(obj_datasec(abfd)->size,
- obj_datasec(abfd)->alignment_power);
+ obj_datasec(abfd)->filepos = text_end;
+ obj_datasec(abfd)->size =
+ align_power(obj_datasec(abfd)->size,
+ obj_datasec(abfd)->alignment_power);
}
}
asymbol *g = generic[count];
struct external_nlist nsp;
-
if (g->name) {
unsigned int length = strlen(g->name) +1;
PUT_WORD (abfd, stindex, (unsigned char *)nsp.e_strx);
bfd_h_put_8(abfd, 0, nsp.e_other);
bfd_h_put_8(abfd, 0, nsp.e_type);
}
-
-
-
+
translate_to_native_sym_flags (&nsp, g, abfd);
-
- bfd_write((PTR)&nsp,1,EXTERNAL_LIST_SIZE, abfd);
+
+ bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd);
}
-
/* Now output the strings. Be sure to put string length into correct
- * byte ordering before writing it.
- */
+ byte ordering before writing it. */
{
char buffer[BYTES_IN_WORD];
PUT_WORD (abfd, stindex, (unsigned char *)buffer);
buffer[sizeof(buffer)-1] = 0;
/* Have to remove : stuff */
p = strchr(buffer,':');
- if (p != NULL) { *p = NULL; }
+ if (p != NULL) { *p = '\0'; }
*functionname_ptr = buffer;
return true;