WikiPendium

(beta)

Binutils2161

WikiPendium :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ec2-3-133-109-211.us-east-2.compute.amazonaws.com

Binutils 2.16.1


Dumb try


You need original binutils-2.16.1 archive. The archive decompress to a 95 MB of source directory. You will also need autoconf and automake to rebuild needed Makefile.in and configure scripts.

Note: TARGETPATH is a directory where binutils-mint will be installed. As there is no support for our target, we got an error:

$ tar xvjf binutils-2.16.1.tar.bz2
$ mkdir binutils-2.16.1-mint
$ cd binutils-2.16.1-mint
$ ../binutils-2.16.1/configure --prefix=$TARGETPATH --target=m68k-atari-mint
$ make
*** BFD does not support target m68k-atari-mint.
*** Look in bfd/config.bfd for supported targets.




So we must add BFD support for our target.

BFD library support


There are two things to add to BFD, besides the m68k-atari-mint target: a custom object file (aout-mint), maybe not needed, and the gemdos binar y executable format (prg-mint).

bfd/config.bfd


We add our aout and prg "vectors", and also add elf32 for m68k (if you want to process some ELF files). targ_defvec defines the default vector for our target, targ_selvecs selects available vectors for our target.

diff -Naur binutils-2.16.1/bfd/config.bfd binutils-2.16.1-new/bfd/config.bfd
--- binutils-2.16.1/bfd/config.bfd	2005-01-31 18:18:47.000000000 +0100
+++ binutils-2.16.1-new/bfd/config.bfd	2005-08-09 17:36:17.000000000 +0200
@@ -732,6 +732,11 @@
     targ_defvec=m68klynx_coff_vec
     targ_selvecs=m68klynx_aout_vec
     ;;
+  m68*-*-mint*)
+    targ_defvec=m68kmint_aout_vec
+    targ_selvecs="m68kmint_prg_vec m68kmint_aout_vec bfd_elf32_m68k_vec"
+    targ_underscore=yes
+    ;;
   m68*-hp*-netbsd*)
     targ_defvec=m68k4knetbsd_vec
     targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec"




bfd/configure.in


Here we define which files are needed to build our custom vectors.
Note: when modifying configure.in, you must run autoconf to regenerate the configure script file from configure.in.

diff -Naur binutils-2.16.1/bfd/configure.in binutils-2.16.1-new/bfd/configure.in
--- binutils-2.16.1/bfd/configure.in	2005-06-12 20:58:40.000000000 +0200
+++ binutils-2.16.1-new/bfd/configure.in	2005-08-09 17:36:46.000000000 +0200
@@ -735,6 +735,8 @@
     m68klinux_vec)		tb="$tb m68klinux.lo aout32.lo" ;;
     m68klynx_aout_vec)		tb="$tb m68klynx.lo lynx-core.lo aout32.lo" ;;
     m68klynx_coff_vec)		tb="$tb cf-m68klynx.lo coff-m68k.lo cofflink.lo lynx-core.lo" ;;
+    m68kmint_aout_vec)		tb="$tb aout-mint.lo aout32.lo" ;;
+    m68kmint_prg_vec)		tb="$tb prg-mint.lo aout32.lo" ;;
     m68knetbsd_vec)		tb="$tb m68knetbsd.lo aout32.lo" ;;
     m68ksysvcoff_vec)		tb="$tb coff-svm68k.lo cofflink.lo" ;;
     m88kbcs_vec)		tb="$tb coff-m88k.lo" ;;




bfd/Makefile.am


In BFD32_BACKENDS define, we must add our target .lo, and in BFD32_BACKENDS_CFILES the corresponding .c files:
Note: when modifying a Makefile.am, you must run automake to regenerate the Makefile.in file from Makefile.am.

diff -Naur binutils-2.16.1/bfd/Makefile.am binutils-2.16.1-new/bfd/Makefile.am
--- binutils-2.16.1/bfd/Makefile.am	2005-06-12 20:58:52.000000000 +0200
+++ binutils-2.16.1-new/bfd/Makefile.am	2005-08-09 17:37:44.000000000 +0200
@@ -174,6 +174,7 @@
 	aout-adobe.lo \
 	aout-arm.lo \
 	aout-cris.lo \
+	aout-mint.lo \
 	aout-ns32k.lo \
 	aout-sparcle.lo \
 	aout-tic30.lo \
@@ -319,6 +320,7 @@
 	pei-mips.lo \
 	peigen.lo \
 	ppcboot.lo \
+	prg-mint.lo \
 	reloc16.lo \
 	riscix.lo \
 	sparclinux.lo \
@@ -343,6 +345,7 @@
 	aout-adobe.c \
 	aout-arm.c \
 	aout-cris.c \
+	aout-mint.c \
 	aout-ns32k.c \
 	aout-sparcle.c \
 	aout-tic30.c \
@@ -486,6 +489,7 @@
 	pe-mips.c \
 	pei-mips.c \
 	ppcboot.c \
+	prg-mint.c \
 	reloc16.c \
 	riscix.c \
 	sparclinux.c \




bfd/targets.c


Here we add references to our extra targets.

diff -Naur binutils-2.16.1/bfd/targets.c binutils-2.16.1-new/bfd/targets.c
--- binutils-2.16.1/bfd/targets.c	2005-03-01 02:56:27.000000000 +0100
+++ binutils-2.16.1-new/bfd/targets.c	2005-08-15 14:07:23.000000000 +0200
@@ -689,6 +689,8 @@
 extern const bfd_target m68klinux_vec;
 extern const bfd_target m68klynx_aout_vec;
 extern const bfd_target m68klynx_coff_vec;
+extern const bfd_target m68kmint_aout_vec;
+extern const bfd_target m68kmint_prg_vec;
 extern const bfd_target m68knetbsd_vec;
 extern const bfd_target m68ksysvcoff_vec;
 extern const bfd_target m88kbcs_vec;




bfd/bfd-in.h


Now we add a special routine to BFD library to set program flags (that will be used for prg-mint target).

diff -Naur binutils-2.16.1/bfd/bfd-in.h binutils-2.16.1-new/bfd/bfd-in.h
--- binutils-2.16.1/bfd/bfd-in.h	2005-02-20 15:59:06.000000000 +0100
+++ binutils-2.16.1-new/bfd/bfd-in.h	2005-08-16 11:32:48.000000000 +0200
@@ -706,6 +706,11 @@
 extern bfd_boolean bfd_sunos_size_dynamic_sections
   (bfd *, struct bfd_link_info *, struct bfd_section **, struct bfd_section **, struct bfd_section **);
 
+/* MiNT routine to set the special flags in exec header.  */
+
+extern bfd_boolean bfd_m68kmint_set_extended_flags
+  PARAMS ((bfd *, flagword));
+
 /* Linux shared library support routines for the linker.  */
 
 extern bfd_boolean bfd_i386linux_size_dynamic_sections




bfd/aout-mint.c


Here is the a.out mint .O object file format. As it has nothing particular, I think we could get rid of it, and use something like ELF to store object files.

diff -Naur binutils-2.16.1/bfd/aout-mint.c binutils-2.16.1-new/bfd/aout-mint.c
--- binutils-2.16.1/bfd/aout-mint.c	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.16.1-new/bfd/aout-mint.c	2005-08-15 21:56:22.000000000 +0200
@@ -0,0 +1,80 @@
+/* BFD backend for MiNT flavored aout binaries.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   Written by Guido Flohr (gufl0000 (somewhere at) stud.uni-sb.de).
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#define N_HEADER_IN_TEXT(x) 0
+#define BYTES_IN_WORD 4
+#define ENTRY_CAN_BE_ZERO
+#define N_SHARED_LIB(x) 0 /* Avoids warning */
+#define TEXT_START_ADDR 0
+#define TARGET_PAGE_SIZE 2
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define TARGET_IS_BIG_ENDIAN_P
+#define DEFAULT_ARCH bfd_arch_m68k
+
+#define MY(OP) CONCAT2(m68kmint_aout_,OP)
+#define TARGETNAME "a.out-mint"
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#define MY_BFD_TARGET MY(vec)
+
+#include "aout-target.h"
+
+CONST bfd_target MY(vec) = {
+  TARGETNAME,           /* name */
+  bfd_target_aout_flavour,
+  BFD_ENDIAN_BIG,               /* target byte order (big) */
+  BFD_ENDIAN_BIG,               /* target headers byte order (big) */
+  (HAS_RELOC |                  /* object flags */
+   HAS_LINENO | HAS_DEBUG |
+   HAS_SYMS | HAS_LOCALS | WP_TEXT ),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
+  MY_symbol_leading_char,
+  AR_PAD_CHAR,                  /* ar_pad_char */
+  15,                           /* ar_max_namelen */
+  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+  bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
+  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
+     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
+  bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
+  {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
+   bfd_generic_archive_p, MY_core_file_p},
+  {bfd_false, MY_mkobject,    /* bfd_set_format */
+   _bfd_generic_mkarchive, bfd_false},
+  {bfd_false, MY_write_object_contents, /* bfd_write_contents */
+   _bfd_write_archive_contents, bfd_false},
+
+  BFD_JUMP_TABLE_GENERIC (MY),
+  BFD_JUMP_TABLE_COPY (MY),
+  BFD_JUMP_TABLE_CORE (MY),
+  BFD_JUMP_TABLE_ARCHIVE (MY),
+  BFD_JUMP_TABLE_SYMBOLS (MY),
+  BFD_JUMP_TABLE_RELOCS (MY),
+  BFD_JUMP_TABLE_WRITE (MY),
+  BFD_JUMP_TABLE_LINK (MY),
+  BFD_JUMP_TABLE_DYNAMIC (MY),
+  
+  NULL,
+  (PTR) MY_backend_data,
+};




bfd/prg-mint.c


TODO

GAS assembler support


GAS already has m68k support from other OS.

gas/configure.tgt


It's easy to add m68k-atari-mint target, as an a.out platform:

diff -Naur binutils-2.16.1/gas/configure.tgt binutils-2.16.1-new/gas/configure.tgt
--- binutils-2.16.1/gas/configure.tgt	2005-01-31 18:18:51.000000000 +0100
+++ binutils-2.16.1-new/gas/configure.tgt	2005-08-16 12:04:55.000000000 +0200
@@ -268,6 +268,7 @@
   m68k-*-linux-gnu*)			fmt=elf em=linux ;;
   m68k-*-uclinux*)			fmt=elf ;;
   m68k-*-gnu*)				fmt=elf ;;
+  m68k-*-mint*)				fmt=aout ;;
   m68k-*-netbsdelf*)			fmt=elf em=nbsd ;;
   m68k-*-netbsd*)			fmt=aout em=nbsd bfd_gas=yes ;;
   m68k-*-openbsd*)			fmt=aout em=nbsd bfd_gas=yes ;;




LD linker support


ld/configure.tgt


As for GAS, first, we need to define what our target is. Here I also added support for ELF executable files as extra.

diff -Naur binutils-2.16.1/ld/configure.tgt binutils-2.16.1-new/ld/configure.tgt
--- binutils-2.16.1/ld/configure.tgt	2005-02-08 20:54:27.000000000 +0100
+++ binutils-2.16.1-new/ld/configure.tgt	2005-08-16 17:59:33.000000000 +0200
@@ -378,6 +378,8 @@
 			;;
 m68k-*-uclinux*)	targ_emul=m68kelf ;;
 m68*-*-gnu*)		targ_emul=m68kelf ;;
+m68*-*-mint*)		targ_emul=m68kmint
+            targ_extra_emuls=m68kelf ;;
 m68*-*-netbsd*4k*)	targ_emul=m68k4knbsd
 			targ_extra_emuls="m68knbsd m68kelfnbsd" ;;
 m68*-*-netbsdelf*)	targ_emul=m68kelfnbsd




ld/Makefile.am


LD needs several scripts related to target support.
We need to add em68kmint.o to ALL_EMULATIONS variable, and then define the related scripts to build this target.

diff -Naur binutils-2.16.1/ld/Makefile.am binutils-2.16.1-new/ld/Makefile.am
--- binutils-2.16.1/ld/Makefile.am	2005-01-20 20:37:49.000000000 +0100
+++ binutils-2.16.1-new/ld/Makefile.am	2005-08-16 18:08:12.000000000 +0200
@@ -250,6 +250,7 @@
 	em68kelfnbsd.o \
 	em68klinux.o \
 	em68klynx.o \
+	em68kmint.o \
 	em68knbsd.o \
 	em68kpsos.o \
 	em88kbcs.o \
@@ -1053,6 +1054,9 @@
 em68klynx.c: $(srcdir)/emulparams/m68klynx.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68klynx.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} m68klynx "$(tdir_m68klynx)"
+em68kmint.c: $(srcdir)/emulparams/m68kmint.sh \
+  $(srcdir)/emultempl/mint.em $(srcdir)/scripttempl/m68kmint.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} m68kmint "$(tdir_m68kmint)"
 em68knbsd.c:	$(srcdir)/emulparams/m68knbsd.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} m68knbsd "$(tdir_m68knbsd)"




ld/emultempl/mint.em


Now our custom LD front end to add support for program flags.

diff -Naur binutils-2.16.1/ld/emultempl/mint.em binutils-2.16.1-new/ld/emultempl/mint.em
--- binutils-2.16.1/ld/emultempl/mint.em	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.16.1-new/ld/emultempl/mint.em	2005-08-18 15:32:03.000000000 +0200
@@ -0,0 +1,324 @@
+# This shell script emits a C file. -*- C -*-
+# It does some substitutions.
+cat >e${EMULATION_NAME}.c <<EOF
+/* This file is is generated by a shell script.  DO NOT EDIT! */
+
+/* emulate the original gld for the given ${EMULATION_NAME}
+   Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+   Written by Steve Chamberlain steve@cygnus.com
+
+This file is part of GLD, the Gnu Linker.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#define TARGET_IS_${EMULATION_NAME}
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libiberty.h"
+#include "getopt.h"
+#include "bfdlink.h"
+
+#include "ld.h"
+#include "ldmain.h"
+#include "ldemul.h"
+#include "ldfile.h"
+#include "ldmisc.h"
+#include "ldexp.h"
+#include "ldlang.h"
+#include "ldctor.h"
+#include "ldgram.h"
+
+static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
+static void gld${EMULATION_NAME}_finish PARAMS ((void));
+static int gld${EMULATION_NAME}_parse_args PARAMS ((int, char **));
+static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
+
+/* Standard GEMDOS program flags.  */
+#define _MINT_F_FASTLOAD      0x01    /* Don't clear heap.  */
+#define _MINT_F_ALTLOAD       0x02    /* OK to load in alternate RAM.  */
+#define _MINT_F_ALTALLOC      0x04    /* OK to malloc from alt. RAM.  */
+#define _MINT_F_BESTFIT       0x08    /* Load with optimal heap size.  */
+/* The memory flags are mutually exclusive.  */
+#define _MINT_F_MEMPROTECTION 0xf0    /* Masks out protection bits.  */
+#define _MINT_F_MEMPRIVATE    0x00    /* Memory is private.  */
+#define _MINT_F_MEMGLOBAL     0x10    /* Read/write access to mem allowed.  */
+#define _MINT_F_MEMSUPER      0x20    /* Only supervisor access allowed.  */
+#define _MINT_F_MEMREADABLE   0x30    /* Any read access OK.  */
+#define _MINT_F_SHTEXT        0x800   /* Program's text may be shared */
+
+/* Option flags.  */
+static flagword prg_flags = (_MINT_F_FASTLOAD | _MINT_F_ALTLOAD
+			     | _MINT_F_ALTALLOC | _MINT_F_MEMPRIVATE);
+
+static void
+gld${EMULATION_NAME}_before_parse()
+{
+#ifndef TARGET_			/* I.e., if not generic.  */
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_m68k);
+#endif /* not TARGET_ */
+}
+
+     /* Handle MiNT specific options.  */
+static int
+gld${EMULATION_NAME}_parse_args (argc, argv)
+     int argc;
+     char** argv;
+{
+  int prevoptind = optind;
+  int prevopterr = opterr;
+  int longind;
+  int optc;
+  int wanterror;
+  static int lastoptind = -1;
+  unsigned long flag_value;
+  char* tail;
+
+#define OPTION_FASTLOAD (300)
+#define OPTION_NO_FASTLOAD (OPTION_FASTLOAD + 1)
+#define OPTION_FASTRAM (OPTION_NO_FASTLOAD + 1)
+#define OPTION_NO_FASTRAM (OPTION_FASTRAM + 1)
+#define OPTION_FASTALLOC (OPTION_NO_FASTRAM + 1)
+#define OPTION_NO_FASTALLOC (OPTION_FASTALLOC + 1)
+#define OPTION_BESTFIT (OPTION_NO_FASTALLOC + 1)
+#define OPTION_NO_BESTFIT (OPTION_BESTFIT + 1)
+#define OPTION_BASEREL (OPTION_NO_BESTFIT + 1)
+#define OPTION_NO_BASEREL (OPTION_BASEREL + 1)
+#define OPTION_MEM_PRIVATE (OPTION_NO_BASEREL + 1)
+#define OPTION_MEM_GLOBAL (OPTION_MEM_PRIVATE + 1)
+#define OPTION_MEM_SUPER (OPTION_MEM_GLOBAL + 1)
+#define OPTION_MEM_READONLY (OPTION_MEM_SUPER + 1)
+#define OPTION_PRG_FLAGS (OPTION_MEM_READONLY + 1)
+
+  static struct option longopts[] =
+  {
+    {"mfastload", no_argument, NULL, OPTION_FASTLOAD},
+    {"mno-fastload", no_argument, NULL, OPTION_NO_FASTLOAD},
+    {"mfastram", no_argument, NULL, OPTION_FASTRAM},
+    {"mno-fastram", no_argument, NULL, OPTION_NO_FASTRAM},
+    {"maltram", no_argument, NULL, OPTION_FASTRAM},
+    {"mno-altram", no_argument, NULL, OPTION_NO_FASTRAM},
+    {"mfastalloc", no_argument, NULL, OPTION_FASTALLOC},
+    {"mno-fastalloc", no_argument, NULL, OPTION_NO_FASTALLOC},
+    {"maltalloc", no_argument, NULL, OPTION_FASTALLOC},
+    {"mno-altalloc", no_argument, NULL, OPTION_NO_FASTALLOC},
+    {"mbest-fit", no_argument, NULL, OPTION_BESTFIT},
+    {"mno-best-fit", no_argument, NULL, OPTION_NO_BESTFIT},
+    {"mbaserel", no_argument, NULL, OPTION_BASEREL},
+    {"mno-baserel", no_argument, NULL, OPTION_NO_BASEREL},
+    {"mshared-text", no_argument, NULL, OPTION_BASEREL},
+    {"mno-shared-text", no_argument, NULL, OPTION_NO_BASEREL},
+    {"msharable-text", no_argument, NULL, OPTION_BASEREL},
+    {"mno-sharable-text", no_argument, NULL, OPTION_NO_BASEREL},
+    /* Memory protection bits.  */
+    {"mprivate-memory", no_argument, NULL, OPTION_MEM_PRIVATE },
+    {"mglobal-memory", no_argument, NULL, OPTION_MEM_GLOBAL},
+    {"msuper-memory", no_argument, NULL, OPTION_MEM_SUPER},
+    {"mreadable-memory", no_argument, NULL, OPTION_MEM_READONLY},
+    {"mreadonly-memory", no_argument, NULL, OPTION_MEM_READONLY},
+    {"mprg-flags", required_argument, NULL, OPTION_PRG_FLAGS},
+    {NULL, no_argument, NULL, 0}
+  };
+
+  if (lastoptind != optind)
+    opterr = 0;
+  wanterror = opterr;
+
+  lastoptind = optind;
+
+  optc = getopt_long_only (argc, argv, "-", longopts, &longind);
+  opterr = prevopterr;
+
+  switch (optc)
+    {
+    default:
+      if (wanterror)
+	xexit (1);
+      optind = prevoptind;
+      return 0;
+
+    case OPTION_FASTLOAD:
+      prg_flags |= _MINT_F_FASTLOAD;
+      break;
+
+    case OPTION_NO_FASTLOAD:
+      prg_flags &= ~_MINT_F_FASTLOAD;
+      break;
+
+    case OPTION_FASTRAM:
+      prg_flags |= _MINT_F_ALTLOAD;
+      break;
+
+    case OPTION_NO_FASTRAM:
+      prg_flags &= ~_MINT_F_ALTLOAD;
+      break;
+
+    case OPTION_FASTALLOC:
+      prg_flags |= _MINT_F_ALTALLOC;
+      break;
+
+    case OPTION_NO_FASTALLOC:
+      prg_flags &= ~_MINT_F_ALTALLOC;
+      break;
+
+    case OPTION_BESTFIT:
+      prg_flags |= _MINT_F_BESTFIT;
+      break;
+
+    case OPTION_NO_BESTFIT:
+      prg_flags &= ~_MINT_F_BESTFIT;
+      break;
+
+    case OPTION_BASEREL:
+      prg_flags |= _MINT_F_SHTEXT;
+      break;
+
+    case OPTION_NO_BASEREL:
+      prg_flags &= ~_MINT_F_SHTEXT;
+      break;
+
+    case OPTION_MEM_PRIVATE:
+      prg_flags &= ~_MINT_F_MEMPROTECTION;
+      break;
+
+    case OPTION_MEM_GLOBAL:
+      prg_flags &= ~_MINT_F_MEMPROTECTION;
+      prg_flags |= _MINT_F_MEMPRIVATE;
+      break;
+
+    case OPTION_MEM_SUPER:
+      prg_flags &= ~_MINT_F_MEMPROTECTION;
+      prg_flags |= _MINT_F_MEMSUPER;
+      break;
+
+    case OPTION_MEM_READONLY:
+      prg_flags &= ~_MINT_F_MEMPROTECTION;
+      prg_flags |= _MINT_F_MEMREADABLE;
+      break;
+
+    case OPTION_PRG_FLAGS:
+      flag_value = strtoul (optarg, &tail, 0);
+      if (*tail != '\0')
+	{
+	  einfo ("%P: warning: ignoring invalid program flags %s\n", optarg);
+	}
+      else if (flag_value > 0xffffffffUL)
+	{
+	  einfo ("\
+%P: warning: ignoring invalid program flags %s (out of range)\n");
+	}
+      else
+	{
+	  prg_flags = flag_value;
+	}
+      break;
+
+    case 0:  /* A long option that just set a flag.  */
+      break;
+    }
+
+  return 1;
+}
+
+static void
+gld${EMULATION_NAME}_finish ()
+{
+  if (strcmp (bfd_get_target (output_bfd), "a.out-mintprg") == 0)
+    (void) bfd_m68kmint_set_extended_flags (output_bfd, prg_flags);
+}
+
+static char *
+gld${EMULATION_NAME}_get_script(isfile)
+     int *isfile;
+EOF
+
+if test -n "$COMPILE_IN"
+then
+# Scripts compiled in.
+
+# sed commands to quote an ld script as a C string.
+sc="-f stringify.sed"
+
+cat >>e${EMULATION_NAME}.c <<EOF
+{			     
+  *isfile = 0;
+
+  if (link_info.relocatable == TRUE && config.build_constructors == TRUE)
+    return
+EOF
+sed $sc ldscripts/${EMULATION_NAME}.xu                     >> e${EMULATION_NAME}.c
+echo '  ; else if (link_info.relocatable == TRUE) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xr                     >> e${EMULATION_NAME}.c
+echo '  ; else if (!config.text_read_only) return'         >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xbn                    >> e${EMULATION_NAME}.c
+echo '  ; else if (!config.magic_demand_paged) return'     >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xn                     >> e${EMULATION_NAME}.c
+echo '  ; else return'                                     >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.x                      >> e${EMULATION_NAME}.c
+echo '; }'                                                 >> e${EMULATION_NAME}.c
+
+else
+# Scripts read from the filesystem.
+
+cat >>e${EMULATION_NAME}.c <<EOF
+{			     
+  *isfile = 1;
+
+  if (link_info.relocatable == TRUE && config.build_constructors == TRUE)
+    return "ldscripts/${EMULATION_NAME}.xu";
+  else if (link_info.relocatable == TRUE)
+    return "ldscripts/${EMULATION_NAME}.xr";
+  else if (!config.text_read_only)
+    return "ldscripts/${EMULATION_NAME}.xbn";
+  else if (!config.magic_demand_paged)
+    return "ldscripts/${EMULATION_NAME}.xn";
+  else
+    return "ldscripts/${EMULATION_NAME}.x";
+}
+EOF
+
+fi
+
+cat >>e${EMULATION_NAME}.c <<EOF
+
+struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
+{
+  gld${EMULATION_NAME}_before_parse,
+  syslib_default,
+  hll_default,
+  after_parse_default,
+  after_open_default,
+  after_allocation_default,
+  set_output_arch_default,
+  ldemul_default_target,
+  before_allocation_default,
+  gld${EMULATION_NAME}_get_script,
+  "${EMULATION_NAME}",
+  "${OUTPUT_FORMAT}",
+  gld${EMULATION_NAME}_finish,
+  NULL,    /* create_output_section_statements */
+  NULL,    /* open_dynamic_archive */
+  NULL,    /* place_orphan */
+  NULL,    /* set_symbols */
+  gld${EMULATION_NAME}_parse_args,
+  NULL,	/* add_options */
+  NULL,	/* handle_option */
+  NULL,    /* unrecognized_file */
+  NULL,    /* list options */
+  NULL,    /* recognized file */
+  NULL,     /* find potential libraries */
+  NULL	/* new_vers_pattern */
+};
+EOF




ld/emulparams/m68kmint.sh


Generator for custom binary file format.

diff -Naur binutils-2.16.1/ld/emulparams/m68kmint.sh binutils-2.16.1-new/ld/emulparams/m68kmint.sh
--- binutils-2.16.1/ld/emulparams/m68kmint.sh	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.16.1-new/ld/emulparams/m68kmint.sh	2005-08-16 18:06:05.000000000 +0200
@@ -0,0 +1,7 @@
+SCRIPT_NAME=m68kmint
+OUTPUT_FORMAT="a.out-mintprg"
+TEXT_START_ADDR=0xe4
+TARGET_PAGE_SIZE=2
+NONPAGED_TEXT_START_ADDR=${TEXT_START_ADDR}
+ARCH=m68k
+TEMPLATE_NAME=mint





ld/scripttempl/m68kmint.sc


Now the file defining how the various text,data,bss sections are put in our custom binary file format.

diff -Naur binutils-2.16.1/ld/scripttempl/m68kmint.sc binutils-2.16.1-new/ld/scripttempl/m68kmint.sc
--- binutils-2.16.1/ld/scripttempl/m68kmint.sc	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.16.1-new/ld/scripttempl/m68kmint.sc	2005-08-16 18:33:20.000000000 +0200
@@ -0,0 +1,55 @@
+test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
+test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
+
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
+	      "${LITTLE_OUTPUT_FORMAT}")
+OUTPUT_ARCH(${ARCH})
+
+${RELOCATING+${LIB_SEARCH_DIRS}}
+${STACKZERO+${RELOCATING+${STACKZERO}}}
+${SHLIB_PATH+${RELOCATING+${SHLIB_PATH}}}
+${RELOCATING+${EXECUTABLE_SYMBOLS}}
+${RELOCATING+PROVIDE (__stack = 0);}
+SECTIONS
+{
+  ${RELOCATING+. = ${TEXT_START_ADDR};}
+  .text :
+  {
+    CREATE_OBJECT_SYMBOLS
+    *(.text)
+    /* The next six sections are for SunOS dynamic linking.  The order
+       is important.  */
+    *(.dynrel)
+    *(.hash)
+    *(.dynsym)
+    *(.dynstr)
+    *(.rules)
+    *(.need)
+    ${RELOCATING+_etext = .;}
+    ${RELOCATING+__etext = .;}
+    ${PAD_TEXT+${RELOCATING+. = ${DATA_ALIGNMENT};}}
+  }
+  ${RELOCATING+. = ${DATA_ALIGNMENT};}
+  .data :
+  {
+    /* The first three sections are for SunOS dynamic linking.  */
+    *(.dynamic)
+    *(.got)
+    *(.plt)
+    *(.data)
+    *(.linux-dynamic) /* For Linux dynamic linking.  */
+    ${CONSTRUCTING+CONSTRUCTORS}
+    ${RELOCATING+_edata  =  .;}
+    ${RELOCATING+__edata  =  .;}
+  }
+  .bss :
+  {
+   ${RELOCATING+ __bss_start = .};
+   *(.bss)
+   *(COMMON)
+   ${RELOCATING+_end = ALIGN(4) };
+   ${RELOCATING+__end = ALIGN(4) };
+  }
+}
+EOF



Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]