xref: /netbsd-src/external/gpl3/binutils.old/dist/bfd/i386aout.c (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* BFD back-end for i386 a.out binaries.
2*e992f068Schristos    Copyright (C) 1990-2022 Free Software Foundation, Inc.
375fd0b74Schristos 
475fd0b74Schristos    This file is part of BFD, the Binary File Descriptor library.
575fd0b74Schristos 
675fd0b74Schristos    This program is free software; you can redistribute it and/or modify
775fd0b74Schristos    it under the terms of the GNU General Public License as published by
875fd0b74Schristos    the Free Software Foundation; either version 3 of the License, or
975fd0b74Schristos    (at your option) any later version.
1075fd0b74Schristos 
1175fd0b74Schristos    This program is distributed in the hope that it will be useful,
1275fd0b74Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1375fd0b74Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1475fd0b74Schristos    GNU General Public License for more details.
1575fd0b74Schristos 
1675fd0b74Schristos    You should have received a copy of the GNU General Public License
1775fd0b74Schristos    along with this program; if not, write to the Free Software
1875fd0b74Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
1975fd0b74Schristos    MA 02110-1301, USA.  */
2075fd0b74Schristos 
2175fd0b74Schristos 
2275fd0b74Schristos /* The only 386 aout system we have here is GO32 from DJ.
2375fd0b74Schristos    These numbers make BFD work with that. If your aout 386 system
2475fd0b74Schristos    doesn't work with these, we'll have to split them into different
2575fd0b74Schristos    files.  Send me (sac@cygnus.com) the runes to make it work on your
2675fd0b74Schristos    system, and I'll stick it in for the next release.  */
2775fd0b74Schristos 
2875fd0b74Schristos #define N_HEADER_IN_TEXT(x)	0
2975fd0b74Schristos #define N_TXTOFF(x)		0x20
3075fd0b74Schristos #define N_TXTADDR(x)		(N_MAGIC (x) == ZMAGIC ? 0x1020 : 0)
3175fd0b74Schristos #define N_TXTSIZE(x)		((x)->a_text)
3275fd0b74Schristos #define TARGET_PAGE_SIZE	4096
3375fd0b74Schristos #define SEGMENT_SIZE		0x400000
3475fd0b74Schristos #define DEFAULT_ARCH		bfd_arch_i386
3575fd0b74Schristos 
3675fd0b74Schristos /* Do not "beautify" the CONCAT* macro args.  Traditional C will not
3775fd0b74Schristos    remove whitespace added here, and thus will fail to concatenate
3875fd0b74Schristos    the tokens.  */
3975fd0b74Schristos #define MY(OP) CONCAT2 (i386_aout_,OP)
4075fd0b74Schristos #define TARGETNAME "a.out-i386"
4175fd0b74Schristos 
4275fd0b74Schristos #include "sysdep.h"
4375fd0b74Schristos #include "bfd.h"
4475fd0b74Schristos #include "libbfd.h"
4575fd0b74Schristos #include "aout/aout64.h"
4675fd0b74Schristos #include "libaout.h"
4775fd0b74Schristos 
4875fd0b74Schristos /* Set the machine type correctly.  */
4975fd0b74Schristos 
50*e992f068Schristos static bool
i386aout_write_object_contents(bfd * abfd)5175fd0b74Schristos i386aout_write_object_contents (bfd *abfd)
5275fd0b74Schristos {
5375fd0b74Schristos   struct external_exec exec_bytes;
5475fd0b74Schristos   struct internal_exec *execp = exec_hdr (abfd);
5575fd0b74Schristos 
5675fd0b74Schristos   N_SET_MACHTYPE (execp, M_386);
5775fd0b74Schristos 
5875fd0b74Schristos   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
5975fd0b74Schristos 
6075fd0b74Schristos   WRITE_HEADERS (abfd, execp);
6175fd0b74Schristos 
62*e992f068Schristos   return true;
6375fd0b74Schristos }
6475fd0b74Schristos 
6575fd0b74Schristos #define MY_write_object_contents  i386aout_write_object_contents
6675fd0b74Schristos #define MY_backend_data		  & MY (backend_data)
6775fd0b74Schristos 
6875fd0b74Schristos static const struct aout_backend_data MY (backend_data);
6975fd0b74Schristos 
7075fd0b74Schristos #include "aout-target.h"
7175fd0b74Schristos 
7275fd0b74Schristos static const struct aout_backend_data MY (backend_data) =
7375fd0b74Schristos {
7475fd0b74Schristos   0,				/* Zmagic contiguous.  */
7575fd0b74Schristos   1,				/* Text incl header.  */
7675fd0b74Schristos   0,				/* Entry is text address.  */
7775fd0b74Schristos   0,				/* Exec_hdr_flags.  */
7875fd0b74Schristos   0,				/* Text vma?  */
7975fd0b74Schristos   MY (set_sizes),
8075fd0b74Schristos   1,				/* Exec header not counted.  */
8175fd0b74Schristos   0,				/* Add_dynamic_symbols.  */
8275fd0b74Schristos   0,				/* Add_one_symbol.  */
8375fd0b74Schristos   0,				/* Link_dynamic_object.  */
8475fd0b74Schristos   0,				/* Write_dynamic_symbol.  */
8575fd0b74Schristos   0,				/* Check_dynamic_reloc.  */
8675fd0b74Schristos   0				/* Finish_dynamic_link.  */
8775fd0b74Schristos };
88