From 7b02b4ed6f80ce65db81a8e47212f4fb56ef478e Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Tue, 15 Oct 1991 23:41:17 +0000 Subject: [PATCH] * hosts/h-amix.h (free): Fix prototype. * aoutx.h: Don't use NULL as an integer, for braindead systems that declare it as (void *)0. (From Peter Schauer.) --- bfd/ChangeLog | 9 ++++ bfd/aoutx.h | 115 ++++++++++++++++++++++++++++---------------------- 2 files changed, 74 insertions(+), 50 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e0e83c49939..5546b618ea4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,14 @@ +Tue Oct 15 08:29:03 1991 John Gilmore (gnu at cygnus.com) + + * hosts/h-amix.h (free): Fix prototype. + + * aoutx.h: Don't use NULL as an integer, for braindead systems + that declare it as (void *)0. (From Peter Schauer.) + Mon Oct 14 17:20:47 1991 Per Bothner (bothner at cygnus.com) + * opncls.c (bfd_fdopenr): Add parentheses to avoid reported + problem with bad Ultrix system headers. * aoutx.h (NAME(aout,set_section_contents)): Try to handle the various kinds of alignments for the various kinds of magic numbers. diff --git a/bfd/aoutx.h b/bfd/aoutx.h index f3d507c77af..ae53c8d3651 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -32,8 +32,9 @@ functions support for sun3, sun4, 386 and 29k a.out files, to create a 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 @@ -263,36 +264,23 @@ function just before returning, to handle any last-minute setup. */ 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; @@ -319,6 +307,9 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, callback_to_real_object_p), /* 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; @@ -336,17 +327,12 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, callback_to_real_object_p), 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 @@ -395,6 +381,10 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, callback_to_real_object_p), 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, @@ -577,6 +567,10 @@ boolean 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) @@ -595,17 +589,43 @@ boolean 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); } } @@ -983,7 +1003,6 @@ DEFUN(NAME(aout,write_syms),(abfd), 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); @@ -1005,18 +1024,14 @@ DEFUN(NAME(aout,write_syms),(abfd), 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); @@ -1669,7 +1684,7 @@ DEFUN(NAME(aout,find_nearest_line),(abfd, 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; -- 2.30.2