Linker now works for go32; other changes keep it from breaking the other

platforms (new backend_data "exec_header_not_counted") (from p3.)
This commit is contained in:
Mark Eichin 1992-10-09 02:41:30 +00:00
parent 23ab00aadf
commit 7f90aa8b18
5 changed files with 70 additions and 132 deletions

View File

@ -1,3 +1,20 @@
Thu Oct 8 22:18:10 1992 Mark Eichin (eichin at tweedledumber.cygnus.com)
* libaout.h (aout_backend_data): added exec_header_not_counted
field. For ZMAGIC files only, when text_includes_header is set, by
default the length of the exec header is counted in the text
section size. For go32, exec header is mapped in but does *not*
contribute to the size of section.
* aoutx.h (aout_adjust_sizes_and_vmas): if exec_header_not_counted
is not set, but ztih is, add the size of the exec header to the
recorded size of the text section.
* aoutf1.h (sunos4_aout_backend): clear exec_header_not_counted.
* i386aout.c (i386aout_backend_data): set exec_header_not_counted.
Also set text_includes_header.
* aout-target.h (*_backend_data): cleare exec_header_not_counted
by default in MY(backend_data).
Thu Oct 8 18:12:49 1992 Ken Raeburn (raeburn@cygnus.com)
* aout-target.h (callback): Don't define this function if it won't be

View File

@ -574,7 +574,7 @@ DEFUN (sunos4_set_sizes, (abfd),
}
static CONST struct aout_backend_data sunos4_aout_backend = {
0, 1, 0, sunos4_set_sizes,
0, 1, 0, sunos4_set_sizes, 0,
};
#define MY_core_file_failing_command sunos4_core_file_failing_command

View File

@ -791,7 +791,7 @@ DEFUN (NAME (aout,adjust_sizes_and_vmas), (abfd, text_size, text_end),
/* Fix up exec header while we're at it. */
execp->a_text = obj_textsec(abfd)->_raw_size;
if (ztih)
if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
execp->a_text += adata(abfd).exec_bytes_size;
N_SET_MAGIC (*execp, ZMAGIC);
/* Spec says data section should be rounded up to page boundary. */

View File

@ -17,135 +17,48 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define PAGE_SIZE 4096
#define SEGMENT_SIZE PAGE_SIZE
#define TEXT_START_ADDR 0x8000
#define ARCH 32
/* The only 386 aout system we have here is GO32 from DJ.
These numbers make BFD work with that. If your aout 386 system
doesn't work with these, we'll have to split them into different
files. Send me (sac@cygnus.com) the runes to make it work on your
system, and I'll stick it in for the next release.
*/
#define TARGET_IS_LITTLE_ENDIAN_P
#define N_HEADER_IN_TEXT(x) 0
#define BYTES_IN_WORD 4
#define ARCH 32
#define N_TXTOFF(x) 0x20
#define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
#define N_TXTSIZE(x) ((x).a_text)
#if 0
#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
#define NOSUBEXECB
#endif
#define PAGE_SIZE 4096
#define SEGMENT_SIZE 0x400000
#define DEFAULT_ARCH bfd_arch_i386
#define MY(OP) CAT(i386aout_,OP)
#define TARGETNAME "a.out-i386"
#define NO_WRITE_HEADER_KLUDGE 1
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "aout64.h"
#include "stab.gnu.h"
#include "ar.h"
#include "libaout.h" /* BFD a.out internal data structures */
bfd_target *aout386_callback ();
bfd_target *
DEFUN(aout386_object_p,(abfd),
bfd *abfd)
{
struct external_exec exec_bytes;
struct internal_exec exec;
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE) {
bfd_error = wrong_format;
return 0;
}
exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
if (N_BADMAG (exec)) return 0;
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
return aout_32_some_aout_object_p (abfd, &exec, aout386_callback);
}
/* Finish up the reading of the file header */
bfd_target *
DEFUN(aout386_callback,(abfd),
bfd *abfd)
{
struct internal_exec *execp = exec_hdr (abfd);
WORK_OUT_FILE_POSITIONS(abfd, execp) ;
/* Determine the architecture and machine type of the object file. */
bfd_default_set_arch_mach(abfd, bfd_arch_i386, 0);
return abfd->xvec;
}
/* Write an object file.
Section contents have already been written. We write the
file header, symbols, and relocation. */
boolean
DEFUN(aout386_write_object_contents,(abfd),
bfd *abfd)
{
bfd_size_type data_pad = 0;
struct external_exec exec_bytes;
struct internal_exec *execp = exec_hdr (abfd);
WRITE_HEADERS(abfd, execp);
return true;
}
/* Transfer vector */
/* We use BSD archive files. */
#define aout386_openr_next_archived_file bfd_generic_openr_next_archived_file
#define aout386_generic_stat_arch_elt bfd_generic_stat_arch_elt
#define aout386_slurp_armap bfd_slurp_bsd_armap
#define aout386_slurp_extended_name_table bfd_true
#define aout386_write_armap bsd_write_armap
#define aout386_truncate_arname bfd_bsd_truncate_arname
/* We don't support core files here. */
#define aout386_core_file_failing_command _bfd_dummy_core_file_failing_command
#define aout386_core_file_failing_signal _bfd_dummy_core_file_failing_signal
#define aout386_core_file_matches_executable_p \
_bfd_dummy_core_file_matches_executable_p
#define aout386_core_file_p _bfd_dummy_target
#define aout386_bfd_debug_info_start bfd_void
#define aout386_bfd_debug_info_end bfd_void
#define aout386_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
#define aout386_mkobject aout_32_mkobject
#define aout386_close_and_cleanup aout_32_close_and_cleanup
#define aout386_set_section_contents aout_32_set_section_contents
#define aout386_get_section_contents aout_32_get_section_contents
#define aout386_new_section_hook aout_32_new_section_hook
#define aout386_get_symtab_upper_bound aout_32_get_symtab_upper_bound
#define aout386_get_symtab aout_32_get_symtab
#define aout386_get_reloc_upper_bound aout_32_get_reloc_upper_bound
#define aout386_canonicalize_reloc aout_32_canonicalize_reloc
#define aout386_make_empty_symbol aout_32_make_empty_symbol
#define aout386_print_symbol aout_32_print_symbol
#define aout386_get_lineno aout_32_get_lineno
#define aout386_set_arch_mach aout_32_set_arch_mach
#define aout386_find_nearest_line aout_32_find_nearest_line
#define aout386_sizeof_headers aout_32_sizeof_headers
bfd_target i386aout_vec = /* Intel 386 running a.out, embedded. */
{
"a.out-i386", /* name */
bfd_target_aout_flavour,
false, /* target byte order */
false, /* target headers byte order */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
1, /* minimum alignment */
/* data swap routines */
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
/* header swap routines */
_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
{_bfd_dummy_target, aout386_object_p, /* bfd_check_format */
bfd_generic_archive_p, aout386_core_file_p},
{bfd_false, aout386_mkobject, /* bfd_set_format */
_bfd_generic_mkarchive, bfd_false},
{bfd_false, aout386_write_object_contents, /* bfd_write_contents */
_bfd_write_archive_contents, bfd_false},
JUMP_TABLE(aout386)
#include "libaout.h"
static boolean MY(set_sizes)();
#define MY_backend_data &MY(backend_data)
static CONST struct aout_backend_data MY(backend_data) = {
0, /* zmagic contiguous */
1, /* text incl header */
0, /* text vma? */
MY(set_sizes),
1, /* exec header not counted */
};
#include "aout-target.h"

View File

@ -22,8 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
variants in a few routines, and otherwise share large masses of code.
This means we only have to fix bugs in one place, most of the time. */
/* $Id$ */
#ifdef __STDC__
#define CAT3(a,b,c) a##b##c
#else
@ -59,11 +57,11 @@ struct aout_backend_data
/* Are ZMAGIC files mapped contiguously? If so, the text section may
need more padding, if the segment size (granularity for memory access
control) is larger than the page size. */
unsigned char zmagic_mapped_contiguous : 1;
unsigned char zmagic_mapped_contiguous;
/* If this flag is set, ZMAGIC/NMAGIC file headers get mapped in with the
text section, which starts immediately after the file header.
If not, the text section starts on the next page. */
unsigned char text_includes_header : 1;
unsigned char text_includes_header;
/* If the text section VMA isn't specified, and we need an absolute
address, use this as the default. If we're producing a relocatable
@ -72,6 +70,15 @@ struct aout_backend_data
reasonable for a format that handles multiple CPUs with different
load addresses for each? */
bfd_vma default_text_vma;
/* Callback for setting the page and segment sizes, if they can't be
trivially determined from the architecture. */
boolean (*set_sizes) PARAMS ((bfd *));
/* zmagic files only. For go32, the length of the exec header contributes
to the size of the text section in the file for alignment purposes but
does *not* get counted in the length of the text section. */
unsigned char exec_header_not_counted;
};
#define aout_backend_info(abfd) \
((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
@ -98,6 +105,7 @@ struct internal_exec
unsigned char a_talign; /* Alignment of text segment */
unsigned char a_dalign; /* Alignment of data segment */
unsigned char a_balign; /* Alignment of bss segment */
char a_relaxable; /* Enough info for linker relax */
};
/* Magic number is written