Ceci est une version archivée de
Binutils2161 à 2006-11-29 19:01:45.
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/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