From 007e17891232fb10848a5250f188cbc684a49fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Tue, 25 Oct 2016 09:48:15 +0200 Subject: [PATCH] Add binutils 2.14 as an alternative for 2.9.1 --- .gitmodules | 3 + patches/binutils-2.14/bfd/Makefile.am.diff | 48 - patches/binutils-2.14/bfd/Makefile.in.diff | 48 - patches/binutils-2.14/bfd/amigaos.c | 3189 ----------------- patches/binutils-2.14/bfd/amigaoslink.c | 1032 ------ patches/binutils-2.14/bfd/aout-amiga.c | 152 - patches/binutils-2.14/bfd/aoutx.h.diff | 61 - patches/binutils-2.14/bfd/archive.c.diff | 49 - patches/binutils-2.14/bfd/bfd-in2.h.diff | 18 - patches/binutils-2.14/bfd/bfd.c.diff | 10 - patches/binutils-2.14/bfd/config.bfd.diff | 14 - patches/binutils-2.14/bfd/configure.diff | 12 - patches/binutils-2.14/bfd/configure.in.diff | 12 - .../binutils-2.14/bfd/doc/Makefile.am.diff | 38 - .../binutils-2.14/bfd/doc/Makefile.in.diff | 40 - .../binutils-2.14/bfd/doc/bfd.texinfo.diff | 29 - patches/binutils-2.14/bfd/libamiga.h | 187 - patches/binutils-2.14/bfd/linker.c.diff | 63 - patches/binutils-2.14/bfd/targets.c.diff | 28 - patches/binutils-2.14/binutils/objcopy.c.diff | 13 - patches/binutils-2.14/gas/Makefile.am.diff | 72 - patches/binutils-2.14/gas/Makefile.in.diff | 75 - patches/binutils-2.14/gas/app.c.diff | 89 - patches/binutils-2.14/gas/as.c.diff | 36 - patches/binutils-2.14/gas/as.h.diff | 25 - .../gas/config/m68k-parse.h.diff | 12 - .../gas/config/m68k-parse.y.diff | 35 - .../binutils-2.14/gas/config/obj-amigahunk.c | 212 -- .../binutils-2.14/gas/config/obj-amigahunk.h | 54 - .../binutils-2.14/gas/config/tc-m68k.c.diff | 688 ---- .../binutils-2.14/gas/config/tc-m68k.h.diff | 43 - patches/binutils-2.14/gas/config/te-amiga.h | 24 - patches/binutils-2.14/gas/configure.diff | 20 - patches/binutils-2.14/gas/configure.in.diff | 20 - patches/binutils-2.14/gas/read.c.diff | 74 - patches/binutils-2.14/gas/read.h.diff | 12 - patches/binutils-2.14/gas/tc.h.diff | 28 - patches/binutils-2.14/gas/write.c.diff | 133 - patches/binutils-2.14/gas/write.h.diff | 25 - patches/binutils-2.14/ld/Makefile.am.diff | 24 - patches/binutils-2.14/ld/Makefile.in.diff | 24 - patches/binutils-2.14/ld/configure.tgt.diff | 10 - patches/binutils-2.14/ld/emulparams/amiga.sh | 6 - .../binutils-2.14/ld/emulparams/amiga_bss.sh | 6 - patches/binutils-2.14/ld/emultempl/amiga.em | 288 -- patches/binutils-2.14/ld/ldctor.c.diff | 41 - patches/binutils-2.14/ld/ldfile.c.diff | 109 - patches/binutils-2.14/ld/ldfile.h.diff | 12 - patches/binutils-2.14/ld/ldlang.h.diff | 11 - patches/binutils-2.14/ld/scripttempl/amiga.sc | 49 - .../binutils-2.14/ld/scripttempl/amiga_bss.sc | 41 - patches/binutils-2.14/opcodes/configure.diff | 20 - patches/binutils-2.14/opcodes/m68k-dis.c.diff | 11 - submodules/binutils-2.14 | 1 + toolchain-m68k | 2 +- 55 files changed, 5 insertions(+), 7373 deletions(-) delete mode 100644 patches/binutils-2.14/bfd/Makefile.am.diff delete mode 100644 patches/binutils-2.14/bfd/Makefile.in.diff delete mode 100644 patches/binutils-2.14/bfd/amigaos.c delete mode 100644 patches/binutils-2.14/bfd/amigaoslink.c delete mode 100644 patches/binutils-2.14/bfd/aout-amiga.c delete mode 100644 patches/binutils-2.14/bfd/aoutx.h.diff delete mode 100644 patches/binutils-2.14/bfd/archive.c.diff delete mode 100644 patches/binutils-2.14/bfd/bfd-in2.h.diff delete mode 100644 patches/binutils-2.14/bfd/bfd.c.diff delete mode 100644 patches/binutils-2.14/bfd/config.bfd.diff delete mode 100644 patches/binutils-2.14/bfd/configure.diff delete mode 100644 patches/binutils-2.14/bfd/configure.in.diff delete mode 100644 patches/binutils-2.14/bfd/doc/Makefile.am.diff delete mode 100644 patches/binutils-2.14/bfd/doc/Makefile.in.diff delete mode 100644 patches/binutils-2.14/bfd/doc/bfd.texinfo.diff delete mode 100644 patches/binutils-2.14/bfd/libamiga.h delete mode 100644 patches/binutils-2.14/bfd/linker.c.diff delete mode 100644 patches/binutils-2.14/bfd/targets.c.diff delete mode 100644 patches/binutils-2.14/binutils/objcopy.c.diff delete mode 100644 patches/binutils-2.14/gas/Makefile.am.diff delete mode 100644 patches/binutils-2.14/gas/Makefile.in.diff delete mode 100644 patches/binutils-2.14/gas/app.c.diff delete mode 100644 patches/binutils-2.14/gas/as.c.diff delete mode 100644 patches/binutils-2.14/gas/as.h.diff delete mode 100644 patches/binutils-2.14/gas/config/m68k-parse.h.diff delete mode 100644 patches/binutils-2.14/gas/config/m68k-parse.y.diff delete mode 100644 patches/binutils-2.14/gas/config/obj-amigahunk.c delete mode 100644 patches/binutils-2.14/gas/config/obj-amigahunk.h delete mode 100644 patches/binutils-2.14/gas/config/tc-m68k.c.diff delete mode 100644 patches/binutils-2.14/gas/config/tc-m68k.h.diff delete mode 100644 patches/binutils-2.14/gas/config/te-amiga.h delete mode 100644 patches/binutils-2.14/gas/configure.diff delete mode 100644 patches/binutils-2.14/gas/configure.in.diff delete mode 100644 patches/binutils-2.14/gas/read.c.diff delete mode 100644 patches/binutils-2.14/gas/read.h.diff delete mode 100644 patches/binutils-2.14/gas/tc.h.diff delete mode 100644 patches/binutils-2.14/gas/write.c.diff delete mode 100644 patches/binutils-2.14/gas/write.h.diff delete mode 100644 patches/binutils-2.14/ld/Makefile.am.diff delete mode 100644 patches/binutils-2.14/ld/Makefile.in.diff delete mode 100644 patches/binutils-2.14/ld/configure.tgt.diff delete mode 100644 patches/binutils-2.14/ld/emulparams/amiga.sh delete mode 100644 patches/binutils-2.14/ld/emulparams/amiga_bss.sh delete mode 100644 patches/binutils-2.14/ld/emultempl/amiga.em delete mode 100644 patches/binutils-2.14/ld/ldctor.c.diff delete mode 100644 patches/binutils-2.14/ld/ldfile.c.diff delete mode 100644 patches/binutils-2.14/ld/ldfile.h.diff delete mode 100644 patches/binutils-2.14/ld/ldlang.h.diff delete mode 100644 patches/binutils-2.14/ld/scripttempl/amiga.sc delete mode 100644 patches/binutils-2.14/ld/scripttempl/amiga_bss.sc delete mode 100644 patches/binutils-2.14/opcodes/configure.diff delete mode 100644 patches/binutils-2.14/opcodes/m68k-dis.c.diff create mode 160000 submodules/binutils-2.14 diff --git a/.gitmodules b/.gitmodules index 1e98608..f8b2b3b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "submodules/fd2pragma"] path = submodules/fd2pragma url = https://github.com/adtools/fd2pragma.git +[submodule "submodules/binutils-2.14"] + path = submodules/binutils-2.14 + url = https://github.com/adtools/amigaos-binutils-2.14.git diff --git a/patches/binutils-2.14/bfd/Makefile.am.diff b/patches/binutils-2.14/bfd/Makefile.am.diff deleted file mode 100644 index 27e7a1d..0000000 --- a/patches/binutils-2.14/bfd/Makefile.am.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- binutils-2.14/bfd/Makefile.am 2003-04-21 15:24:18.000000000 +0200 -+++ binutils-2.14-patched/bfd/Makefile.am 2013-04-24 18:38:23.000000000 +0200 -@@ -162,7 +162,10 @@ - # The .o files needed by all of the 32 bit vectors that are configured into - # target_vector in targets.c if configured with --enable-targets=all. - BFD32_BACKENDS = \ -+ amigaos.lo \ -+ amigaoslink.lo \ - aout-adobe.lo \ -+ aout-amiga.lo \ - aout-arm.lo \ - aout-cris.lo \ - aout-ns32k.lo \ -@@ -326,7 +331,10 @@ - xtensa-modules.lo - - BFD32_BACKENDS_CFILES = \ -+ amigaos.c \ -+ amigaoslink.c \ - aout-adobe.c \ -+ aout-amiga.c \ - aout-arm.c \ - aout-cris.c \ - aout-ns32k.c \ -@@ -587,7 +597,7 @@ - aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \ - elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h \ - elf64-hppa.h elfcode.h elfcore.h elflink.h \ -- freebsd.h genlink.h go32stub.h \ -+ freebsd.h genlink.h go32stub.h libamiga.h \ - libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \ - libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \ - netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \ -@@ -969,9 +979,14 @@ - cpu-xstormy16.lo: cpu-xstormy16.c $(INCDIR)/filenames.h - cpu-xtensa.lo: cpu-xtensa.c $(INCDIR)/filenames.h - cpu-z8k.lo: cpu-z8k.c $(INCDIR)/filenames.h -+amigaos.lo: amigaos.c libamiga.h -+amigaoslink.lo: amigaoslink.c $(INCDIR)/bfdlink.h genlink.h libamiga.h - aout-adobe.lo: aout-adobe.c $(INCDIR)/filenames.h $(INCDIR)/aout/adobe.h \ - $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h \ - $(INCDIR)/bfdlink.h -+aout-amiga.lo: aout-amiga.c libaout.h $(INCDIR)/bfdlink.h \ -+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ -+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h - aout-arm.lo: aout-arm.c $(INCDIR)/filenames.h libaout.h \ - $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h aoutx.h \ - $(INCDIR)/safe-ctype.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \ diff --git a/patches/binutils-2.14/bfd/Makefile.in.diff b/patches/binutils-2.14/bfd/Makefile.in.diff deleted file mode 100644 index 53f2523..0000000 --- a/patches/binutils-2.14/bfd/Makefile.in.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- binutils-2.14/bfd/Makefile.in 2003-05-02 19:06:14.000000000 +0200 -+++ binutils-2.14-patched/bfd/Makefile.in 2013-04-24 18:38:25.000000000 +0200 -@@ -289,7 +337,10 @@ - # The .o files needed by all of the 32 bit vectors that are configured into - # target_vector in targets.c if configured with --enable-targets=all. - BFD32_BACKENDS = \ -+ amigaos.lo \ -+ amigaoslink.lo \ - aout-adobe.lo \ -+ aout-amiga.lo \ - aout-arm.lo \ - aout-cris.lo \ - aout-ns32k.lo \ -@@ -454,7 +507,10 @@ - - - BFD32_BACKENDS_CFILES = \ -+ amigaos.c \ -+ amigaoslink.c \ - aout-adobe.c \ -+ aout-amiga.c \ - aout-arm.c \ - aout-cris.c \ - aout-ns32k.c \ -@@ -721,7 +779,7 @@ - aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \ - elf-bfd.h elf-hppa.h elf32-arm.h elf32-hppa.h \ - elf64-hppa.h elfcode.h elfcore.h elflink.h \ -- freebsd.h genlink.h go32stub.h \ -+ freebsd.h genlink.h go32stub.h libamiga.h \ - libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \ - libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \ - netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \ -@@ -1502,9 +1508,14 @@ - cpu-xstormy16.lo: cpu-xstormy16.c $(INCDIR)/filenames.h - cpu-xtensa.lo: cpu-xtensa.c $(INCDIR)/filenames.h - cpu-z8k.lo: cpu-z8k.c $(INCDIR)/filenames.h -+amigaos.lo: amigaos.c libamiga.h -+amigaoslink.lo: amigaoslink.c $(INCDIR)/bfdlink.h genlink.h libamiga.h - aout-adobe.lo: aout-adobe.c $(INCDIR)/filenames.h $(INCDIR)/aout/adobe.h \ - $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def libaout.h \ - $(INCDIR)/bfdlink.h -+aout-amiga.lo: aout-amiga.c libaout.h $(INCDIR)/bfdlink.h \ -+ $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \ -+ $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h - aout-arm.lo: aout-arm.c $(INCDIR)/filenames.h libaout.h \ - $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h aoutx.h \ - $(INCDIR)/safe-ctype.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \ diff --git a/patches/binutils-2.14/bfd/amigaos.c b/patches/binutils-2.14/bfd/amigaos.c deleted file mode 100644 index dc764db..0000000 --- a/patches/binutils-2.14/bfd/amigaos.c +++ /dev/null @@ -1,3189 +0,0 @@ -/* BFD back-end for Commodore-Amiga AmigaOS binaries. - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 - Free Software Foundation, Inc. - Contributed by Leonard Norrgard. Partially based on the bout - and ieee BFD backends and Markus Wild's tool hunk2gcc. - Revised and updated by Stephan Thesing. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* -SECTION - amiga back end - -This section describes the overall structure of the Amiga BFD back end. -The linker stuff can be found in @xref{amigalink}. -@menu -@* implementation:: -@* amigalink:: -@end menu - -INODE -implementation, amigalink, amiga, amiga - -SECTION - implementation - -The need for a port of the bfd library for Amiga style object (hunk) files -arose by the desire to port the GNU debugger gdb to the Amiga. -Also, the linker ld should be updated to the current version (2.5.2). -@@* -This port bases on the work done by Leonard Norrgard, who started porting -gdb. Raphael Luebbert, who supports the ixemul.library, has also worked on -implementing the needed @code{ptrace()} system call and gas2.5. - -@menu -@* not supported:: -@* Does it work?:: -@* TODO:: -@end menu - -INODE -not supported, Does it work?, implementation, implementation - -SUBSECTION - not supported - -Currently, the implementation does not support Amiga link library files, like -e.g. amiga.lib. This may be added in a later version, if anyone starts work -on it, or I find some time for it. - -The handling of the symbols in hunk files is a little bit broken: - o The symbols in a load file are totally ignored at the moment, so gdb and gprof - do not work. - o The symbols of a object module (Hunk file, starting with HUNK_UNIT) are read in - correctly, but HUNK_SYMBOL hunks are also ignored. - -The reason for this is the following: -Amiga symbol hunks do not allow for much information. Only a name and a value are allowed. -On the other hand, a.out format carries along much more information (see, e.g. the -entry on set symbols in the ld manual). The old linker copied this information into -a HUNK_DEBUG hunk. Now there is the choice: - o ignoring the debug hunk, read in only HUNK_SYMBOL definitions => extra info is lost. - o read in the debug hunk and use the information therein => How can clashs between the - information in the debug hunk and HUNK_SYMBOL or HUNK_EXT hunks be avoided? -I haven't decided yet, what to do about this. - -Although bfd allows to link together object modules of different flavours, -producing a.out style executables does not work on Amiga :-) -It should, however, be possible to create a.out files with the -r option of ld -(incremental link). - -INODE -Does it work?, TODO, not supported, implementation - -SUBSECTION - Does it work? - -Currently, the following utilities work: - o objdump - o objcopy - o strip - o nm - o ar - o gas - -INODE -TODO, , Does it work?, implementation - -SUBSECTION - TODO - - o fix FIXME:s - -@* -BFD: - o add flag to say if the format allows multiple sections with the - same name. Fix bfd_get_section_by_name() and bfd_make_section() - accordingly. - - o dumpobj.c: the disassembler: use relocation record data to find symbolic - names of addresses, when available. Needs new routine where one can - specify the source section of the symbol to be printed as well as some - rewrite of the disassemble functions. -*/ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "libamiga.h" - -#define BYTES_IN_WORD 4 -#include "aout/aout64.h" /* struct external_nlist */ - -#ifndef alloca -extern PTR alloca PARAMS ((size_t)); -#endif - -#define bfd_is_bfd_section(sec) \ - (bfd_is_abs_section(sec)||bfd_is_com_section(sec)||bfd_is_und_section(sec)||bfd_is_ind_section(sec)) - -struct arch_syms { - unsigned long offset; /* disk offset in the archive */ - unsigned long size; /* size of the block of symbols */ - unsigned long unit_offset; /* start of unit on disk */ - struct arch_syms *next; /* linked list */ -}; - -typedef struct amiga_ardata_struct { - /* generic stuff */ - struct artdata generic; - /* amiga-specific stuff */ - unsigned long filesize; - struct arch_syms *defsyms; - unsigned long defsym_count; - unsigned long outnum; -} amiga_ardata_type; - -#define amiga_ardata(bfd) (*(amiga_ardata_type **)(void *)&(bfd)->tdata.aout_ar_data) - -#define bfd_msg (*_bfd_error_handler) - -#define GL(x) bfd_get_32 (abfd, (bfd_byte *) (x)) -#define GW(x) bfd_get_16 (abfd, (bfd_byte *) (x)) -#define LONGSIZE(l) (((l)+3) >> 2) - -/* AmigaOS doesn't like HUNK_SYMBOL with symbol names longer than 124 characters */ -#define MAX_NAME_SIZE 124 - -static bfd_boolean get_long PARAMS ((bfd *, unsigned long *)); -static const struct bfd_target *amiga_object_p PARAMS ((bfd *)); -static sec_ptr amiga_get_section_by_hunk_number PARAMS ((bfd *, long)); -static bfd_boolean amiga_add_reloc PARAMS ((bfd *, sec_ptr, bfd_size_type, - amiga_symbol_type *, reloc_howto_type *, long)); -static sec_ptr amiga_make_unique_section PARAMS ((bfd *, const char *)); -static bfd_boolean parse_archive_units PARAMS ((bfd *, int *, unsigned long, - bfd_boolean, struct arch_syms **, symindex *)); -static bfd_boolean amiga_digest_file PARAMS ((bfd *)); -static bfd_boolean amiga_read_unit PARAMS ((bfd *, unsigned long)); -static bfd_boolean amiga_read_load PARAMS ((bfd *)); -static bfd_boolean amiga_handle_cdb_hunk PARAMS ((bfd *, unsigned long, - unsigned long, unsigned long, unsigned long)); -static bfd_boolean amiga_handle_rest PARAMS ((bfd *, sec_ptr, bfd_boolean)); -static bfd_boolean amiga_mkobject PARAMS ((bfd *)); -static bfd_boolean amiga_mkarchive PARAMS ((bfd *)); -static bfd_boolean write_longs PARAMS ((const unsigned long *, unsigned long, - bfd *)); -static long determine_datadata_relocs PARAMS ((bfd *, sec_ptr)); -static void remove_section_index PARAMS ((sec_ptr, int *)); -static bfd_boolean amiga_write_object_contents PARAMS ((bfd *)); -static bfd_boolean write_name PARAMS ((bfd *, const char *, unsigned long)); -static bfd_boolean amiga_write_archive_contents PARAMS ((bfd *)); -static bfd_boolean amiga_write_armap PARAMS ((bfd *, unsigned int, - struct orl *, unsigned int, int)); -static int determine_type PARAMS ((arelent *)); -static bfd_boolean amiga_write_section_contents PARAMS ((bfd *, sec_ptr, - sec_ptr, unsigned long, int *, int)); -static bfd_boolean amiga_write_symbols PARAMS ((bfd *, sec_ptr)); -static bfd_boolean amiga_get_section_contents PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); -static bfd_boolean amiga_new_section_hook PARAMS ((bfd *, sec_ptr)); -static bfd_boolean amiga_slurp_symbol_table PARAMS ((bfd *)); -static long amiga_get_symtab_upper_bound PARAMS ((bfd *)); -static long amiga_get_symtab PARAMS ((bfd *, asymbol **)); -static asymbol *amiga_make_empty_symbol PARAMS ((bfd *)); -static void amiga_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); -static void amiga_print_symbol PARAMS ((bfd *, PTR, asymbol *, - bfd_print_symbol_type)); -static long amiga_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); -static bfd_boolean read_raw_relocs PARAMS ((bfd *, sec_ptr, unsigned long, - unsigned long)); -static bfd_boolean amiga_slurp_relocs PARAMS ((bfd *, sec_ptr, asymbol **)); -static long amiga_canonicalize_reloc PARAMS ((bfd *, sec_ptr, arelent **, - asymbol **)); -static bfd_boolean amiga_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); -static bfd_boolean amiga_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, - unsigned long)); -static int amiga_sizeof_headers PARAMS ((bfd *, bfd_boolean)); -static bfd_boolean amiga_find_nearest_line PARAMS ((bfd *, sec_ptr, - asymbol **, bfd_vma, const char **, const char **, unsigned int *)); -static reloc_howto_type *amiga_bfd_reloc_type_lookup PARAMS ((bfd *, - bfd_reloc_code_real_type)); -static bfd_boolean amiga_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); -static bfd_boolean amiga_bfd_copy_private_section_data PARAMS ((bfd *, - sec_ptr, bfd *, sec_ptr)); -static bfd_boolean amiga_slurp_armap PARAMS ((bfd *)); -static void amiga_truncate_arname PARAMS ((bfd *, const char *, char *)); -static const struct bfd_target *amiga_archive_p PARAMS ((bfd *)); -static bfd *amiga_openr_next_archived_file PARAMS ((bfd *, bfd *)); -static PTR amiga_read_ar_hdr PARAMS ((bfd *)); -static int amiga_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); - -/*#define DEBUG_AMIGA 1*/ -#if DEBUG_AMIGA -#include -static void -error_print (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - vfprintf (stderr, fmt, args); - va_end (args); -} -#define DPRINT(L,x) if (L>=DEBUG_AMIGA) error_print x -#else -#define DPRINT(L,x) -#endif - -enum {R_ABS32=0,R_PC16,R_PC8,R_SD32,R_SD16,R_SD8,R_ABS32SHORT,R_PC26,R_PC32,R__MAX}; -static reloc_howto_type howto_table[R__MAX] = -{ - {H_ABS32, /* type */ - 0, /* rightshift */ - 2, /* size */ - 32, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield,/* complain_on_overflow */ - 0, /* special_function */ - "RELOC32", /* textual name */ - FALSE, /* partial_inplace */ - 0xffffffff, /* src_mask */ - 0xffffffff, /* dst_mask */ - FALSE}, /* pcrel_offset */ - {H_PC16, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "RELRELOC16", FALSE, 0x0000ffff, 0x0000ffff, TRUE}, - {H_PC8, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0, "RELRELOC8", FALSE, 0x000000ff, 0x000000ff, TRUE}, - {H_SD32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "DREL32", FALSE, 0xffffffff, 0xffffffff, FALSE}, - {H_SD16, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "DREL16", FALSE, 0x0000ffff, 0x0000ffff, FALSE}, - {H_SD8, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, 0, "DREL8", FALSE, 0x000000ff, 0x000000ff, FALSE}, - {H_ABS32SHORT, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "RELOC32SHORT", FALSE, 0x0000ffff, 0x0000ffff, FALSE}, - {H_PC26, 0, 2, 26, TRUE, 0, complain_overflow_signed, 0, "RELRELOC26", FALSE, 0x03fffffc, 0x03fffffc, TRUE}, - {H_PC32, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "RELRELOC32", FALSE, 0xffffffff, 0xffffffff, TRUE} -}; - -/* The following are gross hacks that need to be fixed. The problem is - that the linker unconditionally references these values without - going through any of bfd's standard interface. Thus they need to - be defined in a bfd module that is included in *all* configurations, - and are currently in bfd.c, otherwise linking the linker will fail - on non-Amiga target configurations. */ - -/* This one is used by the linker and tells us, if a debug hunk should - be written out. */ -extern int write_debug_hunk; - -/* This is also used by the linker to set the attribute of sections. */ -extern int amiga_attribute; - -/* used with base-relative linking */ -extern int amiga_base_relative; - -/* used with -resident linking */ -extern int amiga_resident; - -static bfd_boolean -get_long (abfd, n) - bfd *abfd; - unsigned long *n; -{ - if (bfd_bread ((PTR)n, 4, abfd) != 4) - return FALSE; - *n = GL (n); - return TRUE; -} - -static const struct bfd_target * -amiga_object_p (abfd) - bfd *abfd; -{ - unsigned long x; - char buf[8]; - - /* An Amiga object file must be at least 8 bytes long. */ - if (bfd_bread (buf, sizeof(buf), abfd) != sizeof(buf)) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } - - bfd_seek (abfd, 0, SEEK_SET); - - /* Does it look like an Amiga object file? */ - x = GL (&buf[0]); - if ((x != HUNK_UNIT) && (x != HUNK_HEADER)) - { - /* Not an Amiga file. */ - bfd_set_error (bfd_error_wrong_format); - return NULL; - } - - /* Can't fail and return (but must be declared bfd_boolean to suit - other bfd requirements). */ - (void) amiga_mkobject (abfd); - - AMIGA_DATA(abfd)->IsLoadFile = (x == HUNK_HEADER); - - if (!amiga_digest_file (abfd)) - { - /* Something went wrong. */ - DPRINT(20,("bfd parser stopped at offset 0x%lx\n",bfd_tell(abfd))); - return NULL; - } - - /* Set default architecture to m68k:68000. */ - /* So we can link on 68000 AMIGAs... */ - abfd->arch_info = bfd_scan_arch ("m68k:68000"); - - return abfd->xvec; -} - -static sec_ptr -amiga_get_section_by_hunk_number (abfd, hunk_number) - bfd *abfd; - long hunk_number; -{ - /* A cache, so we don't have to search the entire list every time. */ - static sec_ptr last_reference; - static bfd *last_bfd; - sec_ptr p; - - if (last_reference) - if (last_bfd == abfd && last_reference->target_index == hunk_number) - return last_reference; - for (p = abfd->sections; p != NULL; p = p->next) - if (p->target_index == hunk_number) - { - last_reference = p; - last_bfd = abfd; - return p; - } - BFD_FAIL (); - return NULL; -} - -static bfd_boolean -amiga_add_reloc (abfd, section, offset, symbol, howto, target_hunk) - bfd *abfd; - sec_ptr section; - bfd_size_type offset; - amiga_symbol_type *symbol; - reloc_howto_type *howto; - long target_hunk; -{ - amiga_reloc_type *reloc; - sec_ptr target_sec; - - reloc = (amiga_reloc_type *) bfd_alloc (abfd, sizeof (amiga_reloc_type)); - if (reloc == NULL) - return FALSE; - - abfd->flags |= HAS_RELOC; - section->flags |= SEC_RELOC; - - if (amiga_per_section(section)->reloc_tail) - amiga_per_section(section)->reloc_tail->next = reloc; - else - section->relocation = &reloc->relent; - amiga_per_section(section)->reloc_tail = reloc; - - reloc->relent.sym_ptr_ptr = &reloc->symbol; - reloc->relent.address = offset; - reloc->relent.addend = 0; - reloc->relent.howto = howto; - - reloc->next = NULL; - if (symbol==NULL) { /* relative to section */ - target_sec = amiga_get_section_by_hunk_number (abfd, target_hunk); - if (target_sec) - reloc->symbol = target_sec->symbol; - else - return FALSE; - } - else - reloc->symbol = &symbol->symbol; - - return TRUE; -} - -/* BFD doesn't currently allow multiple sections with the same - name, so we try a little harder to get a unique name. */ -static sec_ptr -amiga_make_unique_section (abfd, name) - bfd *abfd; - const char *name; -{ - sec_ptr section; - - bfd_set_error (bfd_error_no_error); - section = bfd_make_section (abfd, name); - if ((section == NULL) && (bfd_get_error() == bfd_error_no_error)) - { -#if 0 - char *new_name = bfd_alloc (abfd, strlen(name) + 4); - int i = 1; - - /* We try to come up with an original name (since BFD currently - requires all sections to have different names). */ - while (!section && (i<=99)) - { - sprintf (new_name, "%s_%u", name, i++); - section = bfd_make_section (abfd, new_name); - } -#else - section = bfd_make_section_anyway (abfd, name); -#endif - } - return section; -} - -#if DEBUG_AMIGA -#define DPRINTHUNK(x) fprintf(stderr,"Processing %s hunk (0x%x)...",\ - (x) == HUNK_UNIT ? "HUNK_UNIT" :\ - (x) == HUNK_NAME ? "HUNK_NAME" :\ - (x) == HUNK_CODE ? "HUNK_CODE" :\ - (x) == HUNK_DATA ? "HUNK_DATA" :\ - (x) == HUNK_BSS ? "HUNK_BSS" :\ - (x) == HUNK_ABSRELOC32 ? "HUNK_RELOC32" :\ - (x) == HUNK_RELRELOC16 ? "HUNK_RELRELOC16" :\ - (x) == HUNK_RELRELOC8 ? "HUNK_RELRELOC8" :\ - (x) == HUNK_EXT ? "HUNK_EXT" :\ - (x) == HUNK_SYMBOL ? "HUNK_SYMBOL" :\ - (x) == HUNK_DEBUG ? "HUNK_DEBUG" :\ - (x) == HUNK_END ? "HUNK_END" :\ - (x) == HUNK_HEADER ? "HUNK_HEADER" :\ - (x) == HUNK_OVERLAY ? "HUNK_OVERLAY" :\ - (x) == HUNK_BREAK ? "HUNK_BREAK" :\ - (x) == HUNK_DREL32 ? "HUNK_DREL32" :\ - (x) == HUNK_DREL16 ? "HUNK_DREL16" :\ - (x) == HUNK_DREL8 ? "HUNK_DREL8" :\ - (x) == HUNK_LIB ? "HUNK_LIB" :\ - (x) == HUNK_INDEX ? "HUNK_INDEX" :\ - (x) == HUNK_RELOC32SHORT ? "HUNK_RELOC32SHORT" :\ - (x) == HUNK_RELRELOC32 ? "HUNK_RELRELOC32" :\ - (x) == HUNK_PPC_CODE ? "HUNK_PPC_CODE" :\ - (x) == HUNK_RELRELOC26 ? "HUNK_RELRELOC26" :\ - "*unknown*",(x)) -#define DPRINTHUNKEND fprintf(stderr,"done\n") -#else -#define DPRINTHUNK(x) -#define DPRINTHUNKEND -#endif - -static bfd_boolean -parse_archive_units (abfd, n_units, filesize, one, syms, symcount) - bfd *abfd; - int *n_units; - unsigned long filesize; - bfd_boolean one; /* parse only the first unit? */ - struct arch_syms **syms; - symindex *symcount; -{ - struct arch_syms *nsyms,*syms_tail=NULL; - unsigned long unit_offset,defsym_pos=0; - unsigned long hunk_type,type,len,no,n; - symindex defsymcount=0; - - *n_units = 0; - while (get_long (abfd, &hunk_type)) { - switch (hunk_type) { - case HUNK_END: - break; - case HUNK_UNIT: - unit_offset = bfd_tell (abfd) - 4; - (*n_units)++; - if (one && *n_units>1) { - bfd_seek (abfd, -4, SEEK_CUR); - return TRUE; - } - /* Fall through */ - case HUNK_NAME: - case HUNK_CODE: - case HUNK_DATA: - case HUNK_DEBUG: - case HUNK_PPC_CODE: - if (!get_long (abfd, &len) - || bfd_seek (abfd, HUNK_VALUE (len) << 2, SEEK_CUR)) - return FALSE; - break; - case HUNK_BSS: - if (!get_long (abfd, &len)) - return FALSE; - break; - case HUNK_ABSRELOC32: - case HUNK_RELRELOC16: - case HUNK_RELRELOC8: - case HUNK_SYMBOL: - case HUNK_DREL32: - case HUNK_DREL16: - case HUNK_DREL8: - for (;;) { - /* read offsets count */ - if (!get_long (abfd, &no)) - return FALSE; - if (!no) - break; - /* skip hunk+offsets */ - if (bfd_seek (abfd, (no+1)<<2, SEEK_CUR)) - return FALSE; - } - break; - case HUNK_EXT: - defsym_pos = 0; - if (!get_long (abfd, &n)) - return FALSE; - while (n) { - len = n & 0xffffff; - type = (n>>24) & 0xff; - switch (type) { - case EXT_SYMB: - case EXT_DEF: - case EXT_ABS: - /* retain the positions of defined symbols for each object - in the archive. They'll be used later to build a - pseudo-armap, which _bfd_generic_link_add_archive_symbols - needs */ - if (defsym_pos==0) - defsym_pos = bfd_tell (abfd) - 4; - /* skip name & value */ - if (bfd_seek (abfd, (len+1)<<2, SEEK_CUR)) - return FALSE; - defsymcount++; - break; - - case EXT_ABSREF32: - case EXT_RELREF16: - case EXT_RELREF8: - case EXT_DEXT32: - case EXT_DEXT16: - case EXT_DEXT8: - case EXT_RELREF32: - case EXT_RELREF26: - /* skip name */ - if (bfd_seek (abfd, len<<2, SEEK_CUR)) - return FALSE; - /* skip references */ - if (!get_long (abfd, &no)) - return FALSE; - if (no && bfd_seek (abfd, no<<2, SEEK_CUR)) - return FALSE; - break; - - case EXT_ABSCOMMON: - case EXT_DEXT32COMMON: - case EXT_DEXT16COMMON: - case EXT_DEXT8COMMON: - /* skip name & value */ - if (bfd_seek (abfd, (len+1)<<2, SEEK_CUR)) - return FALSE; - /* skip references */ - if (!get_long (abfd, &no)) - return FALSE; - if (no && bfd_seek (abfd, no<<2, SEEK_CUR)) - return FALSE; - break; - - default: /* error */ - bfd_msg ("unexpected type %ld(0x%lx) in hunk_ext1 at offset 0x%lx", - type, type, bfd_tell (abfd)); - return FALSE; - } - - if (!get_long (abfd, &n)) - return FALSE; - } - if (defsym_pos != 0 && syms) { - /* there are some defined symbols, keep enough information on - them to simulate an armap later on */ - nsyms = (struct arch_syms *) bfd_alloc (abfd, sizeof (struct arch_syms)); - nsyms->next = NULL; - if (syms_tail) - syms_tail->next = nsyms; - else - *syms = nsyms; - syms_tail = nsyms; - nsyms->offset = defsym_pos; - nsyms->size = bfd_tell (abfd) - defsym_pos; - nsyms->unit_offset = unit_offset; - } - break; /* of HUNK_EXT */ - - default: -#if 0 - bfd_msg ("unexpected hunk 0x%lx at offset 0x%lx", - hunk_type, bfd_tell (abfd)); -#endif - return FALSE; - } - } - if (syms && symcount) - *symcount = defsymcount; - return (bfd_tell (abfd) == filesize); -} - -static bfd_boolean -amiga_digest_file (abfd) - bfd *abfd; -{ - struct stat stat_buffer; - unsigned long tmp; - - if (!get_long (abfd, &tmp)) - { - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } - - switch (HUNK_VALUE (tmp)) - { - case HUNK_UNIT: - /* Read the unit(s) */ - if (bfd_stat (abfd, &stat_buffer) < 0) - return FALSE; -/* - while ((pos=bfd_tell (abfd)) < stat_buffer.st_size) - {*/ - if (!amiga_read_unit (abfd, stat_buffer.st_size - abfd->origin)) - return FALSE; - if (abfd->arelt_data) - arelt_size (abfd) = bfd_tell (abfd); -/* }*/ - break; - - case HUNK_HEADER: - /* This is a load file */ - if (!amiga_read_load (abfd)) - return FALSE; - break; - } - - return TRUE; -}/* of amiga_digest_file */ - - -/* Read in Unit file */ -/* file pointer is located after the HUNK_UNIT LW */ -static bfd_boolean -amiga_read_unit (abfd, size) - bfd *abfd; - unsigned long size; -{ - unsigned long hunk_number=0,hunk_type,tmp; - - /* read LW length of unit's name */ - if (!get_long (abfd, &tmp)) - return FALSE; - - /* and skip it (FIXME maybe) */ - if (bfd_seek (abfd, tmp<<2, SEEK_CUR)) - return FALSE; - - while (bfd_tell (abfd) < size) - { - if (!get_long (abfd, &tmp)) - return FALSE; - - /* Now there may be CODE, DATA, BSS, SYMBOL, DEBUG, RELOC Hunks */ - hunk_type = HUNK_VALUE (tmp); - switch (hunk_type) - { - case HUNK_UNIT: - /* next unit, seek back and return */ - return (bfd_seek (abfd, -4, SEEK_CUR) == 0); - - case HUNK_DEBUG: - /* we don't parse hunk_debug at the moment */ - if (!get_long (abfd, &tmp) || bfd_seek (abfd, tmp<<2, SEEK_CUR)) - return FALSE; - break; - - case HUNK_NAME: - case HUNK_CODE: - case HUNK_DATA: - case HUNK_BSS: - case HUNK_PPC_CODE: - /* Handle this hunk, including relocs, etc. - The finishing HUNK_END is consumed by the routine */ - if (!amiga_handle_cdb_hunk (abfd, hunk_type, hunk_number++, 0, -1)) - return FALSE; - break; - - default: - /* Something very nasty happened: invalid hunk occured... */ - bfd_set_error (bfd_error_wrong_format); - return FALSE; - break; - }/* Of switch hunk_type */ - - /* Next hunk */ - } - return TRUE; -} - - -/* Read a load file */ -static bfd_boolean -amiga_read_load (abfd) - bfd *abfd; -{ - unsigned long max_hunk_number,hunk_type,tmp,i; - unsigned long *hunk_attributes,*hunk_sizes; - char buf[16]; - - /* Read hunk lengths (and memory attributes...) */ - /* Read in each hunk */ - - if (bfd_bread (buf, sizeof(buf), abfd) != sizeof(buf)) - return FALSE; - - /* If there are resident libs: abort (obsolete feature) */ - if (GL (&buf[0]) != 0) - return FALSE; - - max_hunk_number = GL (&buf[4]); - - /* Sanity */ - if (max_hunk_number<1) - { - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } - - AMIGA_DATA(abfd)->nb_hunks = max_hunk_number; - - /* Num of root hunk must be 0 */ - if (GL (&buf[8]) != 0) - { - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } - - /* Num of last hunk must be mhn-1 */ - if (GL (&buf[12]) != max_hunk_number-1) - { - bfd_msg ("Overlay loadfiles are not supported"); - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } - - hunk_sizes = alloca (max_hunk_number * sizeof (unsigned long)); - hunk_attributes = alloca (max_hunk_number * sizeof (unsigned long)); - if (hunk_sizes == NULL || hunk_attributes == NULL) - { - bfd_set_error (bfd_error_no_memory); - return FALSE; - } - - /* Now, read in sizes and memory attributes */ - for (i=0; ifilepos = bfd_tell (abfd); - /* For a loadfile, the section size in memory comes from the - hunk header. The size on disk may be smaller. */ - current_section->_cooked_size = current_section->_raw_size = - ((hunk_size==(unsigned long)-1) ? len : hunk_size); - current_section->target_index = hunk_number; - bfd_set_section_flags (abfd, current_section, secflags); - - amiga_per_section(current_section)->disk_size = len; /* size on disk */ - amiga_per_section(current_section)->attribute = hunk_attribute; - - /* skip the contents */ - if ((secflags & SEC_HAS_CONTENTS) && bfd_seek (abfd, len, SEEK_CUR)) - return FALSE; - - if (!amiga_handle_rest (abfd, current_section, is_load)) - return FALSE; - break; - - /* Currently, there is one debug hunk per executable, instead of one - per unit as it would with a "standard" AmigaOS implementation. So - the debug hunk is at the same level as code/data/bss. - This will change in the future */ - case HUNK_DEBUG: - /* format of gnu debug hunk is: - HUNK_DEBUG - N - ZMAGIC - symtabsize - strtabsize - symtabdata [length=symtabsize] - strtabdata [length=strtabsize] - [pad bytes] - */ - - /* read LW length */ - if (!get_long (abfd, &tmp)) - return FALSE; - len = tmp << 2; - if (len > 12) - { - char buf[12]; - if (bfd_bread (buf, sizeof(buf), abfd) != sizeof(buf)) - return FALSE; - if (GL (&buf[0]) == ZMAGIC) /* GNU DEBUG HUNK */ - { - amiga_data_type *amiga_data=AMIGA_DATA(abfd); - /* FIXME: we should add the symbols in the debug hunk to symtab... */ - amiga_data->symtab_size = GL (&buf[4]); - amiga_data->stringtab_size = GL (&buf[8]); - adata(abfd).sym_filepos = bfd_tell (abfd); - adata(abfd).str_filepos = adata(abfd).sym_filepos + - amiga_data->symtab_size; - } - len -= sizeof(buf); - } - if (bfd_seek (abfd, len, SEEK_CUR)) - return FALSE; - break; - - default: - bfd_set_error (bfd_error_wrong_format); - return FALSE; - break; - }/* switch (hunk_type) */ - - return TRUE; -}/* Of amiga_handle_cdb_hunk */ - - -/* Handle rest of a hunk - I.e.: Relocs, EXT, SYMBOLS... */ -static bfd_boolean -amiga_handle_rest (abfd, current_section, isload) - bfd *abfd; - sec_ptr current_section; - bfd_boolean isload; -{ - amiga_per_section_type *asect=amiga_per_section(current_section); - unsigned long hunk_type,relno,type,len,no; - raw_reloc_type *relp; - - for (relno=0;;) - { - if (!get_long (abfd, &hunk_type)) - return FALSE; - switch (hunk_type) - { - case HUNK_END: - if (relno) - { - abfd->flags |= HAS_RELOC; - current_section->flags |= SEC_RELOC; - current_section->reloc_count = relno; - } - return TRUE; - break; - - case HUNK_DREL32: - if (isload) - hunk_type = HUNK_RELOC32SHORT; - case HUNK_ABSRELOC32: - case HUNK_RELRELOC16: - case HUNK_RELRELOC8: - case HUNK_DREL16: - case HUNK_DREL8: - case HUNK_RELOC32SHORT: - /* count and skip relocs */ - relp = (raw_reloc_type *) bfd_alloc (abfd, sizeof (*relp)); - relp->next = asect->relocs; - asect->relocs = relp; - relp->pos = bfd_tell (abfd) - 4; - relp->num = 0; - if (hunk_type != HUNK_RELOC32SHORT) { - for (;;) { - if (!get_long (abfd, &no)) - return FALSE; - if (!no) - break; - relp->num += no; - if (bfd_seek (abfd, (no+1)<<2, SEEK_CUR)) - return FALSE; - } - } - else { - for (;;) { - char buf[2]; - if (bfd_bread (buf, 2, abfd) != 2) - return FALSE; - if (no=GW(buf),!no) - break; - relp->num += no; - if (bfd_seek (abfd, (no+1)<<1, SEEK_CUR)) - return FALSE; - } - if ((bfd_tell (abfd) & 2) && bfd_seek (abfd, 2, SEEK_CUR)) - return FALSE; - } - relno += relp->num; - break; - - case HUNK_SYMBOL: - /* In a unit, we ignore these, since all symbol information - comes with HUNK_EXT, in a load file, these are added */ - if (!isload) - { - asect->hunk_symbol_pos = bfd_tell (abfd); - for (;;) { - /* size of symbol */ - if (!get_long (abfd, &no)) - return FALSE; - if (!no) - break; - /* skip the name */ - if (bfd_seek (abfd, (no+1)<<2, SEEK_CUR)) - return FALSE; - } - break; - } - /* We add these, by falling through... */ - - case HUNK_EXT: - /* We leave these alone, until they are requested by the user */ - asect->hunk_ext_pos = bfd_tell (abfd); - for (;;) - { - if (!get_long (abfd, &no)) - return FALSE; - if (!no) - break; - - /* symbol type and length */ - type = (no>>24) & 0xff; - len = no & 0xffffff; - - /* skip symbol name */ - if (bfd_seek (abfd, len<<2, SEEK_CUR)) - return FALSE; - - /* We have symbols */ - abfd->flags |= HAS_SYMS; - abfd->symcount++; - - switch (type) - { - case EXT_SYMB: /* Symbol hunks are relative to hunk start... */ - case EXT_DEF: /* def relative to hunk */ - case EXT_ABS: /* def absolute */ - /* skip the value */ - if (!get_long (abfd, &no)) - return FALSE; - break; - - case EXT_ABSCOMMON: /* Common ref/def */ - case EXT_DEXT32COMMON: - case EXT_DEXT16COMMON: - case EXT_DEXT8COMMON: - /* FIXME: skip the size of common block */ - if (!get_long (abfd, &no)) - return FALSE; - - /* Fall through */ - - case EXT_ABSREF32: /* 32 bit ref */ - case EXT_RELREF16: /* 16 bit ref */ - case EXT_RELREF8: /* 8 bit ref */ - case EXT_DEXT32: /* 32 bit baserel */ - case EXT_DEXT16: /* 16 bit baserel */ - case EXT_DEXT8: /* 8 bit baserel */ - case EXT_RELREF32: - case EXT_RELREF26: - if (!get_long (abfd, &no)) - return FALSE; - if (no) - { - relno += no; - /* skip references */ - if (bfd_seek (abfd, no<<2, SEEK_CUR)) - return FALSE; - } - break; - - default: /* error */ - bfd_msg ("unexpected type %ld(0x%lx) in hunk_ext2 at offset 0x%lx", - type, type, bfd_tell (abfd)); - bfd_set_error (bfd_error_wrong_format); - return FALSE; - break; - }/* of switch type */ - } - break; - - case HUNK_DEBUG: - /* If a debug hunk is found at this position, the file has - been generated by a third party tool and the debug info - here are useless to us. Just skip the hunk, then. */ - if (!get_long (abfd, &no) || bfd_seek (abfd, no<<2, SEEK_CUR)) - return FALSE; - break; - - default: /* error */ - bfd_seek (abfd, -4, SEEK_CUR); - bfd_msg ("missing HUNK_END: unexpected hunktype %ld(0x%lx) at offset 0x%lx", - hunk_type, hunk_type, bfd_tell (abfd)); - hunk_type = HUNK_VALUE(hunk_type); - if (hunk_type == HUNK_CODE || hunk_type == HUNK_DATA || hunk_type == HUNK_BSS) - return TRUE; - bfd_set_error (bfd_error_wrong_format); - return FALSE; - break; - }/* Of switch */ - }/* Of for */ - return TRUE; -}/* of amiga_handle_rest */ - -static bfd_boolean -amiga_mkobject (abfd) - bfd *abfd; -{ - amiga_data_type *rawptr; - rawptr = (amiga_data_type *) bfd_zalloc (abfd, sizeof (*rawptr)); - abfd->tdata.amiga_data = rawptr; - return (rawptr!=NULL); -} - -static bfd_boolean -amiga_mkarchive (abfd) - bfd *abfd; -{ - amiga_ardata_type *ar; - ar = (amiga_ardata_type *) bfd_zalloc (abfd, sizeof (*ar)); - amiga_ardata (abfd) = ar; - return (ar!=NULL); -} - -/* write nb long words (possibly swapped out) to the output file */ -static bfd_boolean -write_longs (in, nb, abfd) - const unsigned long *in; - unsigned long nb; - bfd *abfd; -{ - unsigned char out[10*4]; - unsigned long i; - - while (nb) - { - for (i=0; ireloc_count;i++) - { - arelent *r=section->orelocation[i]; - if (r == NULL) - continue; - sym_p=*(r->sym_ptr_ptr); /* The symbol for this relocation */ - insection=sym_p->section; - - /* Is reloc relative to a special section? */ - if (bfd_is_bfd_section(insection)) - continue; /* Nothing to do, since this translates to HUNK_EXT */ - if (insection->output_section == section) - relocs++; - } - return relocs; -} - -/* Adjust the indices map when we decide not to output the section */ -static void -remove_section_index (sec, index_map) - sec_ptr sec; - int *index_map; -{ - int i=sec->index; - for (sec=sec->next,index_map[i++]=-1; sec; sec=sec->next) - (index_map[i++])--; -} - -/* Write out the contents of a bfd */ -static bfd_boolean -amiga_write_object_contents (abfd) - bfd *abfd; -{ - long datadata_relocs=0,bss_size=0,idx; - int *index_map,max_hunk=-1; - sec_ptr data_sec,p; - unsigned long i,n[5]; - - /* Distinguish UNITS, LOAD Files - Write out hunks+relocs+HUNK_EXT+HUNK_DEBUG (GNU format) */ - DPRINT(5,("Entering write_object_conts\n")); - - abfd->output_has_begun=TRUE; /* Output has begun */ - - index_map = bfd_alloc (abfd, abfd->section_count * sizeof (int)); - if (!index_map) - return FALSE; - - for (idx=0, p=abfd->sections; p!=NULL; p=p->next) - index_map[idx++] = p->index; - - /* Distinguish Load files and Unit files */ - if (AMIGA_DATA(abfd)->IsLoadFile) - { - DPRINT(5,("Writing load file\n")); - - if (amiga_base_relative) - BFD_ASSERT (abfd->section_count==3); - - /* Write out load file header */ - n[0] = HUNK_HEADER; - n[1] = n[2] = 0; - for (p=abfd->sections; p!=NULL; p=p->next) { - /* For baserel linking, don't remove empty sections, since they - may get some contents later on */ - if ((amiga_base_relative || p->_raw_size!=0 || p->_cooked_size!=0) && - !(amiga_base_relative && !strcmp (p->name, ".bss"))) - n[2]++; - else - remove_section_index (p, index_map); - } - n[3] = 0; - n[4] = n[2]-1; - if (!write_longs (n, 5, abfd)) - return FALSE; - - /* Write out sizes and memory specifiers... */ - /* We have to traverse the section list again, bad but no other way... */ - if (amiga_base_relative) { - for (p=abfd->sections; p!=NULL; p=p->next) - { - if (amiga_resident && !strcmp(p->name,".data")) - { - datadata_relocs = determine_datadata_relocs (abfd, p); - data_sec = p; - } - else if (!strcmp(p->name,".bss")) - { - /* Get size for header */ - bss_size = p->_raw_size; - } - } - } - - for (p=abfd->sections; p!=NULL; p=p->next) - { - long extra = 0, i; - - if (index_map[p->index] < 0) - continue; - - if (datadata_relocs && !strcmp(p->name,".text")) - extra = datadata_relocs * 4; - else if (bss_size && !strcmp (p->name, ".data")) - extra = bss_size; - /* convert to a size in long words */ - n[0] = LONGSIZE (p->_raw_size + extra); - - i = amiga_per_section(p)->attribute; - switch (i) - { - case MEMF_CHIP: - n[0]|=HUNKF_CHIP; - i=1; - break; - case MEMF_FAST: - n[0]|=HUNKF_FAST; - i=1; - break; - case 0: /* nothing */ - i=1; - break; - default: /* special one */ - n[0]|=0xc0000000; - n[1]=i; - i=2; - break; - }/* Of switch */ - - if (!write_longs (n, i, abfd)) - return FALSE; - }/* Of for */ - } - else - { /* Unit, no base-relative linking here.. */ - DPRINT(5,("Writing unit\n")); - - /* Write out unit header */ - n[0]=HUNK_UNIT; - if (!write_longs (n, 1, abfd) || !write_name (abfd, abfd->filename, 0)) - return FALSE; - - for (i=0;ioutsymbols[i]; - sec_ptr osection=sym_p->section; - if (!osection || !bfd_is_com_section(osection->output_section)) - continue; - for (p=abfd->sections; p!=NULL; p=p->next) { - if (!strcmp(p->name, ".bss")) { - if (!p->_raw_size && !p->_cooked_size) - p->_cooked_size = sym_p->value; - break; - } - } - break; - } - - for (p=abfd->sections; p!=NULL; p=p->next) { - if (p->_raw_size==0 && p->_cooked_size==0) - remove_section_index (p, index_map); - } - } - - /* Compute the maximum hunk number of the ouput file */ - for (p=abfd->sections; p!=NULL; p=p->next) - max_hunk++; - - /* Write out every section */ - for (p=abfd->sections; p!=NULL; p=p->next) - { - if (index_map[p->index] < 0) - continue; - -#define ddrels (datadata_relocs&&!strcmp(p->name,".text")?datadata_relocs:0) - if (!amiga_write_section_contents (abfd,p,data_sec,ddrels,index_map, - max_hunk)) - return FALSE; - - if (!amiga_write_symbols (abfd,p)) /* Write out symbols + HUNK_END */ - return FALSE; - }/* of for sections */ - - /* Write out debug hunk, if requested */ - if (AMIGA_DATA(abfd)->IsLoadFile && write_debug_hunk) - { - extern bfd_boolean - translate_to_native_sym_flags (bfd*, asymbol*, struct external_nlist*); - - unsigned int offset = 4, symbols = 0, i; - unsigned long str_size = 4; /* the first 4 bytes will be replaced with the length */ - asymbol *sym; - sec_ptr s; - - /* We have to convert all the symbols in abfd to a.out style... */ - if (bfd_get_symcount (abfd)) - { -#define CAN_WRITE_OUTSYM(sym) (sym!=NULL && sym->section && \ - ((sym->section->owner && \ - bfd_get_flavour (sym->section->owner) == \ - bfd_target_aout_flavour) || \ - bfd_asymbol_flavour (sym) == \ - bfd_target_aout_flavour)) - - for (i = 0; i < bfd_get_symcount (abfd); i++) - { - sym = abfd->outsymbols[i]; - /* NULL entries have been written already... */ - if (CAN_WRITE_OUTSYM (sym)) - { - str_size += strlen(sym->name) + 1; - symbols++; - } - } - - if (!symbols) - return TRUE; - - /* Now, set the .text, .data and .bss fields in the tdata struct - because translate_to_native_sym_flags needs them... */ - for (i=0,s=abfd->sections;s!=NULL;s=s->next) - if (!strcmp(s->name,".text")) - { - i|=1; - adata(abfd).textsec=s; - } - else if (!strcmp(s->name,".data")) - { - i|=2; - adata(abfd).datasec=s; - } - else if (!strcmp(s->name,".bss")) - { - i|=4; - adata(abfd).bsssec=s; - } - - if (i!=7) /* section(s) missing... */ - { - bfd_msg ("Missing section, debughunk not written"); - return TRUE; - } - - /* Write out HUNK_DEBUG, size, ZMAGIC, ... */ - n[0] = HUNK_DEBUG; - n[1] = 3 + ((symbols * sizeof(struct internal_nlist) + str_size + 3) >> 2); - n[2] = ZMAGIC; /* Magic number */ - n[3] = symbols * sizeof(struct internal_nlist); - n[4] = str_size; - if (!write_longs (n, 5, abfd)) - return FALSE; - - /* Write out symbols */ - for (i = 0; i < bfd_get_symcount (abfd); i++) /* Translate every symbol */ - { - sym = abfd->outsymbols[i]; - if (CAN_WRITE_OUTSYM (sym)) - { - amiga_symbol_type *t = (amiga_symbol_type *) sym; - struct external_nlist data; - - bfd_h_put_16(abfd, t->desc, data.e_desc); - bfd_h_put_8(abfd, t->other, data.e_other); - bfd_h_put_8(abfd, t->type, data.e_type); - if (!translate_to_native_sym_flags(abfd,sym,&data)) - { - bfd_msg ("Cannot translate flags for %s", sym->name); - } - bfd_h_put_32(abfd, offset, &data.e_strx[0]); /* Store index */ - offset += strlen(sym->name) + 1; - if (bfd_bwrite ((PTR)&data, sizeof(data), abfd) - != sizeof(data)) - return FALSE; - } - } - - /* Write out strings */ - if (!write_longs (&str_size, 1, abfd)) - return FALSE; - - for (i = 0; i < bfd_get_symcount (abfd); i++) - { - sym = abfd->outsymbols[i]; - if (CAN_WRITE_OUTSYM (sym)) - { - size_t len = strlen(sym->name) + 1; - - /* Write string tab */ - if (bfd_bwrite (sym->name, len, abfd) != len) - return FALSE; - } - } - - /* Write padding */ - n[0] = 0; - i = (4 - (str_size & 3)) & 3; - if (i && bfd_bwrite ((PTR)n, i, abfd) != i) - return FALSE; - - /* write a HUNK_END here to finish the loadfile, or AmigaOS - will refuse to load it */ - n[0] = HUNK_END; - if (!write_longs (n, 1, abfd)) - return FALSE; - }/* Of if bfd_get_symcount (abfd) */ - }/* Of write out debug hunk */ - - bfd_release (abfd, index_map); - return TRUE; -} - -/* Write a string padded to 4 bytes and preceded by it's length in - long words ORed with */ -static bfd_boolean -write_name (abfd, name, value) - bfd *abfd; - const char *name; - unsigned long value; -{ - unsigned long n[1]; - size_t l; - - l = strlen (name); - if (AMIGA_DATA(abfd)->IsLoadFile && l > MAX_NAME_SIZE) - l = MAX_NAME_SIZE; - n[0] = (LONGSIZE (l) | value); - if (!write_longs (n, 1, abfd)) - return FALSE; - if (bfd_bwrite (name, l, abfd) != l) - return FALSE; - n[0] = 0; - l = (4 - (l & 3)) & 3; - return (l && bfd_bwrite ((PTR)n, l, abfd) != l ? FALSE : TRUE); -} - -static bfd_boolean -amiga_write_archive_contents (arch) - bfd *arch; -{ - struct stat status; - bfd *object; - - for (object = arch->archive_head; object; object = object->next) - { - unsigned long remaining; - - if (bfd_write_p (object)) - { - bfd_set_error (bfd_error_invalid_operation); - return FALSE; - } - - if (object->arelt_data != NULL) - { - remaining = arelt_size (object); - } - else - { - if (stat (object->filename, &status) != 0) - { - bfd_set_error (bfd_error_system_call); - return FALSE; - } - remaining = status.st_size; - } - - if (bfd_seek (object, 0, SEEK_SET)) - return FALSE; - - while (remaining) - { - char buf[DEFAULT_BUFFERSIZE]; - unsigned long amt = sizeof(buf); - if (amt > remaining) - amt = remaining; - errno = 0; - if (bfd_bread (buf, amt, object) != amt) - { - if (bfd_get_error () != bfd_error_system_call) - bfd_set_error (bfd_error_malformed_archive); - return FALSE; - } - if (bfd_bwrite (buf, amt, arch) != amt) - return FALSE; - remaining -= amt; - } - } - return TRUE; -} - -static bfd_boolean -amiga_write_armap (arch, elength, map, orl_count, stridx) - bfd *arch ATTRIBUTE_UNUSED; - unsigned int elength ATTRIBUTE_UNUSED; - struct orl *map ATTRIBUTE_UNUSED; - unsigned int orl_count ATTRIBUTE_UNUSED; - int stridx ATTRIBUTE_UNUSED; -{ - return TRUE; -} - -static int -determine_type (r) - arelent *r; -{ - switch (r->howto->type) - { - case H_ABS8: /* 8 bit absolute */ - case H_PC8: /* 8 bit pcrel */ - return 2; - - case H_ABS16: /* 16 bit absolute */ - case H_PC16: /* 16 bit pcrel */ - return 1; - - case H_ABS32: /* 32 bit absolute */ - /*case H_PC32:*//* 32 bit pcrel */ - return 0; - - case H_SD8: /* 8 bit base rel */ - return 5; - - case H_SD16: /* 16 bit base rel */ - return 4; - - case H_SD32: /* 32 bit baserel */ - return 3; - - default: /* Error, can't represent this */ - bfd_set_error (bfd_error_nonrepresentable_section); - return -1; - }/* Of switch */ -} - -#define NB_RELOC_TYPES 6 -static const unsigned long reloc_types[NB_RELOC_TYPES] = { - HUNK_ABSRELOC32, HUNK_RELRELOC16, HUNK_RELRELOC8, - HUNK_DREL32, HUNK_DREL16, HUNK_DREL8 -}; - -/* Write out section contents, including relocs */ -static bfd_boolean -amiga_write_section_contents (abfd, section, data_sec, datadata_relocs, - index_map, max_hunk) - bfd *abfd; - sec_ptr section; - sec_ptr data_sec; - unsigned long datadata_relocs; - int *index_map; - int max_hunk; -{ - sec_ptr insection; - asymbol *sym_p; - arelent *r; - unsigned long zero=0,disksize,pad,n[2],k,l,s; - long *reloc_counts,reloc_count=0; - unsigned char *values; - int i,j,x,type; - - DPRINT(5,("Entering write_section_contents\n")); - - /* If we are base-relative linking and the section is .bss and abfd - is a load file, then return */ - if (AMIGA_DATA(abfd)->IsLoadFile) - { - if (amiga_base_relative && !strcmp(section->name, ".bss")) - return TRUE; /* Nothing to do */ - } - else - { - /* WRITE out HUNK_NAME + section name */ - n[0] = HUNK_NAME; - if (!write_longs (n, 1, abfd) || !write_name (abfd, section->name, 0)) - return FALSE; - } - - /* Depending on the type of the section, write out HUNK_{CODE|DATA|BSS} */ - if (section->flags & SEC_CODE) /* Code section */ - n[0] = HUNK_CODE; - else if (section->flags & (SEC_DATA | SEC_LOAD)) /* data section */ - n[0] = HUNK_DATA; - else if (section->flags & SEC_ALLOC) /* BSS */ - n[0] = HUNK_BSS; - else if (section->flags & SEC_DEBUGGING) /* debug section */ - n[0] = HUNK_DEBUG; - else /* Error */ - { -#if 0 - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; -#else - /* FIXME: Just dump everything we don't currently recognize into - a DEBUG hunk. */ - n[0] = HUNK_DEBUG; -#endif - } - - DPRINT(10,("Section type is %lx\n",n[0])); - - /* Get real size in n[1], this may be shorter than the size in the header */ - if (amiga_per_section(section)->disk_size == 0) - amiga_per_section(section)->disk_size = section->_raw_size; - disksize = LONGSIZE (amiga_per_section(section)->disk_size) + datadata_relocs; - n[1] = disksize; - - /* in a load file, we put section attributes only in the header */ - if (!AMIGA_DATA(abfd)->IsLoadFile) - { - /* Get attribute for section */ - switch (amiga_per_section(section)->attribute) - { - case MEMF_CHIP: - n[1] |= HUNKF_CHIP; - break; - case MEMF_FAST: - n[1] |= HUNKF_FAST; - break; - case 0: - break; - default: /* error, can't represent this */ - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; - break; - } - }/* Of switch */ - - if (!write_longs (n, 2, abfd)) - return FALSE; - - DPRINT(5,("Wrote code and size=%lx\n",n[1])); - - /* If a BSS hunk, we're done, else write out section contents */ - if (HUNK_VALUE (n[0]) == HUNK_BSS) - return TRUE; - - DPRINT(5,("Non bss hunk...\n")); - - /* Traverse through the relocs, sample them in reloc_data, adjust section - data to get 0 addend - Then compactify reloc_data - Set the entry in the section for the reloc to NULL */ - - if (disksize != 0) - BFD_ASSERT ((section->flags & SEC_IN_MEMORY) != 0); - - reloc_counts = (long *) bfd_zalloc (abfd, NB_RELOC_TYPES * (max_hunk+1) - * sizeof (long)); - if (!reloc_counts) - return FALSE; - - DPRINT(5,("Section has %d relocs\n",section->reloc_count)); - - for (l = 0; l < section->reloc_count; l++) - { - r = section->orelocation[l]; - if (r == NULL) - continue; - - sym_p = *(r->sym_ptr_ptr); /* The symbol for this relocation */ - insection = sym_p->section; - DPRINT(5,("Sec for reloc is %lx(%s)\n",insection,insection->name)); - DPRINT(5,("Symbol for this reloc is %lx(%s)\n",sym_p,sym_p->name)); - /* Is reloc relative to a special section? */ - if (bfd_is_bfd_section(insection)) - continue; /* Nothing to do, since this translates to HUNK_EXT */ - - r->addend += sym_p->value; /* Add offset of symbol from section start */ - - /* Address of reloc has been unchanged since original reloc, or has - been adjusted by get_relocated_section_contents. */ - /* For relocs, the vma of the target section is in the data, the - addend is -vma of that section =>No need to add vma */ - /* Add in offset */ - r->addend += insection->output_offset; - - /* Determine which hunk to write, and index of target */ - x = index_map[insection->output_section->index]; - if (x<0 || x>max_hunk) { - bfd_msg ("erroneous relocation to hunk %d/%s from %s", - x, insection->output_section->name, insection->name); - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; - } - - type = determine_type(r); - if (type == -1) - return FALSE; - if (type >= NB_RELOC_TYPES) { - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; - } - reloc_counts[type+(x*NB_RELOC_TYPES)]++; - reloc_count++; - - /* There is no error checking with these... */ - DPRINT(5,("reloc address=%lx,addend=%lx\n",r->address,r->addend)); - values = §ion->contents[r->address]; - - switch (type) - { - case 2: case 5: /* adjust byte */ - x = ((char *)values)[0] + r->addend; - values[0] = x & 0xff; - break; - case 1: case 4: /* adjust word */ - k = values[1] | (values[0] << 8); - x = (int)k + r->addend; - values[0] = (x & 0xff00) >> 8; - values[1] = x & 0xff; - break; - case 0: case 3: /* adjust long */ - k = values[3] | (values[2] << 8) | (values[1] << 16) | - (values[0] << 24); - x = (int)k + r->addend; - values[3] = x & 0xff; - values[2] = (x & 0xff00) >> 8; - values[1] = (x & 0xff0000) >> 16; - values[0] = ((unsigned int)x & 0xff000000) >> 24; - break; - }/* of switch */ - - r->addend = 0; - DPRINT(5,("Did adjusting\n")); - }/* of for l */ - - DPRINT(5,("Did all relocs\n")); - - /* We applied all the relocs, as far as possible to obtain 0 addend fields */ - /* Write the section contents */ - if (amiga_per_section(section)->disk_size != 0) - { - if (bfd_bwrite ((PTR)section->contents, - amiga_per_section(section)->disk_size, abfd) != - amiga_per_section(section)->disk_size) - return FALSE; - - /* pad the section on disk if necessary (to a long boundary) */ - pad = (4 - (amiga_per_section(section)->disk_size & 3)) & 3; - if (pad && (bfd_bwrite ((PTR)&zero, pad, abfd) != pad)) - return FALSE; - } - -#if 0 - /* write bss data in the data hunk if needed */ - for (; bss_size--;) - if (!write_longs (&zero, 1, abfd)) - return FALSE; -#endif - - if (datadata_relocs) - { - datadata_relocs--; - if (!write_longs (&datadata_relocs, 1, abfd)) - return FALSE; - for (s = 0; s < data_sec->reloc_count; s++) - { - r = data_sec->orelocation[s]; - if (r == NULL) - continue; - - sym_p = *(r->sym_ptr_ptr); /* The symbol for this relocation */ - insection = sym_p->section; - /* Is reloc relative to a special section? */ - if (bfd_is_bfd_section(insection)) - continue; /* Nothing to do, since this translates to HUNK_EXT */ - - if (insection->output_section == data_sec) - { - if (determine_type(r) == 0) - if (!write_longs (&r->address, 1, abfd)) - return FALSE; - } - } - } - - DPRINT(10,("Wrote contents, writing relocs now\n")); - - if (reloc_count > 0) { - /* Sample every reloc type */ - for (i = 0; i < NB_RELOC_TYPES; i++) { - int written = FALSE; - for (j = 0; j <= max_hunk; j++) { - long relocs; - while ((relocs = reloc_counts[i+(j*NB_RELOC_TYPES)]) > 0) { - - if (!written) { - if (!write_longs (&reloc_types[i], 1, abfd)) - return FALSE; - written = TRUE; - } - - if (relocs > 0xffff) - relocs = 0xffff; - - n[0] = relocs; - n[1] = j; - if (!write_longs (n, 2, abfd)) - return FALSE; - - reloc_counts[i+(j*NB_RELOC_TYPES)] -= relocs; - reloc_count -= relocs; - - for (k = 0; k < section->reloc_count; k++) { - int jj; - - r = section->orelocation[k]; - if (r == NULL) /* already written */ - continue; - - sym_p = *(r->sym_ptr_ptr); /* The symbol for this relocation */ - insection = sym_p->section; - /* Is reloc relative to a special section? */ - if (bfd_is_bfd_section(insection)) - continue; /* Nothing to do, since this translates to HUNK_EXT */ -#if 0 - /* Determine which hunk to write, and index of target */ - for (jj = 0, sec = abfd->sections; sec; sec = sec->next, jj++) { - if (sec == insection->output_section) - break; - } - BFD_ASSERT (jj==index_map[insection->output_section->index]); -#else - jj=index_map[insection->output_section->index]; -#endif - if (jj == j && i == determine_type(r)) { - section->orelocation[k] = NULL; - if (!write_longs (&r->address, 1, abfd)) - return FALSE; - if (--relocs == 0) - break; - } - } - } - } - /* write a zero to finish the relocs */ - if (written && !write_longs (&zero, 1, abfd)) - return FALSE; - } - } - - bfd_release (abfd, reloc_counts); - DPRINT(5,("Leaving write_section...\n")); - if (reloc_count > 0) { - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; - } - return TRUE; -} - - -/* Write out symbol information, including HUNK_EXT, DEFS, ABS. - In the case, we were linking base relative, the symbols of the .bss - hunk have been converted already to belong to the .data hunk */ - -static bfd_boolean -amiga_write_symbols (abfd, section) - bfd *abfd; - sec_ptr section; -{ - sec_ptr osection; - asymbol *sym_p; - arelent *r; - unsigned long n[3],symbol_header,type; - unsigned int i,j,idx,ncnt,symbol_count; - - /* If base rel linking and section is .bss ==> exit */ - if (amiga_base_relative && !strcmp(section->name,".bss")) - return TRUE; - - if (section->reloc_count==0 && bfd_get_symcount (abfd)==0) - {/* Write HUNK_END */ - alldone: - DPRINT(5,("Leaving write_symbols\n")); - n[0]=HUNK_END; - return write_longs (n, 1, abfd); - } - - /* If this is Loadfile, then do not write HUNK_EXT, but rather HUNK_SYMBOL */ - symbol_header = AMIGA_DATA(abfd)->IsLoadFile ? HUNK_SYMBOL : HUNK_EXT; - - /* Write out all the symbol definitions, then HUNK_END - - Now, first traverse the relocs, all entries that are non NULL - have to be taken into account */ - symbol_count = 0; - - DPRINT(10,("Traversing relocation table\n")); - for (i=0;ireloc_count;i++) - { - r=section->orelocation[i]; - if (r==NULL) - continue; - - sym_p=*(r->sym_ptr_ptr); /* The symbol for this relocation */ - osection=sym_p->section; /* The section the symbol belongs to */ - /* this section MUST be a special section */ - - DPRINT(5,("Symbol is %s, section is %lx(%s)\n",sym_p->name,osection,osection->name)); - - /* group together relocations referring to the same symbol and howto */ - for(idx=i,j=i+1;jreloc_count;j++) - { - arelent *rj=section->orelocation[j]; - if (rj==NULL || sym_p!=*(rj->sym_ptr_ptr) || r->howto!=rj->howto) - continue; /* no match */ - if (++i == j) - continue; /* adjacent */ - section->orelocation[j] = section->orelocation[i]; - section->orelocation[i] = rj; - } - - if ((symbol_count++)==0) /* First write out the HUNK_EXT */ - { - if (!write_longs (&symbol_header, 1, abfd)) - return FALSE; - } - - if (!bfd_is_com_section(osection)) /* Not common symbol */ - { - DPRINT(5,("Non common ref\n")); - /* Determine type of ref */ - switch (r->howto->type) - { - case H_ABS8: - case H_PC8: - type=EXT_RELREF8; - break; - - case H_ABS16: - case H_PC16: - type=EXT_RELREF16; - break; - - case H_ABS32: - type=EXT_ABSREF32; - break; - - case H_PC32: - type=EXT_RELREF32; - break; - - case H_SD8: - type=EXT_DEXT8; - break; - - case H_SD16: - type=EXT_DEXT16; - break; - - case H_SD32: - type=EXT_DEXT32; - break; - - case H_PC26: - type=EXT_RELREF26; - break; - - default: /* Error, can't represent this */ - bfd_msg ("unexpected reloc %d(%s) at offset 0x%lx", - r->howto->type, r->howto->name, bfd_tell (abfd)); - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; - break; - }/* Of switch */ - ncnt=0; - }/* Of is ref to undefined or abs symbol */ - else /* ref to common symbol */ - { - DPRINT(5,("Common ref\n")); - switch (r->howto->type) - { - default: - bfd_msg ("Warning: bad reloc %s for common symbol %s", - r->howto->name, sym_p->name); - case H_ABS32: - type=EXT_ABSCOMMON; - break; - - case H_SD8: - type=EXT_DEXT8COMMON; - break; - - case H_SD16: - type=EXT_DEXT16COMMON; - break; - - case H_SD32: - type=EXT_DEXT32COMMON; - break; - }/* Of switch */ - n[0]=sym_p->value; /* Size of common block */ - ncnt=1; - }/* Of is common section */ - - DPRINT(5,("Type is %lx\n",type)); - if (!write_name (abfd, sym_p->name, type << 24)) - return FALSE; - n[ncnt]=i-idx+1; /* refs for symbol... */ - if (!write_longs (n, ncnt+1, abfd)) - return FALSE; - for(;idx<=i;++idx) - { - n[0]=section->orelocation[idx]->address; - if (!write_longs (n, 1, abfd)) - return FALSE; - } - }/* Of traverse relocs */ - - /* Now traverse the symbol table and write out all definitions, that are relative - to this hunk. - Absolute defs are always only written out with the first hunk. - Don't write out: - local symbols - undefined symbols - indirect symbols - warning symbols - debugging symbols - warning symbols - constructor symbols - since they are unrepresentable in HUNK format.. */ - - DPRINT(10,("Traversing symbol table\n")); - for (i=0;ioutsymbols[i]; - osection=sym_p->section; - - DPRINT(5,("%d: symbol(%s), osec=%lx(%s)\n", - i,sym_p->name,osection,osection?osection->name:"null")); - - if (osection==NULL) /* FIXME: Happens with constructor functions. */ - continue; - - if (bfd_is_und_section(osection) - /*||bfd_is_com_section(osection)*/ - ||bfd_is_ind_section(osection)) - continue; /* Don't write these */ - - /* Only write abs defs, if not writing a Loadfile */ - if (bfd_is_abs_section(osection)&&(section->index==0)&& - !AMIGA_DATA(abfd)->IsLoadFile) - { - DPRINT(5,("Abs symbol\n")); - /* don't write debug symbols, they will be written in a - HUNK_DEBUG later on */ - if (sym_p->flags & BSF_DEBUGGING) - continue; - - if ((symbol_count++)==0) /* First write out the HUNK_EXT */ - { - if (!write_longs (&symbol_header, 1, abfd)) - return FALSE; - } - - if (!write_name (abfd, sym_p->name, EXT_ABS << 24)) - return FALSE; - n[0]=sym_p->value; - if (!write_longs (n, 1, abfd)) - return FALSE; - continue; - }/* Of abs def */ - if (bfd_is_abs_section(osection)) - continue; /* Not first hunk, already written */ - - /* If it is a warning symbol, or a constructor symbol or a - debugging or a local symbol, don't write it */ - if (sym_p->flags & (BSF_WARNING|BSF_CONSTRUCTOR|BSF_DEBUGGING|BSF_LOCAL)) - continue; - if ((sym_p->flags & BSF_GLOBAL) == 0) - continue; - - /* Now, if osection==section, write it out */ - if (osection->output_section==section) - { - DPRINT(5,("Writing it out\n")); - - if ((symbol_count++)==0) /* First write out the header */ - { - if (!write_longs (&symbol_header, 1, abfd)) - return FALSE; - } - - type = symbol_header == HUNK_EXT ? EXT_DEF << 24 : 0; - if (!write_name (abfd, sym_p->name, type)) - return FALSE; - n[0] = sym_p->value + sym_p->section->output_offset; - if (!write_longs (n, 1, abfd)) - return FALSE; - } - else - { - /* write common definitions as bss common references */ - if (bfd_is_com_section(osection->output_section) && - section->index == 2) - { - if ((symbol_count++)==0) /* First write out the header */ - { - if (!write_longs (&symbol_header, 1, abfd)) - return FALSE; - } - - if (!write_name (abfd, sym_p->name, EXT_ABSCOMMON << 24)) - return FALSE; - n[0]=sym_p->value; - n[1]=0; - if (!write_longs (n, 2, abfd)) - return FALSE; - } - } - }/* Of for */ - - DPRINT(10,("Did traversing\n")); - if (symbol_count) /* terminate HUNK_EXT, HUNK_SYMBOL */ - { - n[0]=0; - if (!write_longs (n, 1, abfd)) - return FALSE; - } - DPRINT(5,("Leaving\n")); - goto alldone; /* Write HUNK_END, return */ -} - -static bfd_boolean -amiga_get_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - PTR location; - file_ptr offset; - bfd_size_type count; -{ - unsigned long disk_size=amiga_per_section(section)->disk_size; - - if (bfd_seek (abfd, section->filepos + offset, SEEK_SET)) - return FALSE; - - if (offset+count > disk_size) { - /* the section's size on disk may be smaller than in memory - in this case, pad the contents */ - if (bfd_bread (location, disk_size-offset, abfd) != disk_size-offset) - return FALSE; - memset ((char *) location + disk_size - offset, 0, count-(disk_size-offset)); - } - else { - if (bfd_bread (location, count, abfd) != count) - return FALSE; - } - return TRUE; -} - -static bfd_boolean -amiga_new_section_hook (abfd, newsect) - bfd *abfd; - sec_ptr newsect; -{ - newsect->used_by_bfd = (PTR) bfd_zalloc (abfd, - sizeof (amiga_per_section_type)); - newsect->alignment_power = 2; - if (!strcmp (newsect->name, ".data_chip") - || !strcmp (newsect->name, ".bss_chip")) - amiga_per_section(newsect)->attribute |= MEMF_CHIP; - return TRUE; -} - -static bfd_boolean -amiga_slurp_symbol_table (abfd) - bfd *abfd; -{ - amiga_data_type *amiga_data=AMIGA_DATA(abfd); - amiga_symbol_type *asp; - unsigned long l,len,type; - sec_ptr section; - - if (amiga_data->symbols) - return TRUE; /* already read */ - - if (!bfd_get_symcount (abfd)) - return TRUE; - - asp = (amiga_symbol_type *) bfd_zalloc (abfd, sizeof (amiga_symbol_type) * - bfd_get_symcount (abfd)); - if ((amiga_data->symbols = asp) == NULL) - return FALSE; - - /* Symbols are associated with every section */ - for (section=abfd->sections; section!=NULL; section=section->next) - { - amiga_per_section_type *asect=amiga_per_section(section); - - if (asect->hunk_ext_pos == 0) - continue; - - if (bfd_seek (abfd, asect->hunk_ext_pos, SEEK_SET)) - return FALSE; - - for (asect->amiga_symbols=asp; get_long (abfd, &l) && l; asp++) - { - type = l>>24; /* type of entry */ - len = (l & 0xffffff) << 2; /* namelength */ - - /* read the name */ - if ((asp->symbol.name = bfd_alloc (abfd, len+1))==NULL) - return FALSE; - if (bfd_bread ((PTR)asp->symbol.name, len, abfd) != len) - return FALSE; - ((char *)asp->symbol.name)[len] = '\0'; - - asp->symbol.the_bfd = abfd; - asp->symbol.flags = BSF_GLOBAL; - /*asp->desc = 0; - asp->other = 0;*/ - asp->type = type; - asp->index = asp - amiga_data->symbols; - - switch (type) { - case EXT_ABSCOMMON: /* Common reference/definition */ - case EXT_DEXT32COMMON: - case EXT_DEXT16COMMON: - case EXT_DEXT8COMMON: - asp->symbol.section = bfd_com_section_ptr; - /* size of common block -> symbol's value */ - if (!get_long (abfd, &l)) - return FALSE; - asp->symbol.value = l; - /* skip refs */ - if (!get_long (abfd, &l) || bfd_seek (abfd, l<<2, SEEK_CUR)) - return FALSE; - asp->refnum = l; - break; - case EXT_ABS: /* Absolute */ - asp->symbol.section = bfd_abs_section_ptr; - goto rval; - break; - case EXT_DEF: /* Relative Definition */ - case EXT_SYMB: /* Same as EXT_DEF for load files */ - asp->symbol.section = section; - rval: - /* read the value */ - if (!get_long (abfd, &l)) - return FALSE; - asp->symbol.value = l; - break; - default: /* References to an undefined symbol */ - asp->symbol.section = bfd_und_section_ptr; - asp->symbol.flags = 0; - /* skip refs */ - if (!get_long (abfd, &l) || bfd_seek (abfd, l<<2, SEEK_CUR)) - return FALSE; - asp->refnum = l; - break; - } - } - } - return TRUE; -} - - -/* Get size of symtab */ -static long -amiga_get_symtab_upper_bound (abfd) - bfd *abfd; -{ - if (!amiga_slurp_symbol_table (abfd)) - return -1; - return (bfd_get_symcount (abfd)+1) * (sizeof (amiga_symbol_type *)); -} - - -static long -amiga_get_symtab (abfd, location) - bfd *abfd; - asymbol **location; -{ - if(!amiga_slurp_symbol_table (abfd)) - return -1; - if (bfd_get_symcount (abfd)) - { - amiga_symbol_type *symp=AMIGA_DATA(abfd)->symbols; - unsigned int i; - for (i = 0; i < bfd_get_symcount (abfd); i++, symp++) - *location++ = &symp->symbol; - *location = 0; - } - return bfd_get_symcount (abfd); -} - - -static asymbol * -amiga_make_empty_symbol (abfd) - bfd *abfd; -{ - amiga_symbol_type *new = - (amiga_symbol_type *) bfd_zalloc (abfd, sizeof (amiga_symbol_type)); - new->symbol.the_bfd = abfd; - return &new->symbol; -} - - -static void -amiga_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd ATTRIBUTE_UNUSED; - asymbol *symbol; - symbol_info *ret; -{ - bfd_symbol_info (symbol, ret); - if (symbol->name[0] == ' ') - ret->name = "* empty table entry "; - if (bfd_is_abs_section(symbol->section)) - ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A'; -} - - -static void -amiga_print_symbol (abfd, afile, symbol, how) - bfd *abfd; - PTR afile; - asymbol *symbol; - bfd_print_symbol_type how; -{ - FILE *file = (FILE *)afile; - - switch (how) { - case bfd_print_symbol_name: - fprintf (file, "%s", symbol->name); - break; - case bfd_print_symbol_more: - fprintf (file, "%4lx %2x", - amiga_symbol(symbol)->refnum, - (unsigned int)amiga_symbol(symbol)->type); - break; - case bfd_print_symbol_all: - if (symbol->name[0] == ' ') - { - fprintf (file, "* empty table entry "); - } - else - { - bfd_print_symbol_vandf (abfd, (PTR)file, symbol); - fprintf (file, " %-10s %04lx %02x %s", - symbol->section->name, - amiga_symbol(symbol)->refnum, - (unsigned int)amiga_symbol(symbol)->type, - symbol->name); - } - break; - } -} - - -static long -amiga_get_reloc_upper_bound (abfd, asect) - bfd *abfd ATTRIBUTE_UNUSED; - sec_ptr asect; -{ - return (asect->reloc_count + 1) * sizeof (arelent *); -} - - -static bfd_boolean -read_raw_relocs (abfd, section, d_offset, count) - bfd *abfd; - sec_ptr section; - unsigned long d_offset; /* offset in the bfd */ - unsigned long count; /* number of relocs */ -{ - unsigned long hunk_number,offset,type,no,j; - reloc_howto_type *howto; - - if (bfd_seek (abfd, d_offset, SEEK_SET)) - return FALSE; - while ((long)count > 0) - { - /* first determine type of reloc */ - if (!get_long (abfd, &type)) - return FALSE; - - if (type==HUNK_DREL32 && AMIGA_DATA(abfd)->IsLoadFile) - type = HUNK_RELOC32SHORT; - - switch (type) - { - case HUNK_RELOC32SHORT: - /* read reloc count, hunk number and offsets */ - for (howto=&howto_table[R_ABS32SHORT];;) { - char buf[2]; - if (bfd_bread (buf, 2, abfd) != 2) - return FALSE; - if (no=GW(buf),!no) - break; - count -= no; - if (bfd_bread (buf, 2, abfd) != 2) - return FALSE; - hunk_number = GW (buf); - /* add relocs */ - for (j=0; jrelocation) - return TRUE; - - for (relp=asect->relocs; relp!=NULL; relp=relp->next) - if (relp->num && !read_raw_relocs (abfd, section, relp->pos, relp->num)) - return FALSE; - - /* Now step through the raw_symbols and add all relocs in them */ - if (!AMIGA_DATA(abfd)->symbols && !amiga_slurp_symbol_table (abfd)) - return FALSE; - - if (asect->hunk_ext_pos == 0) - return TRUE; - - if (bfd_seek (abfd, asect->hunk_ext_pos, SEEK_SET)) - return FALSE; - - for (asp=asect->amiga_symbols; get_long (abfd, &n) && n; asp++) - { - type = (n>>24) & 0xff; - n &= 0xffffff; - - /* skip the name */ - if (bfd_seek (abfd, n<<2, SEEK_CUR)) - return FALSE; - - switch (type) - { - case EXT_SYMB: - case EXT_DEF: - case EXT_ABS: /* no relocs here */ - if (bfd_seek (abfd, 4, SEEK_CUR)) - return FALSE; - break; - - /* same as below, but advance lp by one to skip common size */ - case EXT_DEXT32COMMON: - case EXT_DEXT16COMMON: - case EXT_DEXT8COMMON: - type -= 75; /* convert to EXT_DEXT */ - case EXT_ABSCOMMON: - if (bfd_seek (abfd, 4, SEEK_CUR)) - return FALSE; - /* Fall through */ - default: /* reference to something */ - /* points to num of refs to hunk */ - if (!get_long (abfd, &n)) - return FALSE; - /* Add relocs to this section, relative to asp */ - /* determine howto first */ - if (type==EXT_ABSCOMMON) /* 32 bit ref */ - howto=&howto_table[R_ABS32]; - else if (type==EXT_RELREF32) - howto=&howto_table[R_PC32]; - else if (type==EXT_RELREF26) - howto=&howto_table[R_PC26]; - else - { - type -= EXT_ABSREF32; - if (type) - type--; /* skip EXT_ABSCOMMON gap */ - howto=&howto_table[R_ABS32+type]; - }/* of else */ - for (i=0;ioutsymbols ? - (amiga_symbol_type *) abfd->outsymbols[asp->index] : asp, - howto, -4)) - return FALSE; - } - break; - }/* of switch */ - } - return TRUE; -}/* Of slurp_relocs */ - - -static long -amiga_canonicalize_reloc (abfd, section, relptr, symbols) - bfd *abfd; - sec_ptr section; - arelent **relptr; - asymbol **symbols; -{ - amiga_reloc_type *src; - - if (!section->relocation && !amiga_slurp_relocs (abfd, section, symbols)) - return -1; - - for (src = (amiga_reloc_type *)section->relocation; src; src = src->next) - *relptr++ = &src->relent; - *relptr = NULL; - - return section->reloc_count; -} - - -/* Set section contents */ -/* We do it the following way: - If this is a bss section ==> error - Otherwise, we try to allocate space for this section, - if this has not already been done - Then we set the memory area to the contents */ -static bfd_boolean -amiga_set_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - PTR location; - file_ptr offset; - bfd_size_type count; -{ - if ((section->flags&SEC_HAS_CONTENTS)==0) /* BSS */ - { - bfd_set_error (bfd_error_no_contents); - return FALSE; - } - - if ((section->flags&SEC_IN_MEMORY)==0) /* Not in memory, so alloc space */ - { - section->contents = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size); - if (section->contents == NULL) - return FALSE; - section->flags |= SEC_IN_MEMORY; - DPRINT(5,("Allocated %lx bytes at %lx\n",section->_raw_size,section->contents)); - } - - /* Copy mem */ - memmove(§ion->contents[offset],location,count); - - return TRUE; -}/* Of set_section_contents */ - - -/* FIXME: Is this everything? */ -static bfd_boolean -amiga_set_arch_mach (abfd, arch, machine) - bfd *abfd; - enum bfd_architecture arch; - unsigned long machine; -{ - bfd_default_set_arch_mach(abfd, arch, machine); - if (arch == bfd_arch_m68k) - { - switch (machine) - { - case bfd_mach_m68000: - case bfd_mach_m68008: - case bfd_mach_m68010: - case bfd_mach_m68020: - case bfd_mach_m68030: - case bfd_mach_m68040: - case bfd_mach_m68060: - case 0: - return TRUE; - default: - break; - } - } - return FALSE; -} - -static int -amiga_sizeof_headers (ignore_abfd, ignore) - bfd *ignore_abfd ATTRIBUTE_UNUSED; - bfd_boolean ignore ATTRIBUTE_UNUSED; -{ - /* The amiga hunk format doesn't have headers. */ - return 0; -} - -/* Provided a BFD, a section and an offset into the section, calculate - and return the name of the source file and the line nearest to the - wanted location. */ -bfd_boolean -amiga_find_nearest_line (abfd, section, symbols, offset, filename_ptr, - functionname_ptr, line_ptr) - bfd *abfd ATTRIBUTE_UNUSED; - sec_ptr section ATTRIBUTE_UNUSED; - asymbol **symbols ATTRIBUTE_UNUSED; - bfd_vma offset ATTRIBUTE_UNUSED; - const char **filename_ptr ATTRIBUTE_UNUSED; - const char **functionname_ptr ATTRIBUTE_UNUSED; - unsigned int *line_ptr ATTRIBUTE_UNUSED; -{ - /* FIXME (see aoutx.h, for example) */ - return FALSE; -} - -static reloc_howto_type * -amiga_bfd_reloc_type_lookup (abfd, code) - bfd *abfd ATTRIBUTE_UNUSED; - bfd_reloc_code_real_type code; -{ - DPRINT(5,("reloc: %s (%d)\n",bfd_get_reloc_code_name(code),code)); - switch (code) - { - case BFD_RELOC_8_PCREL: return &howto_table[R_PC8]; - case BFD_RELOC_16_PCREL: return &howto_table[R_PC16]; - case BFD_RELOC_32_PCREL: return &howto_table[R_PC32]; - case BFD_RELOC_8: return &howto_table[R_PC8]; - case BFD_RELOC_16: return &howto_table[R_PC16]; - case BFD_RELOC_32: return &howto_table[R_ABS32]; - case BFD_RELOC_8_BASEREL: return &howto_table[R_SD8]; - case BFD_RELOC_16_BASEREL: return &howto_table[R_SD16]; - case BFD_RELOC_32_BASEREL: return &howto_table[R_SD32]; - case BFD_RELOC_CTOR: return &howto_table[R_ABS32]; - /* FIXME: everything handled? */ - default: return NULL; - } -} - -static bfd_boolean -amiga_bfd_copy_private_bfd_data (ibfd, obfd) - bfd *ibfd; - bfd *obfd; -{ - if (bfd_get_flavour (ibfd) == bfd_target_amiga_flavour - && bfd_get_flavour (obfd) == bfd_target_amiga_flavour) { - AMIGA_DATA(obfd)->IsLoadFile = AMIGA_DATA(ibfd)->IsLoadFile; - } - return TRUE; -} - -static bfd_boolean -amiga_bfd_copy_private_section_data (ibfd, isec, obfd, osec) - bfd *ibfd ATTRIBUTE_UNUSED; - sec_ptr isec; - bfd *obfd ATTRIBUTE_UNUSED; - sec_ptr osec; -{ - if (bfd_get_flavour (osec->owner) == bfd_target_amiga_flavour - && bfd_get_flavour (isec->owner) == bfd_target_amiga_flavour) { - amiga_per_section(osec)->disk_size = amiga_per_section(isec)->disk_size; - amiga_per_section(osec)->attribute = amiga_per_section(isec)->attribute; - } - return TRUE; -} - -/* There is no armap in the amiga libraries, so we fill carsym entries - one by one after having parsed the whole archive. */ -static bfd_boolean -amiga_slurp_armap (abfd) - bfd *abfd; -{ - struct arch_syms *syms; - carsym *defsyms,*csym; - unsigned long symcount; - - /* allocate the carsyms */ - syms = amiga_ardata(abfd)->defsyms; - symcount = amiga_ardata(abfd)->defsym_count; - - defsyms = (carsym *) bfd_alloc (abfd, sizeof (carsym) * symcount); - if (!defsyms) - return FALSE; - - bfd_ardata(abfd)->symdefs = defsyms; - bfd_ardata(abfd)->symdef_count = symcount; - - for (csym = defsyms; syms; syms = syms->next) { - unsigned long type, len, n; - char *symblock; - if (bfd_seek (abfd, syms->offset, SEEK_SET)) - return FALSE; - symblock = (char *) bfd_alloc (abfd, syms->size); - if (!symblock) - return FALSE; - if (bfd_bread (symblock, syms->size, abfd) != syms->size) - return FALSE; - while (n=GL(symblock),n) - { - symblock += 4; - len = n & 0xffffff; - type = (n>>24) & 0xff; - switch (type) { - case EXT_SYMB: - case EXT_DEF: - case EXT_ABS: - len <<= 2; - csym->name = symblock; - csym->name[len] = '\0'; - csym->file_offset = syms->unit_offset; - csym++; - symblock += len+4; /* name+value */ - break; - case EXT_ABSREF32: - case EXT_RELREF16: - case EXT_RELREF8: - case EXT_DEXT32: - case EXT_DEXT16: - case EXT_DEXT8: - case EXT_RELREF32: - case EXT_RELREF26: - symblock += len<<2; - symblock += (1+GL (symblock))<<2; - break; - case EXT_ABSCOMMON: - case EXT_DEXT32COMMON: - case EXT_DEXT16COMMON: - case EXT_DEXT8COMMON: - symblock += (len<<2)+4; - symblock += (1+GL (symblock))<<2; - break; - default: /* error */ - bfd_msg ("unexpected type %ld(0x%lx) in hunk_ext3 at offset 0x%lx", - type, type, bfd_tell (abfd)); - return FALSE; - } - } - } - bfd_has_map (abfd) = TRUE; - return TRUE; -} - -static void -amiga_truncate_arname (abfd, pathname, arhdr) - bfd *abfd ATTRIBUTE_UNUSED; - const char *pathname ATTRIBUTE_UNUSED; - char *arhdr ATTRIBUTE_UNUSED; -{ -} - -static const struct bfd_target * -amiga_archive_p (abfd) - bfd *abfd; -{ - struct arch_syms *symbols=NULL; - struct stat stat_buffer; - symindex symcount=0; - int units; - - if (bfd_stat (abfd, &stat_buffer) < 0) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } - - if (stat_buffer.st_size != 0) - { - /* scan the units */ - if (!parse_archive_units (abfd, &units, stat_buffer.st_size, FALSE, - &symbols, &symcount)) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } - - /* if there is only one unit, file suffix is not .a and .lib, we - consider it an object, not an archive. Obviously it's not - always true but taking objects for archives makes ld fail, - so we don't have much of a choice */ - if (units == 1) - { - char *p = strrchr (abfd->filename, '.'); - if (p == NULL || (strcmp (p, ".a") && strcmp (p, ".lib"))) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } - } - } - - if (abfd->arelt_data) - arelt_size (abfd) = bfd_tell (abfd); - - bfd_seek (abfd, 0, SEEK_SET); - abfd->arch_info = bfd_scan_arch ("m68k:68000"); - - if (amiga_mkarchive (abfd)) - { - bfd_ardata(abfd)->first_file_filepos = 0; - amiga_ardata(abfd)->filesize = stat_buffer.st_size; - amiga_ardata(abfd)->defsyms = symbols; - amiga_ardata(abfd)->defsym_count = symcount; - if (amiga_slurp_armap (abfd)) - return abfd->xvec; - } - - return NULL; -} - -static bfd * -amiga_openr_next_archived_file (archive, last_file) - bfd *archive; - bfd *last_file; -{ - file_ptr filestart; - - if (!last_file) - filestart = bfd_ardata (archive)->first_file_filepos; - else - { - unsigned int size = arelt_size (last_file); - /* Pad to an even boundary... */ - filestart = last_file->origin + size; - filestart += filestart % 2; - } - - return _bfd_get_elt_at_filepos (archive, filestart); -} - -static PTR -amiga_read_ar_hdr (abfd) - bfd *abfd; -{ - struct areltdata *ared; - unsigned long start_pos,len; - char buf[8],*base,*name; - - start_pos = bfd_tell (abfd); - if (start_pos >= amiga_ardata(abfd)->filesize) { - bfd_set_error (bfd_error_no_more_archived_files); - return NULL; - } - - /* get unit type and name length in long words */ - if (bfd_bread (buf, sizeof(buf), abfd) != sizeof(buf)) - return NULL; - - if (GL (&buf[0]) != HUNK_UNIT) { - bfd_set_error (bfd_error_malformed_archive); - return NULL; - } - - ared = bfd_zalloc (abfd, sizeof (struct areltdata)); - if (ared == NULL) - return NULL; - - len = GL (&buf[4]) << 2; - - ared->filename = bfd_alloc (abfd, len+1 > 16 ? len+1 : 16); - if (ared->filename == NULL) - return NULL; - - switch (len) { - default: - if (bfd_bread (ared->filename, len, abfd) != len) - return NULL; - ared->filename[len] = '\0'; - /* strip path part */ - base = strchr (name = ared->filename, ':'); - if (base != NULL) - name = base + 1; - for (base = name; *name; ++name) - if (*name == '/') - base = name + 1; - if (*base != '\0') { - ared->filename = base; - break; - } - /* Fall through */ - case 0: /* fake a name */ - sprintf (ared->filename, "obj-%08lu.o", ++amiga_ardata(abfd)->outnum); - break; - } - - if (bfd_seek (abfd, start_pos+4, SEEK_SET)) - return NULL; - - if (!amiga_read_unit (abfd, amiga_ardata(abfd)->filesize)) - return NULL; - - ared->parsed_size = bfd_tell (abfd) - start_pos; - if (bfd_seek (abfd, start_pos, SEEK_SET)) - return NULL; - - return (PTR) ared; -} - -static int -amiga_generic_stat_arch_elt (abfd, buf) - bfd *abfd; - struct stat *buf; -{ - if (abfd->arelt_data == NULL) - { - bfd_set_error (bfd_error_invalid_operation); - return -1; - } - - /* No header in amiga archives. Let's set reasonable default values */ - buf->st_mode = 0644; - buf->st_uid = 0; - buf->st_gid = 0; - buf->st_mtime = 2922*24*60*60; - buf->st_size = arelt_size (abfd); - - return 0; -} - -/* Entry points through BFD_JUMP_TABLE_GENERIC */ -#define amiga_close_and_cleanup _bfd_generic_close_and_cleanup -#define amiga_bfd_free_cached_info _bfd_generic_bfd_free_cached_info -/* amiga_new_section_hook defined above */ -/* amiga_get_section_contents defined above */ -#define amiga_get_section_contents_in_window _bfd_generic_get_section_contents_in_window - -/* Entry points through BFD_JUMP_TABLE_COPY */ -#define amiga_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -/*#define amiga_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data*/ -#define amiga_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data -#define amiga_bfd_set_private_flags _bfd_generic_bfd_set_private_flags -#define amiga_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data - -/* Entry points through BFD_JUMP_TABLE_ARCHIVE */ -/*#define amiga_slurp_armap bfd_slurp_armap*/ -#define amiga_slurp_extended_name_table _bfd_slurp_extended_name_table -#define amiga_construct_extended_name_table _bfd_archive_bsd_construct_extended_name_table -/*#define amiga_truncate_arname bfd_gnu_truncate_arname*/ -/*#define amiga_write_armap bsd_write_armap*/ -/*#define amiga_read_ar_hdr _bfd_generic_read_ar_hdr*/ -/*#define amiga_openr_next_archived_file bfd_generic_openr_next_archived_file*/ -#define amiga_get_elt_at_index _bfd_generic_get_elt_at_index -/*#define amiga_generic_stat_arch_elt bfd_generic_stat_arch_elt*/ -#define amiga_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp - -/* Entry points through BFD_JUMP_TABLE_SYMBOLS */ -/* amiga_get_symtab_upper_bound defined above */ -/* amiga_get_symtab defined above */ -/* amiga_make_empty_symbol defined above */ -/* amiga_print_symbol defined above */ -/* amiga_get_symbol_info defined above */ -#define amiga_bfd_is_local_label_name bfd_generic_is_local_label_name -#define amiga_get_lineno (alent * (*)(bfd *, asymbol *)) bfd_nullvoidptr -/* amiga_find_nearest_line defined above */ -#define amiga_bfd_make_debug_symbol (asymbol * (*)(bfd *, PTR, unsigned long)) bfd_nullvoidptr -#define amiga_read_minisymbols _bfd_generic_read_minisymbols -#define amiga_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol - -/* Entry points through BFD_JUMP_TABLE_LINK - NOTE: We use a special get_relocated_section_contents both in amiga AND in a.out files. - In addition, we use an own final_link routine, which is nearly identical to _bfd_generic_final_link */ -bfd_byte * -get_relocated_section_contents PARAMS ((bfd *, struct bfd_link_info *, - struct bfd_link_order *, bfd_byte *, bfd_boolean, asymbol **)); -#define amiga_bfd_get_relocated_section_contents get_relocated_section_contents -#define amiga_bfd_relax_section bfd_generic_relax_section -#define amiga_bfd_link_hash_table_create _bfd_generic_link_hash_table_create -#define amiga_bfd_link_hash_table_free _bfd_generic_link_hash_table_free -#define amiga_bfd_link_add_symbols _bfd_generic_link_add_symbols -#define amiga_bfd_link_just_syms _bfd_generic_link_just_syms -bfd_boolean amiga_final_link PARAMS ((bfd *, struct bfd_link_info *)); -#define amiga_bfd_final_link amiga_final_link -#define amiga_bfd_link_split_section _bfd_generic_link_split_section -#define amiga_bfd_gc_sections bfd_generic_gc_sections -#define amiga_bfd_merge_sections bfd_generic_merge_sections -#define amiga_bfd_discard_group bfd_generic_discard_group - -#if defined (amiga) -#undef amiga /* So that the JUMP_TABLE() macros below can work. */ -#endif - -const bfd_target amiga_vec = -{ - "amiga", /* name */ - bfd_target_amiga_flavour, - BFD_ENDIAN_BIG, /* data byte order */ - BFD_ENDIAN_BIG, /* header byte order */ - HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | WP_TEXT, /* object flags */ - SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA, /* section flags */ - '_', /* symbol leading char */ - ' ', /* ar_pad_char */ - 15, /* ar_max_namelen (15 for UNIX compatibility) */ - 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_check_format */ - _bfd_dummy_target, - amiga_object_p, - amiga_archive_p, - _bfd_dummy_target - }, - { - /* bfd_set_format */ - bfd_false, - amiga_mkobject, - amiga_mkarchive, - bfd_false - }, - { - /* bfd_write_contents */ - bfd_false, - amiga_write_object_contents, - amiga_write_archive_contents, - bfd_false - }, - BFD_JUMP_TABLE_GENERIC (amiga), - BFD_JUMP_TABLE_COPY (amiga), - BFD_JUMP_TABLE_CORE (_bfd_nocore), - BFD_JUMP_TABLE_ARCHIVE (amiga), - BFD_JUMP_TABLE_SYMBOLS (amiga), - BFD_JUMP_TABLE_RELOCS (amiga), - BFD_JUMP_TABLE_WRITE (amiga), - BFD_JUMP_TABLE_LINK (amiga), - BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - NULL, - NULL -}; diff --git a/patches/binutils-2.14/bfd/amigaoslink.c b/patches/binutils-2.14/bfd/amigaoslink.c deleted file mode 100644 index 9067a0a..0000000 --- a/patches/binutils-2.14/bfd/amigaoslink.c +++ /dev/null @@ -1,1032 +0,0 @@ -/* BFD back-end for Commodore-Amiga AmigaOS binaries. Linker routines. - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 - Free Software Foundation, Inc. - Contributed by Stephan Thesing. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* -INODE -amigalink, , implementation, amiga -SECTION - amigalink - -This is the description of the linker routines for the amiga. -In fact, this includes a description of the changes made to the -a.out code, in order to build a working linker for the Amiga. -@menu -@* alterations:: -@end menu - -INODE -alterations, , , amigalink -SUBSECTION - alterations - -The file @file{aout-amiga.c} defines the amiga a.out backend. It differs from -the sun3 backend only in these details: - o The @code{final_link} routine is @code{amiga_final_link}. - o The routine to get the relocated section contents is - @code{get_relocated_section_contents}. - -This ensures that the link is performed properly, but has the side effect of -loosing performance. - -The amiga bfd code uses the same functions since they check for the used flavour. -@@* - -The usage of a special linker code has one reason: -The bfd library assumes that a program is always loaded at a known memory -address. This is not a case on an Amiga. So the Amiga format has to take over -some relocs to an executable output file. -This is not the case with a.out formats, so there relocations can be applied at link time, -not at run time, like on the Amiga. -The special routines compensate this: instead of applying the relocations, they are -copied to the output file, if neccessary. -As as consequence, @code{final_link} and @code{get_relocated_section_contents} are nearly identical to -the original routines from @file{linker.c} and @file{reloc.c}. -*/ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "bfdlink.h" -#include "genlink.h" -#include "libamiga.h" - -#define bfd_msg (*_bfd_error_handler) - -/*#define DEBUG_AMIGA 1*/ -#if DEBUG_AMIGA -#include -static void -error_print (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - vfprintf (stderr, fmt, args); - va_end (args); -} -#define DPRINT(L,x) if (L>=DEBUG_AMIGA) error_print x -#else -#define DPRINT(L,x) -#endif - -/* This one is used by the linker and tells us, if a debug hunk should be - written out */ -int write_debug_hunk = 1; - -/* This is also used by the linker to set the attribute of sections */ -int amiga_attribute = 0; - -/* This one is used to indicate base-relative linking */ -int amiga_base_relative = 0; - -/* This one is used to indicate -resident linking */ -int amiga_resident = 0; - -bfd_boolean -default_indirect_link_order PARAMS ((bfd *, struct bfd_link_info *, - asection *, struct bfd_link_order *, bfd_boolean)); -bfd_byte * -get_relocated_section_contents PARAMS ((bfd *, struct bfd_link_info *, - struct bfd_link_order *, bfd_byte *, bfd_boolean, asymbol **)); -bfd_boolean -amiga_final_link PARAMS ((bfd *, struct bfd_link_info *)); -bfd_boolean -aout_amiga_final_link PARAMS ((bfd *, struct bfd_link_info *)); - -static bfd_reloc_status_type -my_add_to PARAMS ((arelent *, PTR, int, int)); -static bfd_reloc_status_type -amiga_perform_reloc PARAMS ((bfd *, arelent *, PTR, sec_ptr, bfd *, char **)); -static bfd_reloc_status_type -aout_perform_reloc PARAMS ((bfd *, arelent *, PTR, sec_ptr, bfd *, char **)); -static bfd_boolean -amiga_reloc_link_order PARAMS ((bfd *, struct bfd_link_info *, asection *, - struct bfd_link_order *)); - -enum { ADDEND_UNSIGNED=0x01, RELOC_SIGNED=0x02 }; - - -/* This one is nearly identical to bfd_generic_get_relocated_section_contents - in reloc.c */ -bfd_byte * -get_relocated_section_contents (abfd, link_info, link_order, data, - relocateable, symbols) - bfd *abfd; - struct bfd_link_info *link_info; - struct bfd_link_order *link_order; - bfd_byte *data; - bfd_boolean relocateable; - asymbol **symbols; -{ - /* Get enough memory to hold the stuff. */ - bfd *input_bfd = link_order->u.indirect.section->owner; - asection *input_section = link_order->u.indirect.section; - - long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); - arelent **reloc_vector = NULL; - long reloc_count; - bfd_reloc_status_type (*reloc_func)(bfd *, arelent *, PTR, sec_ptr, - bfd *, char **); - - DPRINT(5,("Entering get_rel_sec_cont\n")); - - if (reloc_size < 0) - goto error_return; - - if (bfd_get_flavour (input_bfd) == bfd_target_amiga_flavour) - reloc_func = amiga_perform_reloc; - else if (bfd_get_flavour (input_bfd) == bfd_target_aout_flavour) - reloc_func = aout_perform_reloc; - else - { - bfd_set_error (bfd_error_bad_value); - goto error_return; - } - - reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); - if (reloc_vector == NULL && reloc_size != 0) - goto error_return; - - DPRINT(5,("GRSC: GetSecCont()\n")); - /* Read in the section. */ - if (!bfd_get_section_contents (input_bfd, - input_section, - (PTR) data, - (bfd_vma) 0, - input_section->_raw_size)) - goto error_return; - - /* We're not relaxing the section, so just copy the size info. */ - input_section->_cooked_size = input_section->_raw_size; - input_section->reloc_done = TRUE; - - DPRINT(5,("GRSC: CanReloc\n")); - reloc_count = bfd_canonicalize_reloc (input_bfd, - input_section, - reloc_vector, - symbols); - if (reloc_count < 0) - goto error_return; - - if (reloc_count > 0) - { - arelent **parent; - - DPRINT(5,("reloc_count=%ld\n",reloc_count)); - - for (parent = reloc_vector; *parent != (arelent *) NULL; - parent++) - { - char *error_message = (char *) NULL; - bfd_reloc_status_type r; - - DPRINT(5,("Applying a reloc\nparent=%lx, reloc_vector=%lx, " - "*parent=%lx\n",parent,reloc_vector,*parent)); - r=(*reloc_func) (input_bfd, - *parent, - (PTR) data, - input_section, - relocateable ? abfd : (bfd *) NULL, - &error_message); - if (relocateable) - { - asection *os = input_section->output_section; - - DPRINT(5,("Keeping reloc\n")); - /* A partial link, so keep the relocs. */ - os->orelocation[os->reloc_count] = *parent; - os->reloc_count++; - } - - if (r != bfd_reloc_ok) - { - switch (r) - { - case bfd_reloc_undefined: - if (!((*link_info->callbacks->undefined_symbol) - (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), - input_bfd, input_section, (*parent)->address, - TRUE))) - goto error_return; - break; - case bfd_reloc_dangerous: - BFD_ASSERT (error_message != (char *) NULL); - if (!((*link_info->callbacks->reloc_dangerous) - (link_info, error_message, input_bfd, input_section, - (*parent)->address))) - goto error_return; - break; - case bfd_reloc_overflow: - if (!((*link_info->callbacks->reloc_overflow) - (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), - (*parent)->howto->name, (*parent)->addend, - input_bfd, input_section, (*parent)->address))) - goto error_return; - break; - case bfd_reloc_outofrange: - default: - DPRINT(10,("get_rel_sec_cont fails, perform reloc " - "returned $%x\n",r)); - abort (); - break; - } - - } - } - } - if (reloc_vector != NULL) - free (reloc_vector); - DPRINT(5,("GRSC: Returning ok\n")); - return data; - -error_return: - DPRINT(5,("GRSC: Error_return\n")); - if (reloc_vector != NULL) - free (reloc_vector); - return NULL; -} - - -/* Add a value to a location */ -static bfd_reloc_status_type -my_add_to (r, data, add, flags) - arelent *r; - PTR data; - int add, flags; -{ - bfd_reloc_status_type ret=bfd_reloc_ok; - bfd_byte *p=((bfd_byte *)data)+r->address; - int val; - - DPRINT(5,("Entering add_value\n")); - - switch (r->howto->size) - { - case 0: /* byte size */ - if ((flags & ADDEND_UNSIGNED) == 0) - val = ((*p & 0xff) ^ 0x80) - 0x80 + add; - else - val = (*p & 0xff) + add; - /* check for overflow */ - if ((flags & RELOC_SIGNED) != 0) { - if (val<-0x80 || val>0x7f) - ret = bfd_reloc_overflow; - } - else { - if ((val&0xffffff00)!=0 && (val&0xffffff00)!=0xffffff00) - ret=bfd_reloc_overflow; - } - /* set the value */ - *p = val & 0xff; - break; - - case 1: /* word size */ - if ((flags & ADDEND_UNSIGNED) == 0) - val = bfd_getb_signed_16 (p) + add; - else - val = bfd_getb16 (p) + add; - /* check for overflow */ - if ((flags & RELOC_SIGNED) != 0) { - if (val<-0x8000 || val>0x7fff) - ret = bfd_reloc_overflow; - } - else { - if ((val&0xffff0000)!=0 && (val&0xffff0000)!=0xffff0000) - ret=bfd_reloc_overflow; - } - /* set the value */ - bfd_putb16 (val, p); - break; - - case 2: /* long word */ - val = bfd_getb_signed_32 (p) + add; - /* If we are linking a resident program, then we limit the reloc size - to about +/- 1 GB. - - When linking a shared library all variables defined in other - libraries are placed in memory >0x80000000, so if the library - tries to use one of those variables an error is output. - - Without this it would be much more difficult to check for - incorrect references. */ - if (amiga_resident && - (val & 0xc0000000)!=0 && (val&0xc0000000)!=0xc0000000) /* Overflow */ - { - ret=bfd_reloc_overflow; - } - bfd_putb32 (val, p); - break; - - default: /* Error */ - ret=bfd_reloc_notsupported; - break; - }/* Of switch */ - - DPRINT(5,("Leaving add_value\n")); - return ret; -} - - -/* Perform an Amiga relocation */ -static bfd_reloc_status_type -amiga_perform_reloc (abfd, r, data, sec, obfd, error_message) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *r; - PTR data; - sec_ptr sec; - bfd *obfd; - char **error_message ATTRIBUTE_UNUSED; -{ - asymbol *sym; /* Reloc is relative to sym */ - sec_ptr target_section; /* reloc is relative to this section */ - bfd_reloc_status_type ret; - bfd_boolean copy; - int relocation,flags; - - DPRINT(5,("Entering APR\nflavour is %d (amiga_flavour=%d, aout_flavour=%d)\n", - bfd_get_flavour (sec->owner), bfd_target_amiga_flavour, - bfd_target_aout_flavour)); - - /* If obfd==NULL: Apply the reloc, if possible. */ - /* Else: Modify it and return */ - - if (obfd!=NULL) /* Only modify the reloc */ - { - r->address+=sec->output_offset; - sec->output_section->flags|=SEC_RELOC; - DPRINT(5,("Leaving amiga_perf_reloc, modified\n")); - return bfd_reloc_ok; - } - - /* Try to apply the reloc */ - - sym=*(r->sym_ptr_ptr); - - /* FIXME: XXX */ - if (0 && sym->udata.p) - sym = ((struct generic_link_hash_entry *) sym->udata.p)->sym; - - target_section=sym->section; - - if (bfd_is_und_section(target_section)) /* Error */ - { - DPRINT(10,("amiga_perf_reloc: target_sec==UND\n")); - return bfd_reloc_undefined; - } - - relocation=0; flags=RELOC_SIGNED; copy=FALSE; ret=bfd_reloc_ok; - - DPRINT(5,("%s: size=%u\n",r->howto->name,bfd_get_reloc_size(r->howto))); - switch (r->howto->type) - { - case H_ABS32: - if (bfd_is_abs_section(target_section)) /* Ref to absolute hunk */ - relocation=sym->value; - else if (bfd_is_com_section(target_section)) /* ref to common */ - { - relocation=0; - copy=TRUE; - } - else - { - /* If we access a symbol in the .bss section, we have to convert - this to an access to .data section */ - /* This is done through a change to the output section of - the symbol.. */ - if (amiga_base_relative - && !strcmp(target_section->output_section->name,".bss")) - { - /* get value for .data section */ - bfd *ibfd; - sec_ptr s; - - ibfd=target_section->output_section->owner; - for (s=ibfd->sections;s!=NULL;s=s->next) - if (!strcmp(s->name,".data")) - { - target_section->output_offset=s->_raw_size; - target_section->output_section=s; - } - } - relocation=0; - copy=TRUE; - } - break; - - case H_PC8: /* pcrel */ - case H_PC16: - case H_PC32: - if (bfd_is_abs_section(target_section)) /* Ref to absolute hunk */ - relocation=sym->value; - else if (bfd_is_com_section(target_section)) /* Error.. */ - { - ret=bfd_reloc_undefined; - } - else if (sec->output_section!=target_section->output_section) /* Error */ - { - DPRINT(5,("pc relative, but out-of-range\n")); - ret=bfd_reloc_outofrange; - } - else /* Same section */ - { - DPRINT(5,("PC relative\n")); - relocation = sym->value + target_section->output_offset - - (r->address + sec->output_offset); - } - break; - - case H_SD8: /* baserel */ - case H_SD16: - case H_SD32: - /* Relocs are always relative to the symbol ___a4_init */ - /* Relocs to .bss section are converted to a reloc to .data section, - since .bss section contains only COMMON sections...... and should - be following .data section.. */ - if (bfd_is_abs_section(target_section)) - relocation=sym->value; - else if (!AMIGA_DATA(target_section->output_section->owner)->baserel) - { - bfd_msg ("Base symbol for base relative reloc not defined: " - "section %s, reloc to symbol %s",sec->name,sym->name); - ret=bfd_reloc_notsupported; - } - else if ((target_section->flags&SEC_CODE)!=0) - { - bfd_msg ("%s: baserelative text relocation to \"%s\"", - abfd->filename, sym->name); - ret=bfd_reloc_notsupported; - } - else - { - /* If target->out is .bss, add the value of the .data section to - sym->value and set new output_section */ - if (!strcmp(target_section->output_section->name,".bss")) - { - bfd *ibfd; - sec_ptr s; - - ibfd=target_section->output_section->owner; - for (s=ibfd->sections;s!=NULL;s=s->next) - if (!strcmp(s->name,".data")) - { - target_section->output_offset=s->_raw_size; - target_section->output_section=s; - } - } - - relocation = sym->value + target_section->output_offset - - (AMIGA_DATA(target_section->output_section->owner))->a4init - + r->addend; - flags|=ADDEND_UNSIGNED; - } - break; - - default: - bfd_msg ("Error: unsupported reloc: %s(%d)",r->howto->name,r->howto->size); - ret=bfd_reloc_notsupported; - break; - }/* Of switch */ - - /* Add in relocation */ - if (relocation!=0) - ret = my_add_to (r, data, relocation, flags); - - if (copy) /* Copy reloc to output section */ - { - DPRINT(5,("Copying reloc\n")); - target_section=sec->output_section; - r->address+=sec->output_offset; - target_section->orelocation[target_section->reloc_count++]=r; - target_section->flags|=SEC_RELOC; - } - DPRINT(5,("Leaving amiga_perf_reloc with %d (OK=%d)\n",ret,bfd_reloc_ok)); - return ret; -} - - -/* Perform an a.out relocation */ -static bfd_reloc_status_type -aout_perform_reloc (abfd, r, data, sec, obfd, error_message) - bfd *abfd; - arelent *r; - PTR data; - sec_ptr sec; - bfd *obfd; - char **error_message ATTRIBUTE_UNUSED; -{ - asymbol *sym; /* Reloc is relative to sym */ - sec_ptr target_section; /* reloc is relative to this section */ - bfd_reloc_status_type ret; - bfd_boolean copy; - int relocation,flags; - - DPRINT(5,("Entering aout_perf_reloc\n")); - - /* If obfd==NULL: Apply the reloc, if possible. */ - /* Else: Modify it and return */ - - if (obfd!=NULL) /* Only modify the reloc */ - { - r->address+=sec->output_offset; - DPRINT(5,("Leaving aout_perf_reloc, modified\n")); - return bfd_reloc_ok; - } - - /* Try to apply the reloc */ - - sym=*(r->sym_ptr_ptr); - target_section=sym->section; - - if (bfd_is_und_section(target_section)) /* Error */ - { - if ((sym->flags & BSF_WEAK) == 0) - { - DPRINT(10,("aout_perf_reloc: target_sec==UND\n")); - return bfd_reloc_undefined; - } - target_section=bfd_abs_section_ptr; - } - - relocation=0; flags=RELOC_SIGNED; copy=FALSE; ret=bfd_reloc_ok; - - DPRINT(10,("RELOC: %s: size=%u\n",r->howto->name,bfd_get_reloc_size(r->howto))); - switch (r->howto->type) - { - case H_ABS8: /* 8/16 bit reloc, pc relative or absolute */ - case H_ABS16: - if (bfd_is_abs_section(target_section)) /* Ref to absolute hunk */ - relocation=sym->value; - else if (bfd_is_com_section(target_section)) /* Error.. */ - { - bfd_msg ("pc relative relocation to common symbol \"%s\" in " - "section %s",sym->name,sec->name); - DPRINT(10,("Ref to common symbol...aout_perf_reloc\n")); - ret=bfd_reloc_undefined; - } - else if (sec->output_section!=target_section->output_section) - { - if ((target_section->output_section->flags&SEC_DATA)!=0) - goto baserel; /* Dirty, but no code duplication.. */ - bfd_msg ("pc relative relocation out-of-range in section %s. " - "Relocation was to symbol %s",sec->name,sym->name); - DPRINT(10,("Section %s, target %s: Reloc out-of-range...not same " - "section, aout_perf\nsec->out=%s, target->out=%s, " - "offset=%lx\n",sec->name,target_section->name, - sec->output_section->name, - target_section->output_section->name,r->address)); - ret=bfd_reloc_outofrange; - } - else - { - /* Same section, this is a pc relative hunk... */ - DPRINT(5,("Reloc to same section...\n")); - relocation=-(r->address+sec->output_offset); - } - break; - - case H_ABS32: /* 32 bit reloc, pc relative or absolute */ - if (bfd_is_abs_section(target_section)) /* Ref to absolute hunk */ - relocation=sym->value; - else if (bfd_is_com_section(target_section)) /* ref to common */ - { - relocation=0; - copy=TRUE; - } - else - { - /* If we access a symbol in the .bss section, we have to convert - this to an access to .data section */ - /* This is done through a change to the output section of - the symbol.. */ - if (amiga_base_relative - && !strcmp(target_section->output_section->name,".bss")) - { - /* get value for .data section */ - bfd *ibfd; - sec_ptr s; - - ibfd=target_section->output_section->owner; - for (s=ibfd->sections;s!=NULL;s=s->next) - if (!strcmp(s->name,".data")) - { - target_section->output_offset+=s->_raw_size; - target_section->output_section=s; - } - } - relocation=0; - copy=TRUE; - } - DPRINT(10,("target->out=%s(%lx), sec->out=%s(%lx), symbol=%s\n", - target_section->output_section->name, - target_section->output_section,sec->output_section->name, - sec->output_section,sym->name)); - break; - - case H_PC8: /* pcrel */ - case H_PC16: - case H_PC32: - if (bfd_is_abs_section(target_section)) /* Ref to absolute hunk */ - relocation=sym->value; - else - { - relocation = sym->value + target_section->output_offset - - sec->output_offset; - } - break; - - case H_SD16: /* baserel */ - case H_SD32: - baserel: - /* We use the symbol ___a4_init as base */ - if (bfd_is_abs_section(target_section)) - relocation=sym->value; - else if (bfd_is_com_section(target_section)) /* Error.. */ - { - bfd_msg ("baserelative relocation to common \"%s\"",sym->name); - DPRINT(10,("Ref to common symbol...aout_perf_reloc\n")); - ret=bfd_reloc_undefined; - } - else if (!AMIGA_DATA(target_section->output_section->owner)->baserel) - { - bfd_msg ("Base symbol for base relative reloc not defined: " - "section %s, reloc to symbol %s",sec->name,sym->name); - ret=bfd_reloc_notsupported; - } - else if ((target_section->flags&SEC_CODE)!=0) - { - bfd_msg ("%s: baserelative text relocation to \"%s\"", - abfd->filename, sym->name); - ret=bfd_reloc_notsupported; - } - else /* Target section and sec need not be the same.. */ - { - /* If target->out is .bss, add the value of the .data section to - sym->value and set new output_section */ - if (!strcmp(target_section->output_section->name,".bss")) - { - bfd *ibfd; - sec_ptr s; - - ibfd=target_section->output_section->owner; - for (s=ibfd->sections;s!=NULL;s=s->next) - if (!strcmp(s->name,".data")) - { - target_section->output_offset+=s->_raw_size; - target_section->output_section=s; - } - } - - relocation = sym->value + target_section->output_offset - - (AMIGA_DATA(target_section->output_section->owner))->a4init; - /* if the symbol is in .bss, subtract the offset that gas has put - into the opcode */ - if (target_section->index == 2) - relocation -= adata(abfd).datasec->_raw_size; - DPRINT(20,("symbol=%s (0x%lx)\nsection %s (0x%lx; %s; output=0x%lx)" - "\nrelocation @0x%lx\n", sym->name, sym->value, - target_section->name, target_section, - target_section->owner->filename, target_section->output_offset, - r->address)); - flags|=ADDEND_UNSIGNED; - } - DPRINT(10,("target->out=%s(%lx), sec->out=%s(%lx), symbol=%s\n", - target_section->output_section->name, - target_section->output_section,sec->output_section->name, - sec->output_section,sym->name)); - break; - - default: - bfd_msg ("Error: unsupported reloc: %s(%d)",r->howto->name,r->howto->size); - ret=bfd_reloc_notsupported; - break; - }/* Of switch */ - - /* Add in relocation */ - if (relocation!=0) - ret = my_add_to (r, data, relocation, flags); - - if (copy) /* Copy reloc to output section */ - { - DPRINT(5,("Copying reloc\n")); - target_section=sec->output_section; - r->address+=sec->output_offset; - target_section->orelocation[target_section->reloc_count++]=r; - } - DPRINT(5,("Leaving aout_perf_reloc with %d (OK=%d)\n",ret,bfd_reloc_ok)); - return ret; -} - - -/* The final link routine, used both by Amiga and a.out backend */ -/* This is nearly a copy of linker.c/_bfd_generic_final_link */ -bfd_boolean -amiga_final_link (abfd, info) - bfd *abfd; - struct bfd_link_info *info; -{ - bfd *sub; - asection *o; - struct bfd_link_order *p; - size_t outsymalloc; - struct generic_write_global_symbol_info wginfo; - struct bfd_link_hash_entry *h = - bfd_link_hash_lookup (info->hash, "___a4_init", FALSE, FALSE, TRUE); - - if (amiga_base_relative && h && h->type == bfd_link_hash_defined) { - AMIGA_DATA(abfd)->baserel = TRUE; - AMIGA_DATA(abfd)->a4init = h->u.def.value; - } - else - AMIGA_DATA(abfd)->baserel = FALSE; - - DPRINT(5,("Entering final_link\n")); - - if (bfd_get_flavour (abfd) == bfd_target_aout_flavour) - return aout_amiga_final_link (abfd, info); - - bfd_get_outsymbols (abfd) = (asymbol **) NULL; - bfd_get_symcount (abfd) = 0; - outsymalloc = 0; - - /* Mark all sections which will be included in the output file. */ - for (o = abfd->sections; o != NULL; o = o->next) - for (p = o->link_order_head; p != NULL; p = p->next) - if (p->type == bfd_indirect_link_order) - p->u.indirect.section->linker_mark = TRUE; - - /* Build the output symbol table. */ - for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next) - if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc)) - return FALSE; - - DPRINT(10,("Did build output symbol table\n")); - - /* Accumulate the global symbols. */ - wginfo.info = info; - wginfo.output_bfd = abfd; - wginfo.psymalloc = &outsymalloc; - _bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info), - _bfd_generic_link_write_global_symbol, - (PTR) &wginfo); - - DPRINT(10,("Accumulated global symbols\n")); - - DPRINT(10,("Output bfd is %s(%lx)\n",abfd->filename,abfd)); - - if (1) - { - /* Allocate space for the output relocs for each section. */ - /* We also handle base-relative linking special, by setting the .data - sections real length to it's length + .bss length */ - /* This is different to bfd_generic_final_link: We ALWAYS alloc space - for the relocs, because we may need it anyway */ - for (o = abfd->sections; - o != (asection *) NULL; - o = o->next) - { - /* If section is .data, find .bss and add that length */ - if (!info->relocateable && amiga_base_relative && - !strcmp(o->name,".data")) - { - if (bfd_get_flavour(abfd)!=bfd_target_amiga_flavour) /* oops */ - { - bfd_msg ("You can't use base relative linking with " - "partial links."); - } - else if (0) /* XXX */ - { - asection *act_sec; - for (act_sec=abfd->sections; act_sec!=NULL;act_sec=act_sec->next) - if (!strcmp(act_sec->name,".bss")) - amiga_per_section(o)->disk_size = o->_raw_size + - act_sec->_raw_size; - } - }/* Of base-relative linking */ - - DPRINT(10,("Section in output bfd is %s (%lx)\n",o->name,o)); - - o->reloc_count = 0; - for (p = o->link_order_head; - p != (struct bfd_link_order *) NULL; - p = p->next) - { - if (p->type == bfd_section_reloc_link_order - || p->type == bfd_symbol_reloc_link_order) - ++o->reloc_count; - else if (p->type == bfd_indirect_link_order) - { - asection *input_section; - bfd *input_bfd; - long relsize; - arelent **relocs; - asymbol **symbols; - long reloc_count; - - input_section = p->u.indirect.section; - input_bfd = input_section->owner; - - DPRINT(10,("\tIndirect section from bfd %s, section is %s(%lx) " - "(COM=%lx)\n", - input_bfd->filename,input_section->name,input_section, - bfd_com_section_ptr)); - - relsize = bfd_get_reloc_upper_bound (input_bfd, - input_section); - if (relsize < 0) - { - DPRINT(10,("Relsize<0.I..in bfd %s, sec %s\n", - input_bfd->filename, input_section->name)); - return FALSE; - } - relocs = (arelent **) bfd_malloc ((bfd_size_type) relsize); - if (!relocs && relsize != 0) - return FALSE; - symbols = _bfd_generic_link_get_symbols (input_bfd); - reloc_count = bfd_canonicalize_reloc (input_bfd, - input_section, - relocs, - symbols); - free (relocs); - if (reloc_count < 0) - { - DPRINT(10,("Relsize<0.II..in bfd %s, sec %s\n", - input_bfd->filename, input_section->name)); - return FALSE; - } - BFD_ASSERT ((unsigned long) reloc_count - == input_section->reloc_count); - o->reloc_count += reloc_count; - } - } - if (o->reloc_count > 0) - { - bfd_size_type amt; - - amt = o->reloc_count; - amt *= sizeof (arelent *); - o->orelocation = (arelent **) bfd_alloc (abfd, amt); - if (!o->orelocation) - return FALSE; - /* o->flags |= SEC_RELOC; There may be no relocs. This can - be determined later only */ - /* Reset the count so that it can be used as an index - when putting in the output relocs. */ - o->reloc_count = 0; - } - } - } - - DPRINT(10,("Got all relocs\n")); - - /* Handle all the link order information for the sections. */ - for (o = abfd->sections; - o != (asection *) NULL; - o = o->next) - { - for (p = o->link_order_head; - p != (struct bfd_link_order *) NULL; - p = p->next) - { - switch (p->type) - { - case bfd_section_reloc_link_order: - case bfd_symbol_reloc_link_order: - if (! amiga_reloc_link_order (abfd, info, o, p)) /* We use an own routine */ - return FALSE; - break; - case bfd_indirect_link_order: - if (! default_indirect_link_order (abfd, info, o, p, FALSE)) - /* Calls our get_relocated_section_contents */ - return FALSE; - break; - default: - if (! _bfd_default_link_order (abfd, info, o, p)) - return FALSE; - break; - } - } - } - - if (bfd_get_flavour(abfd)==bfd_target_amiga_flavour&&!info->relocateable) - AMIGA_DATA(abfd)->IsLoadFile = TRUE; - - DPRINT(10,("Leaving final_link\n")); - return TRUE; -} - - -/* Handle reloc link order. - This is nearly a copy of linker.c/_bfd_generic_reloc_link_order */ -static bfd_boolean -amiga_reloc_link_order (abfd, info, sec, link_order) - bfd *abfd; - struct bfd_link_info *info; - asection *sec; - struct bfd_link_order *link_order; -{ - arelent *r; - - DPRINT(5,("Entering amiga_reloc_link_order\n")); - - if (sec->orelocation == (arelent **) NULL) - { - DPRINT(10,("aborting, since orelocation==NULL\n")); - abort (); - } - - /* We generate a new ***AMIGA*** style reloc */ - r = (arelent *) bfd_zalloc (abfd, (bfd_size_type) sizeof (amiga_reloc_type)); - if (r == (arelent *) NULL) - { - DPRINT(5,("Leaving amiga_reloc_link, no mem\n")); - return FALSE; - } - - r->address = link_order->offset; - r->howto = bfd_reloc_type_lookup (abfd, link_order->u.reloc.p->reloc); - if (r->howto == 0) - { - bfd_set_error (bfd_error_bad_value); - DPRINT(5,("Leaving amiga_reloc_link, bad value\n")); - return FALSE; - } - - /* Get the symbol to use for the relocation. */ - if (link_order->type == bfd_section_reloc_link_order) - r->sym_ptr_ptr = link_order->u.reloc.p->u.section->symbol_ptr_ptr; - else - { - struct generic_link_hash_entry *h; - - h = ((struct generic_link_hash_entry *) - bfd_wrapped_link_hash_lookup (abfd, info, - link_order->u.reloc.p->u.name, - FALSE, FALSE, TRUE)); - if (h == (struct generic_link_hash_entry *) NULL - || ! h->written) - { - if (! ((*info->callbacks->unattached_reloc) - (info, link_order->u.reloc.p->u.name, - (bfd *) NULL, (asection *) NULL, (bfd_vma) 0))) - return FALSE; - bfd_set_error (bfd_error_bad_value); - DPRINT(5,("Leaving amiga_reloc_link, bad value in hash lookup\n")); - return FALSE; - } - r->sym_ptr_ptr = &h->sym; - } - DPRINT(5,("Got symbol for relocation\n")); - /* Store the addend */ - r->addend = link_order->u.reloc.p->addend; - - /* If we are generating relocateable output, just add the reloc */ - if (info->relocateable) - { - DPRINT(5,("Adding reloc\n")); - sec->orelocation[sec->reloc_count] = r; - ++sec->reloc_count; - sec->flags|=SEC_RELOC; - } - else /* Try to apply the reloc */ - { - PTR data=(PTR)sec->contents; - bfd_reloc_status_type ret; - char *em=NULL; - - DPRINT(5,("Apply link_order_reloc\n")); - - /* FIXME: Maybe, we have to get the section contents, before we - use them, if they have not been set by now.. */ - BFD_ASSERT (data!=NULL); - - if (bfd_get_flavour(abfd)==bfd_target_amiga_flavour) - ret=amiga_perform_reloc(abfd,r,data,sec,NULL,&em); - else - ret=aout_perform_reloc(abfd,r,data,sec,NULL,&em); - - if (ret!=bfd_reloc_ok) - { - DPRINT(5,("Leaving amiga_reloc_link, value FALSE\n")); - return FALSE; - } - } - DPRINT(5,("Leaving amiga_reloc_link\n")); - return TRUE; -} diff --git a/patches/binutils-2.14/bfd/aout-amiga.c b/patches/binutils-2.14/bfd/aout-amiga.c deleted file mode 100644 index ced7584..0000000 --- a/patches/binutils-2.14/bfd/aout-amiga.c +++ /dev/null @@ -1,152 +0,0 @@ -/* BFD back-end for Amiga style m68k a.out binaries. - Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. - Contributed by Stephan Thesing. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGETNAME "a.out-amiga" -#define MACHTYPE_OK(m) ((m)==M_UNKNOWN || (m)==M_68010 || (m)==M_68020) -#define TARGET_IS_BIG_ENDIAN_P -#define TARGET_PAGE_SIZE 0x2000 -#define N_HEADER_IN_TEXT(x) 0 -#define N_SHARED_LIB(x) 0 -#define TEXT_START_ADDR 0 - -/* Do not "beautify" the CONCAT* macro args. Traditional C will not - remove whitespace added here, and thus will fail to concatenate - the tokens. */ -#define MY(OP) CONCAT2 (aout_amiga_,OP) - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "libaout.h" -#include "aout/aout64.h" - -bfd_boolean -MY(final_link) PARAMS ((bfd *, struct bfd_link_info *)); - -bfd_boolean -amiga_final_link PARAMS ((bfd *, struct bfd_link_info *)); -#define MY_bfd_final_link amiga_final_link - -bfd_byte * -get_relocated_section_contents PARAMS ((bfd *, struct bfd_link_info *, - struct bfd_link_order *, bfd_byte *, bfd_boolean, asymbol **)); -#define MY_bfd_get_relocated_section_contents get_relocated_section_contents - -static unsigned long MY(get_mach) PARAMS ((enum machine_type)); -static bfd_boolean MY(write_object_contents) PARAMS ((bfd *)); -static bfd_boolean MY(set_sizes) PARAMS ((bfd *)); -static bfd_boolean MY(link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); -#define MY_bfd_link_add_symbols aout_amiga_link_add_symbols - -static unsigned long -MY(get_mach) (machtype) - enum machine_type machtype; -{ - unsigned long machine; - switch (machtype) - { - default: - case M_UNKNOWN: - /* Some Sun3s make magic numbers without cpu types in them, so - we'll default to the 68000. */ - machine = bfd_mach_m68000; - break; - - case M_68010: - machine = bfd_mach_m68010; - break; - - case M_68020: - machine = bfd_mach_m68020; - break; - } - return machine; -} -#define SET_ARCH_MACH(ABFD, EXEC) \ - bfd_set_arch_mach (ABFD, bfd_arch_m68k, MY(get_mach) (N_MACHTYPE (EXEC))) - -static bfd_boolean -MY(write_object_contents) (abfd) - bfd *abfd; -{ - struct external_exec exec_bytes; - struct internal_exec *execp = exec_hdr (abfd); - - /* Magic number, maestro, please! */ - switch (bfd_get_arch (abfd)) - { - case bfd_arch_m68k: - switch (bfd_get_mach (abfd)) - { - case bfd_mach_m68000: - N_SET_MACHTYPE (*execp, M_UNKNOWN); - break; - case bfd_mach_m68010: - N_SET_MACHTYPE (*execp, M_68010); - break; - default: - case bfd_mach_m68020: - N_SET_MACHTYPE (*execp, M_68020); - break; - } - break; - default: - N_SET_MACHTYPE (*execp, M_UNKNOWN); - } - - WRITE_HEADERS (abfd, execp); - - return TRUE; -} -#define MY_write_object_contents MY(write_object_contents) - -static bfd_boolean -MY(set_sizes) (abfd) - bfd *abfd; -{ - adata (abfd).page_size = TARGET_PAGE_SIZE; - adata (abfd).segment_size = TARGET_PAGE_SIZE; - adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; - return TRUE; -} -#define MY_set_sizes MY(set_sizes) - -/* Include the usual a.out support. */ -#include "aout-target.h" - -/* Add symbols from an object file to the global hash table. */ -static bfd_boolean -MY(link_add_symbols) (abfd, info) - bfd *abfd; - struct bfd_link_info *info; -{ - if (info->hash->creator->flavour == bfd_target_amiga_flavour) - return _bfd_generic_link_add_symbols (abfd, info); - return NAME(aout,link_add_symbols) (abfd, info); -} - -/* Public final_link routine. */ -bfd_boolean -MY(final_link) (abfd, info) - bfd *abfd; - struct bfd_link_info *info; -{ - return NAME(aout,final_link) (abfd, info, MY_final_link_callback); -} diff --git a/patches/binutils-2.14/bfd/aoutx.h.diff b/patches/binutils-2.14/bfd/aoutx.h.diff deleted file mode 100644 index 3c38d21..0000000 --- a/patches/binutils-2.14/bfd/aoutx.h.diff +++ /dev/null @@ -1,61 +0,0 @@ ---- binutils-2.14/bfd/aoutx.h 2003-03-31 20:13:24.000000000 +0200 -+++ binutils-2.14-patched/bfd/aoutx.h 2013-04-24 18:38:23.000000000 +0200 -@@ -133,7 +133,8 @@ - PARAMS ((bfd *)); - static bfd_boolean translate_from_native_sym_flags - PARAMS ((bfd *, aout_symbol_type *)); --static bfd_boolean translate_to_native_sym_flags -+/*Amiga hack - used in amigaos.c, must be global */ -+/*static*/ bfd_boolean translate_to_native_sym_flags - PARAMS ((bfd *, asymbol *, struct external_nlist *)); - static void adjust_o_magic - PARAMS ((bfd *, struct internal_exec *)); -@@ -1657,7 +1658,7 @@ - - /* Set the fields of SYM_POINTER according to CACHE_PTR. */ - --static bfd_boolean -+/*static*/ bfd_boolean - translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer) - bfd *abfd; - asymbol *cache_ptr; -@@ -2067,10 +2068,26 @@ - - r_length = g->howto->size ; /* Size as a power of two. */ - r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ -+#if 1 -+ /* FIXME! "#if 1" is the wrong way to select this Amiga specific code. */ -+ switch (bfd_asymbol_flavour(sym)) -+ { -+ case bfd_target_amiga_flavour: -+ case bfd_target_aout_flavour: -+ r_baserel = (g->howto->type & 8) != 0; -+ r_jmptable = (g->howto->type & 16) != 0; -+ r_relative = (g->howto->type & 32) != 0; -+ break; -+ default: -+ r_baserel=r_jmptable=r_relative=0; -+ break; -+ } -+#else - /* XXX This relies on relocs coming from a.out files. */ - r_baserel = (g->howto->type & 8) != 0; - r_jmptable = (g->howto->type & 16) != 0; - r_relative = (g->howto->type & 32) != 0; -+#endif - - #if 0 - /* For a standard reloc, the addend is in the object file. */ -@@ -2369,8 +2386,12 @@ - /* Base relative relocs are always against the symbol table, - regardless of the setting of r_extern. r_extern just reflects - whether the symbol the reloc is against is local or global. */ -+#if 0 -+ /* FIXME! "#if 0" is the wrong way to disable this code. See comment -+ earlier in file. */ - if (r_baserel) - r_extern = 1; -+#endif - - if (r_extern && r_index > symcount) - { diff --git a/patches/binutils-2.14/bfd/archive.c.diff b/patches/binutils-2.14/bfd/archive.c.diff deleted file mode 100644 index 19c6f33..0000000 --- a/patches/binutils-2.14/bfd/archive.c.diff +++ /dev/null @@ -1,49 +0,0 @@ ---- binutils-2.14/bfd/archive.c 2002-11-30 09:39:34.000000000 +0100 -+++ binutils-2.14/bfd/archive.c 2013-05-17 23:47:34.000000000 +0200 -@@ -1420,7 +1420,7 @@ - strncpy (hdr->ar_fmag, ARFMAG, 2); - - /* Goddamned sprintf doesn't permit MAXIMUM field lengths. */ -- sprintf ((hdr->ar_date), "%-12ld", (long) status.st_mtime); -+ sprintf ((hdr->ar_date), "%-11ld", (long) status.st_mtime); - #ifdef HPUX_LARGE_AR_IDS - /* HP has a very "special" way to handle UID/GID's with numeric values - > 99999. */ -@@ -1437,8 +1437,8 @@ - else - #endif - sprintf ((hdr->ar_gid), "%ld", (long) status.st_gid); -- sprintf ((hdr->ar_mode), "%-8o", (unsigned int) status.st_mode); -- sprintf ((hdr->ar_size), "%-10ld", (long) status.st_size); -+ sprintf ((hdr->ar_mode), "%-7o", (unsigned int) status.st_mode); -+ sprintf ((hdr->ar_size), "%-9ld", (long) status.st_size); - /* Correct for a lossage in sprintf whereby it null-terminates. I cannot - understand how these C losers could design such a ramshackle bunch of - IO operations. */ -@@ -1754,7 +1754,7 @@ - memset ((char *) (&hdr), 0, sizeof (struct ar_hdr)); - strcpy (hdr.ar_name, ename); - /* Round size up to even number in archive header. */ -- sprintf (&(hdr.ar_size[0]), "%-10d", -+ sprintf (&(hdr.ar_size[0]), "%-9d", - (int) ((elength + 1) & ~(bfd_size_type) 1)); - strncpy (hdr.ar_fmag, ARFMAG, 2); - for (i = 0; i < sizeof (struct ar_hdr); i++) -@@ -2010,7 +2010,7 @@ - sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp); - sprintf (hdr.ar_uid, "%ld", (long) getuid ()); - sprintf (hdr.ar_gid, "%ld", (long) getgid ()); -- sprintf (hdr.ar_size, "%-10d", (int) mapsize); -+ sprintf (hdr.ar_size, "%-9d", (int) mapsize); - strncpy (hdr.ar_fmag, ARFMAG, 2); - for (i = 0; i < sizeof (struct ar_hdr); i++) - if (((char *) (&hdr))[i] == '\0') -@@ -2168,7 +2168,7 @@ - - memset ((char *) (&hdr), 0, sizeof (struct ar_hdr)); - hdr.ar_name[0] = '/'; -- sprintf (hdr.ar_size, "%-10d", (int) mapsize); -+ sprintf (hdr.ar_size, "%-9d", (int) mapsize); - sprintf (hdr.ar_date, "%ld", (long) time (NULL)); - /* This, at least, is what Intel coff sets the values to. */ - sprintf ((hdr.ar_uid), "%d", 0); diff --git a/patches/binutils-2.14/bfd/bfd-in2.h.diff b/patches/binutils-2.14/bfd/bfd-in2.h.diff deleted file mode 100644 index 203d5a1..0000000 --- a/patches/binutils-2.14/bfd/bfd-in2.h.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- binutils-2.14/bfd/bfd-in2.h 2003-05-03 18:06:57.000000000 +0200 -+++ binutils-2.14-patched/bfd/bfd-in2.h 2013-04-24 18:38:25.000000000 +0200 -@@ -3811,6 +3821,7 @@ - struct bfd_pef_data_struct *pef_data; - struct bfd_pef_xlib_data_struct *pef_xlib_data; - struct bfd_sym_data_struct *sym_data; -+ struct amiga_data_struct *amiga_data; - PTR any; - } - tdata; -@@ -4069,6 +4080,7 @@ - enum bfd_flavour - { - bfd_target_unknown_flavour, -+ bfd_target_amiga_flavour, - bfd_target_aout_flavour, - bfd_target_coff_flavour, - bfd_target_ecoff_flavour, diff --git a/patches/binutils-2.14/bfd/bfd.c.diff b/patches/binutils-2.14/bfd/bfd.c.diff deleted file mode 100644 index e6bd3df..0000000 --- a/patches/binutils-2.14/bfd/bfd.c.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- binutils-2.14/bfd/bfd.c 2003-03-01 00:43:35.000000000 +0100 -+++ binutils-2.14-patched/bfd/bfd.c 2013-04-24 18:38:25.000000000 +0200 -@@ -188,6 +188,7 @@ - . struct bfd_pef_data_struct *pef_data; - . struct bfd_pef_xlib_data_struct *pef_xlib_data; - . struct bfd_sym_data_struct *sym_data; -+. struct amiga_data_struct *amiga_data; - . PTR any; - . } - . tdata; diff --git a/patches/binutils-2.14/bfd/config.bfd.diff b/patches/binutils-2.14/bfd/config.bfd.diff deleted file mode 100644 index 3135e06..0000000 --- a/patches/binutils-2.14/bfd/config.bfd.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- binutils-2.14/bfd/config.bfd 2003-06-02 22:35:20.000000000 +0200 -+++ binutils-2.14-patched/bfd/config.bfd 2013-04-24 18:38:23.000000000 +0200 -@@ -605,6 +610,11 @@ - m68*-motorola-sysv*) - targ_defvec=m68ksysvcoff_vec - ;; -+ m68*-*-amigaos*) -+ targ_defvec=amiga_vec -+ targ_selvecs="aout_amiga_vec amiga_vec" -+ targ_underscore=yes -+ ;; - m68*-hp-bsd*) - targ_defvec=hp300bsd_vec - targ_underscore=yes diff --git a/patches/binutils-2.14/bfd/configure.diff b/patches/binutils-2.14/bfd/configure.diff deleted file mode 100644 index 375bf2a..0000000 --- a/patches/binutils-2.14/bfd/configure.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- binutils-2.14/bfd/configure 2003-06-12 16:25:46.000000000 +0200 -+++ binutils-2.14-patched/bfd/configure 2013-04-24 18:38:23.000000000 +0200 -@@ -6083,7 +11457,9 @@ - a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;; - a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;; - aix5coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;; -+ amiga_vec) tb="$tb amigaos.lo amigaoslink.lo" ;; - aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;; -+ aout_amiga_vec) tb="$tb aout-amiga.lo aout32.lo";; - aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;; - aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;; - aout_mips_big_vec) tb="$tb mipsbsd.lo aout32.lo" ;; diff --git a/patches/binutils-2.14/bfd/configure.in.diff b/patches/binutils-2.14/bfd/configure.in.diff deleted file mode 100644 index e4e3ff6..0000000 --- a/patches/binutils-2.14/bfd/configure.in.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- binutils-2.14/bfd/configure.in 2003-06-12 16:25:46.000000000 +0200 -+++ binutils-2.14-patched/bfd/configure.in 2013-04-24 18:38:25.000000000 +0200 -@@ -545,7 +545,9 @@ - a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;; - a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;; - aix5coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo aix5ppc-core.lo"; target_size=64 ;; -+ amiga_vec) tb="$tb amigaos.lo amigaoslink.lo" ;; - aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;; -+ aout_amiga_vec) tb="$tb aout-amiga.lo aout32.lo";; - aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;; - aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;; - aout_mips_big_vec) tb="$tb mipsbsd.lo aout32.lo" ;; diff --git a/patches/binutils-2.14/bfd/doc/Makefile.am.diff b/patches/binutils-2.14/bfd/doc/Makefile.am.diff deleted file mode 100644 index a48f354..0000000 --- a/patches/binutils-2.14/bfd/doc/Makefile.am.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- binutils-2.14/bfd/doc/Makefile.am 2002-11-18 17:37:54.000000000 +0100 -+++ binutils-2.14-patched/bfd/doc/Makefile.am 2013-04-24 18:38:20.000000000 +0200 -@@ -2,7 +2,7 @@ - - AUTOMAKE_OPTIONS = cygnus - --DOCFILES = aoutx.texi archive.texi archures.texi \ -+DOCFILES = amiga.texi amigalink.texi aoutx.texi archive.texi archures.texi \ - bfdt.texi cache.texi coffcode.texi \ - core.texi elf.texi elfcode.texi format.texi \ - libbfd.texi bfdwin.texi bfdio.texi \ -@@ -28,6 +28,7 @@ - $(srcdir)/../cache.c $(srcdir)/../coffcode.h \ - $(srcdir)/../corefile.c $(srcdir)/../elf.c \ - $(srcdir)/../elfcode.h $(srcdir)/../format.c \ -+ $(srcdir)/../amigaos.c $(srcdir)/../amigaoslink.c \ - $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \ - $(srcdir)/../reloc.c $(srcdir)/../section.c \ - $(srcdir)/../syms.c $(srcdir)/../targets.c \ -@@ -208,6 +210,18 @@ - touch s-linker - linker.texi: s-linker - -+s-amiga: $(MKDOC) $(srcdir)/../amigaos.c $(srcdir)/doc.str -+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../amigaos.c >amiga.tmp -+ $(srcdir)/../../move-if-change amiga.tmp amiga.texi -+ touch s-amiga -+amiga.texi: s-amiga -+ -+s-amigalink: $(MKDOC) $(srcdir)/../amigaoslink.c $(srcdir)/doc.str -+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../amigaoslink.c >amigalink.tmp -+ $(srcdir)/../../move-if-change amigalink.tmp amigalink.texi -+ touch s-amigalink -+amigalink.texi: s-amigalink -+ - LIBBFD_H_DEP = \ - $(srcdir)/../libbfd-in.h \ - $(srcdir)/../init.c \ diff --git a/patches/binutils-2.14/bfd/doc/Makefile.in.diff b/patches/binutils-2.14/bfd/doc/Makefile.in.diff deleted file mode 100644 index 58fc66e..0000000 --- a/patches/binutils-2.14/bfd/doc/Makefile.in.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- binutils-2.14/bfd/doc/Makefile.in 2002-11-18 17:37:54.000000000 +0100 -+++ binutils-2.14-patched/bfd/doc/Makefile.in 2013-04-24 18:38:20.000000000 +0200 -@@ -122,9 +122,9 @@ - tdefaults = @tdefaults@ - wordsize = @wordsize@ - - AUTOMAKE_OPTIONS = cygnus - --DOCFILES = aoutx.texi archive.texi archures.texi \ -+DOCFILES = amiga.texi amigalink.texi aoutx.texi archive.texi archures.texi \ - bfdt.texi cache.texi coffcode.texi \ - core.texi elf.texi elfcode.texi format.texi \ - libbfd.texi bfdwin.texi bfdio.texi \ -@@ -156,6 +156,7 @@ - $(srcdir)/../cache.c $(srcdir)/../coffcode.h \ - $(srcdir)/../corefile.c $(srcdir)/../elf.c \ - $(srcdir)/../elfcode.h $(srcdir)/../format.c \ -+ $(srcdir)/../amigaos.c $(srcdir)/../amigaoslink.c \ - $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \ - $(srcdir)/../reloc.c $(srcdir)/../section.c \ - $(srcdir)/../syms.c $(srcdir)/../targets.c \ -@@ -622,6 +623,18 @@ - touch s-linker - linker.texi: s-linker - -+s-amiga: $(MKDOC) $(srcdir)/../amigaos.c $(srcdir)/doc.str -+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../amigaos.c >amiga.tmp -+ $(srcdir)/../../move-if-change amiga.tmp amiga.texi -+ touch s-amiga -+amiga.texi: s-amiga -+ -+s-amigalink: $(MKDOC) $(srcdir)/../amigaoslink.c $(srcdir)/doc.str -+ ./$(MKDOC) -f $(srcdir)/doc.str <$(srcdir)/../amigaoslink.c >amigalink.tmp -+ $(srcdir)/../../move-if-change amigalink.tmp amigalink.texi -+ touch s-amigalink -+amigalink.texi: s-amigalink -+ - libbfd.h: $(LIBBFD_H_DEP) - echo "$(LIBBFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@ - for file in $(LIBBFD_H_DEP); do \ diff --git a/patches/binutils-2.14/bfd/doc/bfd.texinfo.diff b/patches/binutils-2.14/bfd/doc/bfd.texinfo.diff deleted file mode 100644 index 0ee7512..0000000 --- a/patches/binutils-2.14/bfd/doc/bfd.texinfo.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- binutils-2.14/bfd/doc/bfd.texinfo 2003-02-13 12:26:41.000000000 +0100 -+++ binutils-2.14-patched/bfd/doc/bfd.texinfo 2013-04-24 18:38:20.000000000 +0200 -@@ -299,6 +299,7 @@ - * aout :: a.out backends - * coff :: coff backends - * elf :: elf backends -+* amiga :: amigaos backend - * mmo :: mmo backend - @ignore - * oasys :: oasys backends -@@ -315,12 +316,16 @@ - @node coff, elf, aout, BFD back ends - @include coffcode.texi - --@node elf, mmo, coff, BFD back ends -+@node elf, amiga, coff, BFD back ends - @include elf.texi - @c Leave this out until the file has some actual contents... - @c @include elfcode.texi - --@node mmo, , elf, BFD back ends -+@node amiga, mmo, elf, BFD back ends -+@include amiga.texi -+@include amigalink.texi -+ -+@node mmo, , amiga, BFD back ends - @include mmo.texi - - @node GNU Free Documentation License, Index, BFD back ends, Top diff --git a/patches/binutils-2.14/bfd/libamiga.h b/patches/binutils-2.14/bfd/libamiga.h deleted file mode 100644 index 351f0fa..0000000 --- a/patches/binutils-2.14/bfd/libamiga.h +++ /dev/null @@ -1,187 +0,0 @@ -/* BFD back-end for Commodore-Amiga AmigaOS binaries. Data structures. - Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998 - Free Software Foundation, Inc. - Contributed by Leonard Norrgard. - Extended by Stephan Thesing 11/1994. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Hunk ID numbers. */ - -#define HUNK_UNIT 999 -#define HUNK_NAME 1000 -#define HUNK_CODE 1001 -#define HUNK_DATA 1002 -#define HUNK_BSS 1003 -#define HUNK_RELOC32 1004 -#define HUNK_ABSRELOC32 HUNK_RELOC32 -#define HUNK_RELOC16 1005 -#define HUNK_RELRELOC16 HUNK_RELOC16 -#define HUNK_RELOC8 1006 -#define HUNK_RELRELOC8 HUNK_RELOC8 -#define HUNK_EXT 1007 -#define HUNK_SYMBOL 1008 -#define HUNK_DEBUG 1009 -#define HUNK_END 1010 -#define HUNK_HEADER 1011 -#define HUNK_OVERLAY 1013 -#define HUNK_BREAK 1014 -#define HUNK_DREL32 1015 -#define HUNK_DREL16 1016 -#define HUNK_DREL8 1017 -#define HUNK_LIB 1018 -#define HUNK_INDEX 1019 -#define HUNK_RELOC32SHORT 1020 -#define HUNK_RELRELOC32 1021 -#define HUNK_ABSRELOC16 1022 -/* EHF extensions */ -#define HUNK_PPC_CODE 1257 -#define HUNK_RELRELOC26 1260 - -/* The hunk ID part. */ - -#define HUNK_VALUE(hunk_id) ((hunk_id) & 0x3fffffff) - -/* Attributes of a hunk. */ - -#define HUNK_ATTRIBUTE(hunk_id) ((hunk_id) >> 30) -#define HUNK_ATTR_CHIP 0x01 /* hunk content must go into chip ram */ -#define HUNK_ATTR_FAST 0x02 /* fast */ -#define HUNK_ATTR_FOLLOWS 0x03 /* mem id follows */ - -/* HUNK_EXT subtypes. */ - -#define EXT_SYMB 0 -#define EXT_DEF 1 -#define EXT_ABS 2 -#define EXT_RES 3 -#define EXT_REF32 129 -#define EXT_ABSREF32 EXT_REF32 -#define EXT_COMMON 130 -#define EXT_ABSCOMMON EXT_COMMON -#define EXT_REF16 131 -#define EXT_RELREF16 EXT_REF16 -#define EXT_REF8 132 -#define EXT_RELREF8 EXT_REF8 -#define EXT_DEXT32 133 -#define EXT_DEXT16 134 -#define EXT_DEXT8 135 -#define EXT_RELREF32 136 -#define EXT_RELCOMMON 137 -#define EXT_ABSREF16 138 -#define EXT_ABSREF8 139 -/* VBCC extensions */ -#define EXT_DEXT32COMMON 208 -#define EXT_DEXT16COMMON 209 -#define EXT_DEXT8COMMON 210 -/* EHF extensions */ -#define EXT_RELREF26 229 - -/* HOWTO types almost matching aoutx.h/howto_table_std. */ - -enum { - H_ABS8=0,H_ABS16,H_ABS32,H_ABS32SHORT,H_PC8,H_PC16,H_PC32,H_PC26,H_SD8,H_SD16,H_SD32 -}; - -/* Various structures. */ - -typedef struct amiga_reloc { - arelent relent; - struct amiga_reloc *next; - asymbol *symbol; -} amiga_reloc_type; - -/* Structure layout *must* match libaout.h/struct aout_symbol. */ - -typedef struct amiga_symbol { - asymbol symbol; - short desc; - char other; - unsigned char type; - /* amiga data */ - unsigned long index,refnum; -} amiga_symbol_type; - -/* We take the address of the first element of an asymbol to ensure that the - macro is only ever applied to an asymbol. */ -#define amiga_symbol(asymbol) ((amiga_symbol_type *)(&(asymbol)->the_bfd)) - -typedef struct raw_reloc { - unsigned long num,pos; - struct raw_reloc *next; -} raw_reloc_type; - -typedef struct amiga_per_section { - amiga_reloc_type *reloc_tail; /* last reloc, first is in section->relocation */ - int attribute; /* Memory type required by this section */ - unsigned long disk_size; /* Section size on disk, _raw_size may be larger than this */ - amiga_symbol_type *amiga_symbols; /* the symbols for this section */ - unsigned long hunk_ext_pos; /* offset of hunk_ext in the bfd file */ - unsigned long hunk_symbol_pos; /* offset of hunk_symbol in the bfd file */ - raw_reloc_type *relocs; -} amiga_per_section_type; - -#define amiga_per_section(x) ((amiga_per_section_type *)((x)->used_by_bfd)) - -/* Structure layout *must* match libaout.h/struct aoutdata. */ - -struct amiga_data { - char *dummy[2]; - sec_ptr textsec; - sec_ptr datasec; - sec_ptr bsssec; - file_ptr sym_filepos; - file_ptr str_filepos; - /* rest intentionally omitted */ -}; - -typedef struct amiga_data_struct { - struct amiga_data a; - unsigned long symtab_size; - unsigned long stringtab_size; - amiga_symbol_type *symbols; - bfd_boolean IsLoadFile; /* If true, this is a load file (for output bfd only) */ - unsigned int nb_hunks; - /* The next two fields are set at final_link time (for the output bfd only) */ - bfd_boolean baserel;/* true if there is ___init_a4 in the global hash table */ - bfd_vma a4init; /* cache the value for efficiency */ -} amiga_data_type; - -#define adata(bfd) ((bfd)->tdata.amiga_data->a) -#define AMIGA_DATA(bfd) ((bfd)->tdata.amiga_data) - -#define HUNKB_ADVISORY 29 -#define HUNKB_CHIP 30 -#define HUNKB_FAST 31 -#define HUNKF_ADVISORY (1L << HUNKB_ADVISORY) -#define HUNKF_CHIP (1L << HUNKB_CHIP) -#define HUNKF_FAST (1L << HUNKB_FAST) - -#ifndef MEMF_ANY -#define MEMF_ANY (0L) -#define MEMF_PUBLIC (1L << 0) -#define MEMF_CHIP (1L << 1) -#define MEMF_FAST (1L << 2) -#define MEMF_LOCAL (1L << 8) -#define MEMF_24BITDMA (1L << 9) -#define MEMF_KICK (1L << 10) -#define MEMF_CLEAR (1L << 16) -#define MEMF_LARGEST (1L << 17) -#define MEMF_REVERSE (1L << 18) -#define MEMF_TOTAL (1L << 19) -#define MEMF_NO_EXPUNGE (1L << 31) -#endif /* MEMF_ANY */ diff --git a/patches/binutils-2.14/bfd/linker.c.diff b/patches/binutils-2.14/bfd/linker.c.diff deleted file mode 100644 index c6de1a3..0000000 --- a/patches/binutils-2.14/bfd/linker.c.diff +++ /dev/null @@ -1,63 +0,0 @@ ---- binutils-2.14/bfd/linker.c 2003-03-31 20:13:25.000000000 +0200 -+++ binutils-2.14-patched/bfd/linker.c 2013-04-24 18:38:23.000000000 +0200 -@@ -431,7 +431,8 @@ - static bfd_boolean default_data_link_order - PARAMS ((bfd *, struct bfd_link_info *, asection *, - struct bfd_link_order *)); --static bfd_boolean default_indirect_link_order -+/*Amiga hack - used in amigaoslink.c so must be global */ -+/*static*/ bfd_boolean default_indirect_link_order - PARAMS ((bfd *, struct bfd_link_info *, asection *, - struct bfd_link_order *, bfd_boolean)); - -@@ -1246,6 +1247,13 @@ - h->u.c.size = size; - - power = bfd_log2 (size); -+ /* For the amiga, we don't want an alignment bigger than 2**2. -+ Doing this here is horrible kludgy, but IMHO the maximal -+ power alignment really should be target-dependant so that -+ we wouldn't have to do this -- daniel */ -+ if (info->hash->creator->flavour == bfd_target_amiga_flavour -+ && power > 2) -+ power = 2; - if (power > 4) - power = 4; - h->u.c.p->alignment_power = power; -@@ -1708,6 +1716,13 @@ - unsigned int power; - - power = bfd_log2 (value); -+ /* For the amiga, we don't want an alignment bigger than 2**2. -+ Doing this here is horrible kludgy, but IMHO the maximal -+ power alignment really should be target-dependant so that -+ we wouldn't have to do this -- daniel */ -+ if (info->hash->creator->flavour == bfd_target_amiga_flavour -+ && power > 2) -+ power = 2; - if (power > 4) - power = 4; - h->u.c.p->alignment_power = power; -@@ -1763,6 +1778,13 @@ - /* Select a default alignment based on the size. This may - be overridden by the caller. */ - power = bfd_log2 (value); -+ /* For the amiga, we don't want an alignment bigger than 2**2. -+ Doing this here is horrible kludgy, but IMHO the maximal -+ power alignment really should be target-dependant so that -+ we wouldn't have to do this -- daniel */ -+ if (info->hash->creator->flavour == bfd_target_amiga_flavour -+ && power > 2) -+ power = 2; - if (power > 4) - power = 4; - h->u.c.p->alignment_power = power; -@@ -2739,7 +2761,7 @@ - - /* Default routine to handle a bfd_indirect_link_order. */ - --static bfd_boolean -+/*static*/ bfd_boolean - default_indirect_link_order (output_bfd, info, output_section, link_order, - generic_linker) - bfd *output_bfd; diff --git a/patches/binutils-2.14/bfd/targets.c.diff b/patches/binutils-2.14/bfd/targets.c.diff deleted file mode 100644 index 605c7de..0000000 --- a/patches/binutils-2.14/bfd/targets.c.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- binutils-2.14/bfd/targets.c 2003-04-01 17:50:27.000000000 +0200 -+++ binutils-2.14-patched/bfd/targets.c 2013-04-24 18:38:23.000000000 +0200 -@@ -138,6 +138,7 @@ - .enum bfd_flavour - .{ - . bfd_target_unknown_flavour, -+. bfd_target_amiga_flavour, - . bfd_target_aout_flavour, - . bfd_target_coff_flavour, - . bfd_target_ecoff_flavour, -@@ -488,6 +489,8 @@ - extern const bfd_target a29kcoff_big_vec; - extern const bfd_target a_out_adobe_vec; - extern const bfd_target aix5coff64_vec; -+extern const bfd_target amiga_vec; -+extern const bfd_target aout_amiga_vec; - extern const bfd_target aout0_big_vec; - extern const bfd_target aout_arm_big_vec; - extern const bfd_target aout_arm_little_vec; -@@ -763,6 +769,8 @@ - #ifdef BFD64 - &aix5coff64_vec, - #endif -+ &amiga_vec, -+ &aout_amiga_vec, - &aout0_big_vec, - #if 0 - /* We have no way of distinguishing these from other a.out variants. */ diff --git a/patches/binutils-2.14/binutils/objcopy.c.diff b/patches/binutils-2.14/binutils/objcopy.c.diff deleted file mode 100644 index 0b33889..0000000 --- a/patches/binutils-2.14/binutils/objcopy.c.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- binutils-2.14/binutils/objcopy.c 2003-06-02 22:35:15.000000000 +0200 -+++ binutils-2.14-patched/binutils/objcopy.c 2013-04-24 18:38:17.000000000 +0200 -@@ -1843,7 +1848,9 @@ - if (relcount < 0) - RETURN_NONFATAL (bfd_get_filename (ibfd)); - -- if (strip_symbols == STRIP_ALL) -+ /* Never, ever, strip reloc data on the Amiga! */ -+ if (strip_symbols == STRIP_ALL && -+ bfd_get_flavour(obfd) != bfd_target_amiga_flavour) - { - /* Remove relocations which are not in - keep_strip_specific_list. */ diff --git a/patches/binutils-2.14/gas/Makefile.am.diff b/patches/binutils-2.14/gas/Makefile.am.diff deleted file mode 100644 index 3d8b079..0000000 --- a/patches/binutils-2.14/gas/Makefile.am.diff +++ /dev/null @@ -1,72 +0,0 @@ ---- binutils-2.14/gas/Makefile.am 2003-04-24 14:47:31.000000000 +0200 -+++ binutils-2.14-patched/gas/Makefile.am 2013-04-24 18:38:14.000000000 +0200 -@@ -93,6 +93,7 @@ - # We deliberately omit SOM, since it does not work as a cross assembler. - - OBJ_FORMATS = \ -+ amigahunk \ - aout \ - bout \ - coff \ -@@ -337,6 +338,7 @@ - # OBJ files in config - - OBJ_FORMAT_CFILES = \ -+ config/obj-amigahunk.c \ - config/obj-aout.c \ - config/obj-bout.c \ - config/obj-coff.c \ -@@ -349,6 +351,7 @@ - config/obj-vms.c - - OBJ_FORMAT_HFILES = \ -+ config/obj-amigahunk.h \ - config/obj-aout.h \ - config/obj-bout.h \ - config/obj-coff.h \ -@@ -364,6 +367,7 @@ - - TARG_ENV_HFILES = \ - config/te-386bsd.h \ -+ config/te-amiga.h \ - config/te-aux.h \ - config/te-delta.h \ - config/te-delt88.h \ -@@ -566,6 +570,8 @@ - # We need all these explicit rules for the multi stuff. Because of - # these rules, we don't need one for OBJ_FORMAT_O. - -+obj-amigahunk.o : $(srcdir)/config/obj-amigahunk.c -+ $(COMPILE) -c $(srcdir)/config/obj-amigahunk.c - obj-aout.o : $(srcdir)/config/obj-aout.c - $(COMPILE) -c $(srcdir)/config/obj-aout.c - obj-bout.o : $(srcdir)/config/obj-bout.c -@@ -1215,6 +1221,9 @@ - $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \ - $(INCDIR)/opcode/m68hc11.h dwarf2dbg.h $(INCDIR)/elf/m68hc11.h \ - $(INCDIR)/elf/reloc-macros.h -+DEPTC_m68k_amigaoshunk = $(INCDIR)/symcat.h $(srcdir)/config/obj-amigahunk.h \ -+ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libamiga.h $(INCDIR)/bfdlink.h \ -+ $(INCDIR)/obstack.h subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h - DEPTC_m68k_aout = $(INCDIR)/symcat.h $(srcdir)/config/obj-aout.h \ - $(srcdir)/config/tc-m68k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \ - $(INCDIR)/safe-ctype.h $(INCDIR)/obstack.h subsegs.h \ -@@ -1764,6 +1773,9 @@ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68hc11.h \ - $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \ - struc-symbol.h $(INCDIR)/aout/aout64.h -+DEPOBJ_m68k_amigaoshunk = $(INCDIR)/symcat.h $(srcdir)/config/obj-amigahunk.h \ -+ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libamiga.h $(INCDIR)/bfdlink.h \ -+ $(INCDIR)/aout/aout64.h $(INCDIR)/obstack.h - DEPOBJ_m68k_aout = $(INCDIR)/symcat.h $(srcdir)/config/obj-aout.h \ - $(srcdir)/config/tc-m68k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \ - $(INCDIR)/aout/aout64.h $(INCDIR)/obstack.h -@@ -2202,6 +2214,8 @@ - DEP_m68hc11_elf = $(srcdir)/config/obj-elf.h $(INCDIR)/symcat.h \ - $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68hc11.h -+DEP_m68k_amigaoshunk = $(srcdir)/config/obj-amigahunk.h \ -+ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libamiga.h $(INCDIR)/bfdlink.h - DEP_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ - $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h - DEP_m68k_coff = $(srcdir)/config/obj-coff.h $(srcdir)/config/tc-m68k.h \ diff --git a/patches/binutils-2.14/gas/Makefile.in.diff b/patches/binutils-2.14/gas/Makefile.in.diff deleted file mode 100644 index 773f928..0000000 --- a/patches/binutils-2.14/gas/Makefile.in.diff +++ /dev/null @@ -1,75 +0,0 @@ ---- binutils-2.14/gas/Makefile.in 2003-04-24 14:47:32.000000000 +0200 -+++ binutils-2.14/gas/Makefile.in 2013-05-18 12:00:58.000000000 +0200 -@@ -205,6 +205,7 @@ - # We deliberately omit SOM, since it does not work as a cross assembler. - - OBJ_FORMATS = \ -+ amigahunk \ - aout \ - bout \ - coff \ -@@ -456,6 +457,7 @@ - # OBJ files in config - - OBJ_FORMAT_CFILES = \ -+ config/obj-amigahunk.c \ - config/obj-aout.c \ - config/obj-bout.c \ - config/obj-coff.c \ -@@ -469,6 +471,7 @@ - - - OBJ_FORMAT_HFILES = \ -+ config/obj-amigahunk.h \ - config/obj-aout.h \ - config/obj-bout.h \ - config/obj-coff.h \ -@@ -485,6 +488,7 @@ - - TARG_ENV_HFILES = \ - config/te-386bsd.h \ -+ config/te-amiga.h \ - config/te-aux.h \ - config/te-delta.h \ - config/te-delt88.h \ -@@ -964,6 +968,10 @@ - $(INCDIR)/opcode/m68hc11.h dwarf2dbg.h $(INCDIR)/elf/m68hc11.h \ - $(INCDIR)/elf/reloc-macros.h - -+DEPTC_m68k_amigaoshunk = $(INCDIR)/symcat.h $(srcdir)/config/obj-amigahunk.h \ -+ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libamiga.h $(INCDIR)/bfdlink.h \ -+ $(INCDIR)/obstack.h subsegs.h $(INCDIR)/opcode/m68k.h $(srcdir)/config/m68k-parse.h -+ - DEPTC_m68k_aout = $(INCDIR)/symcat.h $(srcdir)/config/obj-aout.h \ - $(srcdir)/config/tc-m68k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \ - $(INCDIR)/safe-ctype.h $(INCDIR)/obstack.h subsegs.h \ -@@ -1631,6 +1639,10 @@ - $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \ - struc-symbol.h $(INCDIR)/aout/aout64.h - -+DEPOBJ_m68k_amigaoshunk = $(INCDIR)/symcat.h $(srcdir)/config/obj-amigahunk.h \ -+ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libamiga.h $(INCDIR)/bfdlink.h \ -+ $(INCDIR)/aout/aout64.h $(INCDIR)/obstack.h -+ - DEPOBJ_m68k_aout = $(INCDIR)/symcat.h $(srcdir)/config/obj-aout.h \ - $(srcdir)/config/tc-m68k.h $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h \ - $(INCDIR)/aout/aout64.h $(INCDIR)/obstack.h -@@ -2185,6 +2197,9 @@ - $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-m68hc11.h - -+DEP_m68k_amigaoshunk = $(srcdir)/config/obj-amigahunk.h \ -+ $(srcdir)/config/tc-m68k.h $(BFDDIR)/libamiga.h $(INCDIR)/bfdlink.h -+ - DEP_m68k_aout = $(srcdir)/config/obj-aout.h $(srcdir)/config/tc-m68k.h \ - $(BFDDIR)/libaout.h $(INCDIR)/bfdlink.h - -@@ -2940,6 +2955,8 @@ - # We need all these explicit rules for the multi stuff. Because of - # these rules, we don't need one for OBJ_FORMAT_O. - -+obj-amigahunk.o : $(srcdir)/config/obj-amigahunk.c -+ $(COMPILE) -c $(srcdir)/config/obj-amigahunk.c - obj-aout.o : $(srcdir)/config/obj-aout.c - $(COMPILE) -c $(srcdir)/config/obj-aout.c - obj-bout.o : $(srcdir)/config/obj-bout.c diff --git a/patches/binutils-2.14/gas/app.c.diff b/patches/binutils-2.14/gas/app.c.diff deleted file mode 100644 index ae0c52a..0000000 --- a/patches/binutils-2.14/gas/app.c.diff +++ /dev/null @@ -1,89 +0,0 @@ ---- binutils-2.14/gas/app.c 2003-05-02 19:06:16.000000000 +0200 -+++ binutils-2.14-patched/gas/app.c 2013-05-22 16:18:19.000000000 +0200 -@@ -351,6 +345,8 @@ - char *fromend; - int fromlen; - register int ch, ch2 = 0; -+ /* Character that started the string we're working on. */ -+ static char quotechar; - - /*State 0: beginning of normal line - 1: After first whitespace on line (flush more white) -@@ -536,11 +538,8 @@ - for (s = from; s < fromend; s++) - { - ch = *s; -- /* This condition must be changed if the type of any -- other character can be LEX_IS_STRINGQUOTE. */ - if (ch == '\\' -- || ch == '"' -- || ch == '\'' -+ || ch == quotechar - || ch == '\n') - break; - } -@@ -558,12 +557,12 @@ - ch = GET (); - if (ch == EOF) - { -- as_warn (_("end of file in string; inserted '\"'")); -+ as_warn (_("end of file in string; '%c' inserted"), quotechar); - state = old_state; - UNGET ('\n'); -- PUT ('"'); -+ PUT (quotechar); - } -- else if (lex[ch] == LEX_IS_STRINGQUOTE) -+ else if (ch == quotechar) - { - state = old_state; - PUT (ch); -@@ -603,8 +602,8 @@ - continue; - - case EOF: -- as_warn (_("end of file in string; '\"' inserted")); -- PUT ('"'); -+ as_warn (_("end of file in string; '%c' inserted"), quotechar); -+ PUT (quotechar); - continue; - - case '"': -@@ -638,10 +637,9 @@ - - case 7: - ch = GET (); -+ quotechar = ch; - state = 5; - old_state = 8; -- if (ch == EOF) -- goto fromeof; - PUT (ch); - continue; - -@@ -952,6 +973,7 @@ - break; - - case LEX_IS_STRINGQUOTE: -+ quotechar = ch; - if (state == 10) - { - /* Preserve the whitespace in foo "bar". */ -@@ -1279,6 +1301,8 @@ - case 1: *to++ = *from++; - } - } -+ if (to >= toend) -+ goto tofull; - ch = GET (); - } - } -@@ -1297,7 +1321,7 @@ - } - else if (state == 9) - { -- if (lex[ch] != LEX_IS_SYMBOL_COMPONENT) -+ if (!IS_SYMBOL_COMPONENT (ch)) - state = 3; - } - else if (state == 10) diff --git a/patches/binutils-2.14/gas/as.c.diff b/patches/binutils-2.14/gas/as.c.diff deleted file mode 100644 index 4d7448c..0000000 --- a/patches/binutils-2.14/gas/as.c.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- binutils-2.14/gas/as.c 2003-04-08 14:47:07.000000000 +0200 -+++ binutils-2.14-patched/gas/as.c 2013-04-24 18:38:14.000000000 +0200 -@@ -88,6 +88,9 @@ - #ifdef BFD_ASSEMBLER - segT reg_section, expr_section; - segT text_section, data_section, bss_section; -+#ifdef OBJ_AMIGAHUNK -+segT data_chip_section, bss_chip_section; -+#endif - #endif - - /* The default obstack chunk size. If we set this to zero, the -@@ -1044,6 +1047,10 @@ - text_section = subseg_new (TEXT_SECTION_NAME, 0); - data_section = subseg_new (DATA_SECTION_NAME, 0); - bss_section = subseg_new (BSS_SECTION_NAME, 0); -+#ifdef OBJ_AMIGAHUNK -+ data_chip_section = subseg_new (".data_chip", 0); -+ bss_chip_section = subseg_new (".bss_chip", 0); -+#endif - /* @@ FIXME -- we're setting the RELOC flag so that sections are assumed - to have relocs, otherwise we don't find out in time. */ - applicable = bfd_applicable_section_flags (stdoutput); -@@ -1054,6 +1061,12 @@ - applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC - | SEC_DATA)); - bfd_set_section_flags (stdoutput, bss_section, applicable & SEC_ALLOC); -+#ifdef OBJ_AMIGAHUNK -+ bfd_set_section_flags (stdoutput, data_chip_section, -+ applicable & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)); -+ bfd_set_section_flags (stdoutput, bss_chip_section, applicable & SEC_ALLOC); -+#endif -+ - seg_info (bss_section)->bss = 1; - subseg_new (BFD_ABS_SECTION_NAME, 0); - subseg_new (BFD_UND_SECTION_NAME, 0); diff --git a/patches/binutils-2.14/gas/as.h.diff b/patches/binutils-2.14/gas/as.h.diff deleted file mode 100644 index 0f4099f..0000000 --- a/patches/binutils-2.14/gas/as.h.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- binutils-2.14/gas/as.h 2003-01-24 02:12:30.000000000 +0100 -+++ binutils-2.14-patched/gas/as.h 2013-04-24 18:38:14.000000000 +0200 -@@ -397,6 +397,22 @@ - /* Enough bits for address, but still an integer type. - Could be a problem, cross-assembling for 64-bit machines. */ - typedef addressT relax_addressT; -+ -+struct relax_type -+{ -+ /* Forward reach. Signed number. > 0. */ -+ long rlx_forward; -+ /* Backward reach. Signed number. < 0. */ -+ long rlx_backward; -+ -+ /* Bytes length of this address. */ -+ unsigned char rlx_length; -+ -+ /* Next longer relax-state. 0 means there is no 'next' relax-state. */ -+ relax_substateT rlx_more; -+}; -+ -+typedef struct relax_type relax_typeS; - - /* main program "as.c" (command arguments etc) */ - diff --git a/patches/binutils-2.14/gas/config/m68k-parse.h.diff b/patches/binutils-2.14/gas/config/m68k-parse.h.diff deleted file mode 100644 index 09b186b..0000000 --- a/patches/binutils-2.14/gas/config/m68k-parse.h.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- binutils-2.14/gas/config/m68k-parse.h 2001-03-09 00:24:22.000000000 +0100 -+++ binutils-2.14-patched/gas/config/m68k-parse.h 2013-04-24 18:38:13.000000000 +0200 -@@ -267,6 +267,9 @@ - - /* The expression itself. */ - expressionS exp; -+ -+ /* base-relative? */ -+ short baserel; - }; - - /* The operand modes. */ diff --git a/patches/binutils-2.14/gas/config/m68k-parse.y.diff b/patches/binutils-2.14/gas/config/m68k-parse.y.diff deleted file mode 100644 index df3855d..0000000 --- a/patches/binutils-2.14/gas/config/m68k-parse.y.diff +++ /dev/null @@ -1,35 +0,0 @@ ---- binutils-2.14/gas/config/m68k-parse.y 2001-09-19 07:33:21.000000000 +0200 -+++ binutils-2.14-patched/gas/config/m68k-parse.y 2013-04-24 18:38:13.000000000 +0200 -@@ -946,6 +946,7 @@ - } - - yylval.exp.size = SIZE_UNSPEC; -+ yylval.exp.baserel = 0; - if (s <= str + 2 - || (s[-2] != '.' && s[-2] != ':')) - tail = 0; -@@ -953,18 +954,21 @@ - { - switch (s[-1]) - { -+ case 'B': -+ yylval.exp.baserel = 1; - case 's': - case 'S': - case 'b': -- case 'B': - yylval.exp.size = SIZE_BYTE; - break; -- case 'w': - case 'W': -+ yylval.exp.baserel = 1; -+ case 'w': - yylval.exp.size = SIZE_WORD; - break; -- case 'l': - case 'L': -+ yylval.exp.baserel = 1; -+ case 'l': - yylval.exp.size = SIZE_LONG; - break; - default: diff --git a/patches/binutils-2.14/gas/config/obj-amigahunk.c b/patches/binutils-2.14/gas/config/obj-amigahunk.c deleted file mode 100644 index 8755475..0000000 --- a/patches/binutils-2.14/gas/config/obj-amigahunk.c +++ /dev/null @@ -1,212 +0,0 @@ -/* AmigaOS object file format - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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, -or (at your option) any later version. - -GAS 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 GAS; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -#include "as.h" - -enum { - N_UNDF=0, -/*N_ABS=2,*/ -/*N_TEXT=4,*/ -/*N_DATA=6,*/ -/*N_BSS=8,*/ - N_INDR=0xa, -/*N_COMM=0x12,*/ - N_SETA=0x14, - N_SETT=0x16, - N_SETD=0x18, - N_SETB=0x1a, -/*N_SETV=0x1c,*/ - N_WARNING=0x1e, -/*N_FN=0x1f*/ - N_EXT=1, - N_TYPE=0x1e, -/*N_STAB=0xe0,*/ -}; - -static void obj_amiga_line PARAMS ((int)); -static void obj_amiga_weak PARAMS ((int)); - -const pseudo_typeS obj_pseudo_table[] = -{ - {"line", obj_amiga_line, 0}, /* source code line number */ - {"weak", obj_amiga_weak, 0}, /* mark symbol as weak. */ - - /* other stuff */ - {"ABORT", s_abort, 0}, - - {NULL, NULL, 0} /* end sentinel */ -}; - -#ifdef BFD_ASSEMBLER - -void -obj_amiga_frob_symbol (sym, punt) - symbolS *sym; - int *punt ATTRIBUTE_UNUSED; -{ - sec_ptr sec = S_GET_SEGMENT (sym); - unsigned int type = amiga_symbol (symbol_get_bfdsym (sym))->type; - - /* Only frob simple symbols this way right now. */ - if (! (type & ~ (N_TYPE | N_EXT))) - { - if (type == (N_UNDF | N_EXT) - && sec == &bfd_abs_section) - { - sec = bfd_und_section_ptr; - S_SET_SEGMENT (sym, sec); - } - - if ((type & N_TYPE) != N_INDR - && (type & N_TYPE) != N_SETA - && (type & N_TYPE) != N_SETT - && (type & N_TYPE) != N_SETD - && (type & N_TYPE) != N_SETB - && type != N_WARNING - && (sec == &bfd_abs_section - || sec == &bfd_und_section)) - return; - if (symbol_get_bfdsym (sym)->flags & BSF_EXPORT) - type |= N_EXT; - - switch (type & N_TYPE) - { - case N_SETA: - case N_SETT: - case N_SETD: - case N_SETB: - /* Set the debugging flag for constructor symbols so that - BFD leaves them alone. */ - symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; - - /* You can't put a common symbol in a set. The way a set - element works is that the symbol has a definition and a - name, and the linker adds the definition to the set of - that name. That does not work for a common symbol, - because the linker can't tell which common symbol the - user means. FIXME: Using as_bad here may be - inappropriate, since the user may want to force a - particular type without regard to the semantics of sets; - on the other hand, we certainly don't want anybody to be - mislead into thinking that their code will work. */ - if (S_IS_COMMON (sym)) - as_bad (_("Attempt to put a common symbol into set %s"), - S_GET_NAME (sym)); - /* Similarly, you can't put an undefined symbol in a set. */ - else if (! S_IS_DEFINED (sym)) - as_bad (_("Attempt to put an undefined symbol into set %s"), - S_GET_NAME (sym)); - - break; - case N_INDR: - /* Put indirect symbols in the indirect section. */ - S_SET_SEGMENT (sym, bfd_ind_section_ptr); - symbol_get_bfdsym (sym)->flags |= BSF_INDIRECT; - if (type & N_EXT) - { - symbol_get_bfdsym (sym)->flags |= BSF_EXPORT; - symbol_get_bfdsym (sym)->flags &=~ BSF_LOCAL; - } - break; - case N_WARNING: - /* Mark warning symbols. */ - symbol_get_bfdsym (sym)->flags |= BSF_WARNING; - break; - } - } - else - { - symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING; - } - - amiga_symbol (symbol_get_bfdsym (sym))->type = type; - - /* Double check weak symbols. */ - if (S_IS_WEAK (sym)) - { - if (S_IS_COMMON (sym)) - as_bad (_("Symbol `%s' can not be both weak and common"), - S_GET_NAME (sym)); - } -} - -void -obj_amiga_frob_file_before_fix () -{ - /* Relocation processing may require knowing the VMAs of the sections. - Since writing to a section will cause the BFD back end to compute the - VMAs, fake it out here.... */ - bfd_byte b = 0; - bfd_boolean x = TRUE; - if (bfd_section_size (stdoutput, text_section) != 0) - { - x = bfd_set_section_contents (stdoutput, text_section, &b, (file_ptr) 0, - (bfd_size_type) 1); - } - else if (bfd_section_size (stdoutput, data_section) != 0) - { - x = bfd_set_section_contents (stdoutput, data_section, &b, (file_ptr) 0, - (bfd_size_type) 1); - } - assert (x); -} - -#endif /* BFD_ASSEMBLER */ - -static void -obj_amiga_line (ignore) - int ignore ATTRIBUTE_UNUSED; -{ - /* Assume delimiter is part of expression. - BSD4.2 as fails with delightful bug, so we - are not being incompatible here. */ - new_logical_line ((char *) NULL, (int) (get_absolute_expression ())); - demand_empty_rest_of_line (); -} /* obj_amiga_line() */ - -/* Handle .weak. This is a GNU extension. */ - -static void -obj_amiga_weak (ignore) - int ignore ATTRIBUTE_UNUSED; -{ - char *name; - int c; - symbolS *symbolP; - - do - { - name = input_line_pointer; - c = get_symbol_end (); - symbolP = symbol_find_or_make (name); - *input_line_pointer = c; - SKIP_WHITESPACE (); - S_SET_WEAK (symbolP); - if (c == ',') - { - input_line_pointer++; - SKIP_WHITESPACE (); - if (*input_line_pointer == '\n') - c = '\n'; - } - } - while (c == ','); - demand_empty_rest_of_line (); -} diff --git a/patches/binutils-2.14/gas/config/obj-amigahunk.h b/patches/binutils-2.14/gas/config/obj-amigahunk.h deleted file mode 100644 index 0b7d80e..0000000 --- a/patches/binutils-2.14/gas/config/obj-amigahunk.h +++ /dev/null @@ -1,54 +0,0 @@ -/* obj-amigahunk.h, AmigaOS object file format for gas, the assembler. - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - - This file is part of GAS, the GNU Assembler. - - GAS 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, - or (at your option) any later version. - - GAS 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 GAS; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* Tag to validate an amiga object file format processing */ -#define OBJ_AMIGAHUNK 1 - -#include "targ-cpu.h" - -#ifdef BFD_ASSEMBLER - -#include "bfd/libamiga.h" - -#define OUTPUT_FLAVOR bfd_target_amiga_flavour - -/* SYMBOL TABLE */ -/* Symbol table macros and constants */ - -#define S_SET_OTHER(S,V) (amiga_symbol (symbol_get_bfdsym (S))->other = (V)) -#define S_SET_TYPE(S,T) (amiga_symbol (symbol_get_bfdsym (S))->type = (T)) -#define S_SET_DESC(S,D) (amiga_symbol (symbol_get_bfdsym (S))->desc = (D)) -#define S_GET_TYPE(S) (amiga_symbol (symbol_get_bfdsym (S))->type) - -#define obj_frob_symbol(S,PUNT) obj_amiga_frob_symbol (S, &PUNT) -extern void obj_amiga_frob_symbol PARAMS ((symbolS *, int *)); - -#define obj_frob_file_before_fix() obj_amiga_frob_file_before_fix () -extern void obj_amiga_frob_file_before_fix PARAMS ((void)); - -#define obj_sec_sym_ok_for_reloc(SEC) (1) - -#endif /* BFD_ASSEMBLER */ - -#define obj_read_begin_hook() {;} -#define obj_symbol_new_hook(s) {;} -#define EMIT_SECTION_SYMBOLS (0) - -#define AOUT_STABS diff --git a/patches/binutils-2.14/gas/config/tc-m68k.c.diff b/patches/binutils-2.14/gas/config/tc-m68k.c.diff deleted file mode 100644 index b82bbc1..0000000 --- a/patches/binutils-2.14/gas/config/tc-m68k.c.diff +++ /dev/null @@ -1,688 +0,0 @@ ---- binutils-2.14/gas/config/tc-m68k.c 2002-12-12 23:16:16.000000000 +0100 -+++ binutils-2.14-patched/gas/config/tc-m68k.c 2013-04-24 18:38:13.000000000 +0200 -@@ -33,6 +33,16 @@ - #include "elf/m68k.h" - #endif - -+/* FIXME: delete this #define as soon as the code that references -+ N_TEXT is changed */ -+#ifdef BFD_ASSEMBLER -+#define N_TEXT 4 -+#endif -+ -+#ifndef OBJ_AMIGAHUNK -+#define OBJ_AMIGAHUNK 0 -+#endif -+ - /* This string holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful. The macro - tc_comment_chars points to this. We use this, rather than the -@@ -77,6 +87,7 @@ - static int flag_short_refs; /* -l option */ - static int flag_long_jumps; /* -S option */ - static int flag_keep_pcrel; /* --pcrel option. */ -+static int flag_small_code; /* -sc option */ - - #ifdef REGISTER_PREFIX_OPTIONAL - int flag_reg_prefix_optional = REGISTER_PREFIX_OPTIONAL; -@@ -221,6 +232,7 @@ - so, which. */ - enum pic_relocation pic_reloc; - #endif -+ char baserel; - } - reloc[5]; /* Five is enough??? */ - }; -@@ -247,7 +259,7 @@ - /* Static functions. */ - - static void insop PARAMS ((int, const struct m68k_incant *)); --static void add_fix PARAMS ((int, struct m68k_exp *, int, int)); -+static void add_fix PARAMS ((int, struct m68k_exp *, int, int, int)); - static void add_frag PARAMS ((symbolS *, offsetT, int)); - - /* Like addword, but goes BEFORE general operands */ -@@ -270,11 +282,12 @@ - /* The numo+1 kludge is so we can hit the low order byte of the prev word. - Blecch. */ - static void --add_fix (width, exp, pc_rel, pc_fix) -+add_fix (width, exp, pc_rel, pc_fix, base_rel) - int width; - struct m68k_exp *exp; - int pc_rel; - int pc_fix; -+ int base_rel; - { - the_ins.reloc[the_ins.nrel].n = ((width == 'B' || width == '3') - ? (the_ins.numo*2-1) -@@ -287,7 +300,8 @@ - #ifdef OBJ_ELF - the_ins.reloc[the_ins.nrel].pic_reloc = exp->pic_reloc; - #endif -- the_ins.reloc[the_ins.nrel++].pcrel = pc_rel; -+ the_ins.reloc[the_ins.nrel].pcrel = pc_rel; -+ the_ins.reloc[the_ins.nrel++].baserel = base_rel; - } - - /* Cause an extra frag to be generated here, inserting up to 10 bytes -@@ -463,6 +477,18 @@ - #define PCINDEX 8 /* PC+displacement+index */ - #define ABSTOPCREL 9 /* absolute relax down to 16-bit PC-relative */ - -+/* ABSREL (nice name;-)) is used in small-code, it might be implemented -+ * base-relative (a4), pc-relative, or base-relative with an extra add -+ * instruction to add the base-register. -+ * -+ * IMMREL is the analogous mode for immediate addressing of variables. This -+ * one can lead into situations, where a replacement is not possible: -+ * addl #foo,a0 -+ * can't be made pc-relative, if foo is in the text segment. */ -+ -+#define ABSREL 10 -+#define IMMREL 11 -+ - /* Note that calls to frag_var need to specify the maximum expansion - needed; this is currently 10 bytes for DBCC. */ - -@@ -524,6 +550,16 @@ - { 32767, -32768, 2, TAB (ABSTOPCREL, LONG) }, - { 0, 0, 4, 0 }, - { 1, 1, 0, 0 }, -+ -+ { 127, -128, 0, 0 }, -+ { 32767, -32768, 2, TAB (ABSREL, LONG) }, -+ { 0, 0, 6, 0 }, -+ { 1, 1, 0, 0 }, -+ -+ { 127, -128, 0, 0 }, -+ { 32767, -32768, 2, TAB (IMMREL, LONG) }, -+ { 0, 0, 6, 0 }, -+ { 1, 1, 0, 0 }, - }; - - /* These are the machine dependent pseudo-ops. These are included so -@@ -946,6 +982,17 @@ - } - } - } -+ else if (fixp->tc_fix_data) -+ { -+ switch (fixp->fx_size) -+ { -+ case 1: code = BFD_RELOC_8_BASEREL; break; -+ case 2: code = BFD_RELOC_16_BASEREL; break; -+ case 4: code = BFD_RELOC_32_BASEREL; break; -+ default: -+ abort (); -+ } -+ } - else - { - #define F(SZ,PCREL) (((SZ) << 1) + (PCREL)) -@@ -1937,7 +1984,18 @@ - else - nextword = get_num (&opP->disp, 0); - if (isvar (&opP->disp)) -- add_fix (s[1], &opP->disp, 0, 0); -+ { -+/* This doesn't work when the symbol is N_UNDF! We ignore this for now. */ -+ if (0 && flag_small_code) -+ { -+ add_frag (adds (&opP->disp), -+ offs (&opP->disp), -+ TAB (IMMREL, SZ_UNDEF)); -+ break; -+ } -+ else -+ add_fix(s[1], &opP->disp, 0, 0, opP->disp.baserel); -+ } - switch (s[1]) - { - case 'b': -@@ -2097,7 +2155,7 @@ - ) - { - addword (0x0170); -- add_fix ('l', &opP->disp, 1, 2); -+ add_fix ('l', &opP->disp, 1, 2, opP->disp.baserel); - } - else - { -@@ -2110,7 +2168,7 @@ - else - { - addword (0x0170); -- add_fix ('l', &opP->disp, 0, 0); -+ add_fix ('l', &opP->disp, 0, 0, opP->disp.baserel); - } - } - else -@@ -2128,10 +2186,10 @@ - { - if (opP->reg == PC) - { -- add_fix ('w', &opP->disp, 1, 0); -+ add_fix ('w', &opP->disp, 1, 0, opP->disp.baserel); - } - else -- add_fix ('w', &opP->disp, 0, 0); -+ add_fix ('w', &opP->disp, 0, 0, opP->disp.baserel); - } - } - addword (nextword); -@@ -2240,9 +2298,9 @@ - fit (possible on m68000) let the - fixup processing complain later. */ - if (opP->reg == PC) -- add_fix ('B', &opP->disp, 1, 1); -+ add_fix ('B', &opP->disp, 1, 1, 0); /* FIXME? -fnf */ - else -- add_fix ('B', &opP->disp, 0, 0); -+ add_fix ('B', &opP->disp, 0, 0, 0); /* FIXME? -fnf */ - } - else if (siz1 != SIZE_BYTE) - { -@@ -2372,9 +2430,9 @@ - if (siz1 != SIZE_UNSPEC && isvar (&opP->disp)) - { - if (opP->reg == PC || opP->reg == ZPC) -- add_fix (siz1 == SIZE_LONG ? 'l' : 'w', &opP->disp, 1, 2); -+ add_fix (siz1 == SIZE_LONG ? 'l' : 'w', &opP->disp, 1, 2, opP->disp.baserel); - else -- add_fix (siz1 == SIZE_LONG ? 'l' : 'w', &opP->disp, 0, 0); -+ add_fix (siz1 == SIZE_LONG ? 'l' : 'w', &opP->disp, 0, 0, opP->disp.baserel); - } - if (siz1 == SIZE_LONG) - addword (baseo >> 16); -@@ -2382,7 +2440,7 @@ - addword (baseo); - - if (siz2 != SIZE_UNSPEC && isvar (&opP->odisp)) -- add_fix (siz2 == SIZE_LONG ? 'l' : 'w', &opP->odisp, 0, 0); -+ add_fix (siz2 == SIZE_LONG ? 'l' : 'w', &opP->odisp, 0, 0, opP->disp.baserel); - if (siz2 == SIZE_LONG) - addword (outro >> 16); - if (siz2 != SIZE_UNSPEC) -@@ -2422,8 +2480,17 @@ - } - /* Fall through into long */ - case SIZE_LONG: -+/* This doesn't work when the symbol is N_UNDF! We ignore this for now. */ -+ if (0 && flag_small_code) -+ { -+ tmpreg=0x3A; /* 7.2 */ -+ add_frag (adds (&opP->disp), -+ offs (&opP->disp), -+ TAB (ABSREL, SZ_UNDEF)); -+ break; -+ } - if (isvar (&opP->disp)) -- add_fix ('l', &opP->disp, 0, 0); -+ add_fix ('l', &opP->disp, 0, 0, opP->disp.baserel); - - tmpreg = 0x39;/* 7.1 mode */ - addword (nextword >> 16); -@@ -2435,7 +2502,7 @@ - /* Fall through. */ - case SIZE_WORD: /* Word */ - if (isvar (&opP->disp)) -- add_fix ('w', &opP->disp, 0, 0); -+ add_fix ('w', &opP->disp, 0, 0, opP->disp.baserel); - - tmpreg = 0x38;/* 7.0 mode */ - addword (nextword); -@@ -2471,7 +2538,7 @@ - } - tmpreg = get_num (&opP->disp, tmpreg); - if (isvar (&opP->disp)) -- add_fix (s[1], &opP->disp, 0, 0); -+ add_fix (s[1], &opP->disp, 0, 0, opP->disp.baserel); - switch (s[1]) - { - case 'b': /* Danger: These do no check for -@@ -2537,10 +2604,10 @@ - switch (s[1]) - { - case 'B': -- add_fix ('B', &opP->disp, 1, -1); -+ add_fix ('B', &opP->disp, 1, -1, opP->disp.baserel); - break; - case 'W': -- add_fix ('w', &opP->disp, 1, 0); -+ add_fix ('w', &opP->disp, 1, 0, opP->disp.baserel); - addword (0); - break; - case 'L': -@@ -2548,7 +2615,7 @@ - if (! HAVE_LONG_BRANCH (current_architecture)) - as_warn (_("Can't use long branches on 68000/68010/5200")); - the_ins.opcode[0] |= 0xff; -- add_fix ('l', &opP->disp, 1, 0); -+ add_fix ('l', &opP->disp, 1, 0, opP->disp.baserel); - addword (0); - addword (0); - break; -@@ -2578,7 +2645,7 @@ - the_ins.opcode[0] |= 0x0006; - addword (0x4EF9); - } -- add_fix ('l', &opP->disp, 0, 0); -+ add_fix ('l', &opP->disp, 0, 0, opP->disp.baserel); - addword (0); - addword (0); - break; -@@ -2622,12 +2689,12 @@ - TAB (DBCCABSJ, SZ_UNDEF)); - break; - } -- add_fix ('w', &opP->disp, 1, 0); -+ add_fix ('w', &opP->disp, 1, 0, opP->disp.baserel); - } - addword (0); - break; - case 'C': /* Fixed size LONG coproc branches */ -- add_fix ('l', &opP->disp, 1, 0); -+ add_fix ('l', &opP->disp, 1, 0, opP->disp.baserel); - addword (0); - addword (0); - break; -@@ -2635,7 +2702,7 @@ - if (subs (&opP->disp) || (adds (&opP->disp) == 0)) - { - the_ins.opcode[the_ins.numo - 1] |= 0x40; -- add_fix ('l', &opP->disp, 1, 0); -+ add_fix ('l', &opP->disp, 1, 0, opP->disp.baserel); - addword (0); - addword (0); - } -@@ -2999,7 +3066,7 @@ - break; - case '_': /* used only for move16 absolute 32-bit address */ - if (isvar (&opP->disp)) -- add_fix ('l', &opP->disp, 0, 0); -+ add_fix ('l', &opP->disp, 0, 0, opP->disp.baserel); - tmpreg = get_num (&opP->disp, 80); - addword (tmpreg >> 16); - addword (tmpreg & 0xFFFF); -@@ -3318,6 +3385,12 @@ - int number; - }; - -+#if defined(TE_AMIGA) -+ #define FRAME ADDR5 -+#else -+ #define FRAME ADDR6 -+#endif -+ - static const struct init_entry init_table[] = - { - { "d0", DATA0 }, -@@ -3335,7 +3408,7 @@ - { "a4", ADDR4 }, - { "a5", ADDR5 }, - { "a6", ADDR6 }, -- { "fp", ADDR6 }, -+ { "fp", FRAME }, - { "a7", ADDR7 }, - { "sp", ADDR7 }, - { "ssp", ADDR7 }, -@@ -3657,7 +3730,8 @@ - &the_ins.reloc[m].exp, - the_ins.reloc[m].pcrel, - get_reloc_code (n, the_ins.reloc[m].pcrel, -- the_ins.reloc[m].pic_reloc)); -+ the_ins.reloc[m].pic_reloc), -+ the_ins.reloc[m].baserel); - fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix; - if (the_ins.reloc[m].wid == 'B') - fixP->fx_signed = 1; -@@ -3719,7 +3793,8 @@ - &the_ins.reloc[m].exp, - the_ins.reloc[m].pcrel, - get_reloc_code (wid, the_ins.reloc[m].pcrel, -- the_ins.reloc[m].pic_reloc)); -+ the_ins.reloc[m].pic_reloc), -+ the_ins.reloc[m].baserel); - fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix; - } - (void) frag_var (rs_machine_dependent, 10, 0, -@@ -3756,7 +3831,8 @@ - &the_ins.reloc[m].exp, - the_ins.reloc[m].pcrel, - get_reloc_code (wid, the_ins.reloc[m].pcrel, -- the_ins.reloc[m].pic_reloc)); -+ the_ins.reloc[m].pic_reloc), -+ the_ins.reloc[m].baserel); - fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix; - } - } -@@ -4363,7 +4439,7 @@ - as_bad_where (fragP->fr_file, fragP->fr_line, - _("short branch with zero offset: use :w")); - fixP = fix_new (fragP, fragP->fr_fix - 1, 1, fragP->fr_symbol, -- fragP->fr_offset, 1, RELAX_RELOC_PC8); -+ fragP->fr_offset, 1, RELAX_RELOC_PC8, 0); - fixP->fx_pcrel_adjust = -1; - break; - case TAB (BRANCHBWL, SHORT): -@@ -4372,22 +4448,26 @@ - case TAB (BRANCHBW, SHORT): - fragP->fr_opcode[1] = 0x00; - fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, -- 1, RELAX_RELOC_PC16); -+ 1, RELAX_RELOC_PC16, 0); - fragP->fr_fix += 2; - break; - case TAB (BRANCHBWL, LONG): - fragP->fr_opcode[1] = (char) 0xFF; - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, -- 1, RELAX_RELOC_PC32); -+ 1, RELAX_RELOC_PC32, 0); - fragP->fr_fix += 4; - break; - case TAB (BRABSJUNC, LONG): -- if (fragP->fr_opcode[0] == 0x61) /* jbsr */ -+ if (flag_small_code) -+ { -+ as_bad (_("Long branch in small code model, not supported.")); -+ } -+ else if (fragP->fr_opcode[0] == 0x61) /* jbsr */ - { - fragP->fr_opcode[0] = 0x4E; - fragP->fr_opcode[1] = (char) 0xB9; /* JSR with ABSL LONG operand */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, -- 0, RELAX_RELOC_ABS32); -+ 0, RELAX_RELOC_ABS32, 0); - fragP->fr_fix += 4; - } - else if (fragP->fr_opcode[0] == 0x60) /* jbra */ -@@ -4395,7 +4475,7 @@ - fragP->fr_opcode[0] = 0x4E; - fragP->fr_opcode[1] = (char) 0xF9; /* JMP with ABSL LONG operand */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, -- 0, RELAX_RELOC_ABS32); -+ 0, RELAX_RELOC_ABS32, 0); - fragP->fr_fix += 4; - } - else -@@ -4419,25 +4499,25 @@ - *buffer_address++ = (char) 0xf9; - fragP->fr_fix += 2; /* account for jmp instruction */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, -- fragP->fr_offset, 0, RELAX_RELOC_ABS32); -+ fragP->fr_offset, 0, RELAX_RELOC_ABS32, 0); - fragP->fr_fix += 4; - break; - case TAB (FBRANCH, SHORT): - know ((fragP->fr_opcode[1] & 0x40) == 0); - fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, -- 1, RELAX_RELOC_PC16); -+ 1, RELAX_RELOC_PC16, 0); - fragP->fr_fix += 2; - break; - case TAB (FBRANCH, LONG): - fragP->fr_opcode[1] |= 0x40; /* Turn on LONG bit */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, -- 1, RELAX_RELOC_PC32); -+ 1, RELAX_RELOC_PC32, 0); - fragP->fr_fix += 4; - break; - case TAB (DBCCLBR, SHORT): - case TAB (DBCCABSJ, SHORT): - fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, -- 1, RELAX_RELOC_PC16); -+ 1, RELAX_RELOC_PC16, 0); - fragP->fr_fix += 2; - break; - case TAB (DBCCLBR, LONG): -@@ -4454,7 +4534,7 @@ - - fragP->fr_fix += 6; /* account for bra/jmp instructions */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 1, -- RELAX_RELOC_PC32); -+ RELAX_RELOC_PC32, 0); - fragP->fr_fix += 4; - break; - case TAB (DBCCABSJ, LONG): -@@ -4471,14 +4551,14 @@ - - fragP->fr_fix += 6; /* account for bra/jmp instructions */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 0, -- RELAX_RELOC_ABS32); -+ RELAX_RELOC_ABS32, 0); - fragP->fr_fix += 4; - break; - case TAB (PCREL1632, SHORT): - fragP->fr_opcode[1] &= ~0x3F; - fragP->fr_opcode[1] |= 0x3A; /* 072 - mode 7.2 */ - fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol, -- fragP->fr_offset, 1, RELAX_RELOC_PC16); -+ fragP->fr_offset, 1, RELAX_RELOC_PC16, 0); - fragP->fr_fix += 2; - break; - case TAB (PCREL1632, LONG): -@@ -4488,7 +4568,7 @@ - *buffer_address++ = 0x70; - fragP->fr_fix += 2; - fixP = fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol, -- fragP->fr_offset, 1, RELAX_RELOC_PC32); -+ fragP->fr_offset, 1, RELAX_RELOC_PC32, 0); - fixP->fx_pcrel_adjust = 2; - fragP->fr_fix += 4; - break; -@@ -4496,7 +4576,7 @@ - assert (fragP->fr_fix >= 2); - buffer_address[-2] &= ~1; - fixP = fix_new (fragP, fragP->fr_fix - 1, 1, fragP->fr_symbol, -- fragP->fr_offset, 1, RELAX_RELOC_PC8); -+ fragP->fr_offset, 1, RELAX_RELOC_PC8, 0); - fixP->fx_pcrel_adjust = 1; - break; - case TAB (PCINDEX, SHORT): -@@ -4504,7 +4584,7 @@ - buffer_address[-2] |= 0x1; - buffer_address[-1] = 0x20; - fixP = fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol, -- fragP->fr_offset, 1, RELAX_RELOC_PC16); -+ fragP->fr_offset, 1, RELAX_RELOC_PC16, 0); - fixP->fx_pcrel_adjust = 2; - fragP->fr_fix += 2; - break; -@@ -4513,13 +4593,13 @@ - buffer_address[-2] |= 0x1; - buffer_address[-1] = 0x30; - fixP = fix_new (fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol, -- fragP->fr_offset, 1, RELAX_RELOC_PC32); -+ fragP->fr_offset, 1, RELAX_RELOC_PC32, 0); - fixP->fx_pcrel_adjust = 2; - fragP->fr_fix += 4; - break; - case TAB (ABSTOPCREL, SHORT): - fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, -- 1, RELAX_RELOC_PC16); -+ 1, RELAX_RELOC_PC16, 0); - fragP->fr_fix += 2; - break; - case TAB (ABSTOPCREL, LONG): -@@ -4530,9 +4610,81 @@ - fragP->fr_opcode[1] &= ~0x3F; - fragP->fr_opcode[1] |= 0x39; /* Mode 7.1 */ - fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, -- 0, RELAX_RELOC_ABS32); -+ 0, RELAX_RELOC_ABS32, 0); - fragP->fr_fix += 4; - break; -+ case TAB (ABSREL, BYTE): -+ as_bad (_("ABSREL_BYTE: how the ** does this look??")); -+ break; -+ case TAB (ABSREL, SHORT): -+ fragP->fr_opcode[1] &= ~0x3f; -+ fragP->fr_fix += 2; -+ if (S_GET_TYPE (fragP->fr_symbol) == N_TEXT) -+ { -+ /* so this is really a pc-relative address */ -+ fragP->fr_opcode[1] |= 0x3a; -+ fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, 1, NO_RELOC, 0); -+ break; -+ } -+ /* in that case we have to generate base-relative code -+ * (note: if we're in N_UNDF, this could as well be pc-relative, but the linker -+ * will have to do the final patch in that case) */ -+ fragP->fr_opcode[1] |= 0x2c; /* (a4) */ -+ fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC, 1); -+ break; -+ case TAB (ABSREL, LONG): -+ as_bad (_("ABSREL_LONG: sorry, not supported.")); -+ break; -+ case TAB (IMMREL, BYTE): -+ as_bad (_("IMMREL_BYTE: how the ** does this look??")); -+ break; -+ case TAB (IMMREL, SHORT): -+ if (S_GET_TYPE (fragP->fr_symbol) == N_TEXT) -+ { -+ /* we can only fix operations on data registers, not on */ -+ if ((fragP->fr_opcode[1] & 0x38) != 0) -+ { -+ /* use the normal reloc32, sigh... */ -+ fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC, 0); -+ fragP->fr_fix += 4; -+ break; -+ } -+ -+ /* so this is really a pc-relative address -+ * What we have to do now is a VERY UGLY AND BIG KLUDGE. Basically do the -+ * following thing: -+ * turn -+ * addl #foo,d0 (foo is N_TEXT) -+ * into -+ * pea foo(pc) -+ * addl (sp)+,d0 -+ */ -+ *buffer_address++ = fragP->fr_opcode[0]; /* save the original command */ -+ *buffer_address++ = fragP->fr_opcode[1]; -+ fragP->fr_opcode[0] = 0x48; /* PEA */ -+ fragP->fr_opcode[1] = 0x7a; -+ fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fragP->fr_offset, 1, NO_RELOC, 0); -+ -+ *buffer_address++ = 0x9f; /* sp@+ */ -+ fragP->fr_fix += 4; /* two byte fix, two byte code extension */ -+ break; -+ } -+ /* in that case we have to generate base-relative code -+ * (note: if we're in N_UNDF, this could as well be pc-relative, but the linker -+ * will have to do the final patch in that case) */ -+ -+ /* analogous (more or less;-)) to above, the following conversion is done -+ * turn -+ * addl #bar,d0 (bar is N_DATA) -+ * into -+ * addl #,d0 where is a baserel-reloc -+ * addl a4,d0 -+ */ -+ -+ fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fragP->fr_offset, 0, NO_RELOC, 1); -+ *buffer_address++ = 0xd0; -+ *buffer_address++ = 0x8c; -+ break; - } - } - -@@ -4579,7 +4731,7 @@ - { - fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE); - } -- else if (flag_short_refs) -+ else if (flag_short_refs || (0 && flag_small_code)) - { - /* Symbol is undefined and we want short ref. */ - fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT); -@@ -4651,6 +4803,21 @@ - break; - } - -+ case TAB (ABSREL, SZ_UNDEF): -+ { -+ if ((S_GET_SEGMENT (fragP->fr_symbol) == segment -+ && relaxable_symbol (fragP->fr_symbol)) -+ || flag_short_refs || (0 && flag_small_code)) -+ { -+ fragP->fr_subtype = TAB (ABSREL, SHORT); -+ } -+ else -+ { -+ fragP->fr_subtype = TAB (ABSREL, LONG); -+ } -+ break; -+ } -+ - default: - break; - } -@@ -4714,7 +4881,7 @@ - the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff; - the_bytes[6] = ri->r_symbolnum & 0x0ff; - the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) | -- ((ri->r_extern << 4) & 0x10)); -+ ((ri->r_extern << 4) & 0x10) | ((ri->r_baserel << 3) & 0x08)); - } - - #endif /* comment */ -@@ -4748,7 +4915,7 @@ - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[6] = r_symbolnum & 0x0ff; - where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) | -- (((!S_IS_DEFINED (fixP->fx_addsy)) << 4) & 0x10)); -+ (((!S_IS_DEFINED (fixP->fx_addsy)) << 4) & 0x10) | ((fixP->tc_fix_data << 3) & 0x08)); - } - #endif - -@@ -4788,7 +4955,7 @@ - md_number_to_chars (ptr, (valueT) 0x4EF9, 2); - md_number_to_chars (ptr + 2, (valueT) offset, 4); - fix_new (frag, (ptr + 2) - frag->fr_literal, 4, to_symbol, (offsetT) 0, -- 0, NO_RELOC); -+ 0, NO_RELOC, 0); - } - else - { -@@ -6732,7 +6899,7 @@ - #ifdef OBJ_ELF - const char *md_shortopts = "lSA:m:kQ:V"; - #else --const char *md_shortopts = "lSA:m:k"; -+const char *md_shortopts = "lSA:m:s:k"; - #endif - - struct option md_longopts[] = { -@@ -6779,6 +6946,13 @@ - flag_keep_pcrel = 1; - break; - -+ case 's': -+ if (!strcmp(arg, "c") || !strcmp(arg, "mallcode")) -+ flag_small_code = 1; -+ else -+ return 0; -+ break; -+ - case 'A': - if (*arg == 'm') - arg++; -@@ -6960,6 +7134,7 @@ - [default yes for 68020 and up]\n\ - -pic, -k generate position independent code\n\ - -S turn jbsr into jsr\n\ -+-smallcode, -sc small code model\n\ - --pcrel never turn PC-relative branches into absolute jumps\n\ - --register-prefix-optional\n\ - recognize register names without prefix character\n\ -@@ -7108,6 +7283,8 @@ - adjust = ((fixP->fx_pcrel_adjust & 0xff) ^ 0x80) - 0x80; - if (adjust == 64) - adjust = -1; -+ if (OBJ_AMIGAHUNK) -+ return -adjust; - return fixP->fx_where + fixP->fx_frag->fr_address - adjust; - } - diff --git a/patches/binutils-2.14/gas/config/tc-m68k.h.diff b/patches/binutils-2.14/gas/config/tc-m68k.h.diff deleted file mode 100644 index dcfa811..0000000 --- a/patches/binutils-2.14/gas/config/tc-m68k.h.diff +++ /dev/null @@ -1,43 +0,0 @@ ---- binutils-2.14/gas/config/tc-m68k.h 2003-01-23 13:51:05.000000000 +0100 -+++ binutils-2.14-patched/gas/config/tc-m68k.h 2013-04-24 18:38:13.000000000 +0200 -@@ -35,6 +35,9 @@ - #ifdef TE_NetBSD - #define TARGET_FORMAT "a.out-m68k-netbsd" - #endif -+#ifdef TE_AMIGA -+#define TARGET_FORMAT "a.out-amiga" -+#endif - #ifdef TE_LINUX - #define TARGET_FORMAT "a.out-m68k-linux" - #endif -@@ -43,6 +46,10 @@ - #endif - #endif - -+#ifdef OBJ_AMIGAHUNK -+#define TARGET_FORMAT "amiga" -+#endif -+ - #ifdef OBJ_ELF - #define TARGET_FORMAT "elf32-m68k" - #endif -@@ -81,6 +88,9 @@ - - #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (2<<16|OMAGIC); /* Magic byte for file header */ - #endif /* TE_SUN3 */ -+#ifdef TE_AMIGA -+#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC); /* Magic byte for file header */ -+#endif - - #ifndef AOUT_MACHTYPE - #define AOUT_MACHTYPE m68k_aout_machtype -@@ -209,6 +219,9 @@ - extern struct relax_type md_relax_table[]; - #define TC_GENERIC_RELAX_TABLE md_relax_table - -+#define TC_FIX_TYPE char -+#define TC_INIT_FIX_DATA(p) -+ - /* We can't do a byte jump to the next instruction, so in that case - force word mode by faking AIM. */ - #define md_prepare_relax_scan(fragP, address, aim, this_state, this_type) \ diff --git a/patches/binutils-2.14/gas/config/te-amiga.h b/patches/binutils-2.14/gas/config/te-amiga.h deleted file mode 100644 index a7b9372..0000000 --- a/patches/binutils-2.14/gas/config/te-amiga.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * te-amiga.h -- Amiga target environment declarations. - */ - -#define TE_AMIGA 1 - -#define LOCAL_LABELS_DOLLAR 1 -#define LOCAL_LABELS_FB 1 - -#ifdef OBJ_HEADER -#include OBJ_HEADER -#else -#include "obj-format.h" -#endif - -#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \ - do { \ - if ((SIZE) >= 4) \ - (P2VAR) = 2; \ - else if ((SIZE) >= 2) \ - (P2VAR) = 1; \ - else \ - (P2VAR) = 0; \ - } while (0) diff --git a/patches/binutils-2.14/gas/configure.diff b/patches/binutils-2.14/gas/configure.diff deleted file mode 100644 index 616e8a4..0000000 --- a/patches/binutils-2.14/gas/configure.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- binutils-2.14/gas/configure 2003-06-02 22:35:23.000000000 +0200 -+++ binutils-2.14/gas/configure 2013-05-18 12:03:00.000000000 +0200 -@@ -2536,6 +2536,8 @@ - m68hc11-*-* | m6811-*-*) fmt=elf ;; - m68hc12-*-* | m6812-*-*) fmt=elf ;; - -+ m68*-*-amigaoshunk) fmt=amigahunk em=amiga bfd_gas=yes ;; -+ m68*-*-amigaos*) fmt=aout em=amiga ;; - m68k-*-vxworks*) fmt=aout em=sun3 ;; - m68k-ericsson-ose) fmt=aout em=sun3 ;; - m68k-*-sunos*) fmt=aout em=sun3 ;; -@@ -3199,7 +3201,7 @@ - - case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in - yes-*-coff) need_bfd=yes ;; -- no-*-coff) need_bfd=yes -+ no-*-coff | yes-m68k-amigahunk | no-m68k-amigahunk) need_bfd=yes - cat >> confdefs.h <<\EOF - #define MANY_SEGMENTS 1 - EOF diff --git a/patches/binutils-2.14/gas/configure.in.diff b/patches/binutils-2.14/gas/configure.in.diff deleted file mode 100644 index e744440..0000000 --- a/patches/binutils-2.14/gas/configure.in.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- binutils-2.14/gas/configure.in 2003-06-02 22:35:23.000000000 +0200 -+++ binutils-2.14-patched/gas/configure.in 2013-04-24 18:37:53.000000000 +0200 -@@ -326,6 +328,8 @@ - m68hc11-*-* | m6811-*-*) fmt=elf ;; - m68hc12-*-* | m6812-*-*) fmt=elf ;; - -+ m68k-*-amigaoshunk) fmt=amigahunk em=amiga bfd_gas=yes ;; -+ m68k-*-amigaos*) fmt=aout em=amiga ;; - m68k-*-vxworks*) fmt=aout em=sun3 ;; - m68k-ericsson-ose) fmt=aout em=sun3 ;; - m68k-*-sunos*) fmt=aout em=sun3 ;; -@@ -895,7 +901,7 @@ - - case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in - yes-*-coff) need_bfd=yes ;; -- no-*-coff) need_bfd=yes -+ no-*-coff | yes-m68k-amigahunk | no-m68k-amigahunk) need_bfd=yes - AC_DEFINE(MANY_SEGMENTS, 1, [old COFF support?]) ;; - esac - diff --git a/patches/binutils-2.14/gas/read.c.diff b/patches/binutils-2.14/gas/read.c.diff deleted file mode 100644 index 24dcf3e..0000000 --- a/patches/binutils-2.14/gas/read.c.diff +++ /dev/null @@ -1,74 +0,0 @@ ---- binutils-2.14/gas/read.c 2003-06-02 22:35:23.000000000 +0200 -+++ binutils-2.14-patched/gas/read.c 2013-04-24 18:37:53.000000000 +0200 -@@ -48,6 +48,10 @@ - #define TC_START_LABEL(x,y) (x == ':') - #endif - -+#ifdef OBJ_AMIGAHUNK -+extern segT data_chip_section, bss_chip_section; -+#endif -+ - /* Set by the object-format or the target. */ - #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT - #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \ -@@ -274,6 +278,9 @@ - {"common", s_mri_common, 0}, - {"common.s", s_mri_common, 1}, - {"data", s_data, 0}, -+#ifdef OBJ_AMIGAHUNK -+ {"datachip", s_data_chip, 0}, -+#endif - {"dc", cons, 2}, - {"dc.b", cons, 1}, - {"dc.d", float_cons, 'd'}, -@@ -1552,6 +1559,17 @@ - demand_empty_rest_of_line (); - } - -+#ifdef OBJ_AMIGAHUNK -+void -+s_data_chip (ignore) -+ int ignore ATTRIBUTE_UNUSED; -+{ -+ int temp = get_absolute_expression (); -+ subseg_set (data_chip_section, (subsegT) temp); -+ demand_empty_rest_of_line (); -+} -+#endif -+ - /* Handle the .appfile pseudo-op. This is automatically generated by - do_scrub_chars when a preprocessor # line comment is seen with a - file name. This default definition may be overridden by the object -@@ -3717,7 +3735,7 @@ - - #ifdef BFD_ASSEMBLER - #ifdef TC_CONS_FIX_NEW -- TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp); -+ TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp, 0); - #else - { - bfd_reloc_code_real_type r; -@@ -3742,12 +3760,12 @@ - break; - } - fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, -- 0, r); -+ 0, r, 0); - } - #endif - #else - #ifdef TC_CONS_FIX_NEW -- TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp); -+ TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp, 0); - #else - /* Figure out which reloc number to use. Use TC_CONS_RELOC if - it is defined, otherwise use NO_RELOC if it is defined, -@@ -3760,7 +3778,7 @@ - #endif - #endif - fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0, -- TC_CONS_RELOC); -+ TC_CONS_RELOC, 0); - #endif /* TC_CONS_FIX_NEW */ - #endif /* BFD_ASSEMBLER */ - } diff --git a/patches/binutils-2.14/gas/read.h.diff b/patches/binutils-2.14/gas/read.h.diff deleted file mode 100644 index 39377eb..0000000 --- a/patches/binutils-2.14/gas/read.h.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- binutils-2.14/gas/read.h 2003-01-11 07:24:12.000000000 +0100 -+++ binutils-2.14-patched/gas/read.h 2013-04-24 18:37:53.000000000 +0200 -@@ -144,6 +144,9 @@ - extern void s_bad_endr PARAMS ((int)); - extern void s_comm PARAMS ((int)); - extern void s_data PARAMS ((int)); -+#ifdef OBJ_AMIGAHUNK -+extern void s_data_chip PARAMS ((int)); -+#endif - extern void s_desc PARAMS ((int)); - extern void s_else PARAMS ((int arg)); - extern void s_elseif PARAMS ((int arg)); diff --git a/patches/binutils-2.14/gas/tc.h.diff b/patches/binutils-2.14/gas/tc.h.diff deleted file mode 100644 index 7923125..0000000 --- a/patches/binutils-2.14/gas/tc.h.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- binutils-2.14/gas/tc.h 2001-11-15 22:28:53.000000000 +0100 -+++ binutils-2.14-patched/gas/tc.h 2013-04-24 18:38:14.000000000 +0200 -@@ -24,25 +24,6 @@ - - extern const pseudo_typeS md_pseudo_table[]; - --/* JF moved this here from as.h under the theory that nobody except MACHINE.c -- and write.c care about it anyway. */ -- --struct relax_type --{ -- /* Forward reach. Signed number. > 0. */ -- long rlx_forward; -- /* Backward reach. Signed number. < 0. */ -- long rlx_backward; -- -- /* Bytes length of this address. */ -- unsigned char rlx_length; -- -- /* Next longer relax-state. 0 means there is no 'next' relax-state. */ -- relax_substateT rlx_more; --}; -- --typedef struct relax_type relax_typeS; -- - extern const int md_reloc_size; /* Size of a relocation record */ - - char *md_atof PARAMS ((int what_statement_type, char *literalP, int *sizeP)); diff --git a/patches/binutils-2.14/gas/write.c.diff b/patches/binutils-2.14/gas/write.c.diff deleted file mode 100644 index c88e95c..0000000 --- a/patches/binutils-2.14/gas/write.c.diff +++ /dev/null @@ -1,133 +0,0 @@ ---- binutils-2.14/gas/write.c 2003-04-07 05:54:00.000000000 +0200 -+++ binutils-2.14-patched/gas/write.c 2013-04-24 18:38:14.000000000 +0200 -@@ -160,7 +160,7 @@ - static fixS *fix_new_internal PARAMS ((fragS *, int where, int size, - symbolS *add, symbolS *sub, - offsetT offset, int pcrel, -- RELOC_ENUM r_type)); -+ RELOC_ENUM r_type, int baserel)); - #if defined (BFD_ASSEMBLER) || (!defined (BFD) && !defined (OBJ_VMS)) - static long fixup_segment PARAMS ((fixS *, segT)); - #endif -@@ -190,7 +190,7 @@ - - static fixS * - fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel, -- r_type) -+ r_type, baserel) - fragS *frag; /* Which frag? */ - int where; /* Where in that frag? */ - int size; /* 1, 2, or 4 usually. */ -@@ -199,6 +199,7 @@ - offsetT offset; /* X_add_number. */ - int pcrel; /* TRUE if PC-relative relocation. */ - RELOC_ENUM r_type ATTRIBUTE_UNUSED; /* Relocation type. */ -+ int baserel ATTRIBUTE_UNUSED; /* TRUE if base-relative data */ - { - fixS *fixP; - -@@ -239,6 +240,7 @@ - #endif - - #ifdef TC_FIX_TYPE -+ fixP->tc_fix_data = baserel; - TC_INIT_FIX_DATA (fixP); - #endif - -@@ -283,7 +285,7 @@ - /* Create a fixup relative to a symbol (plus a constant). */ - - fixS * --fix_new (frag, where, size, add_symbol, offset, pcrel, r_type) -+fix_new (frag, where, size, add_symbol, offset, pcrel, r_type, baserel) - fragS *frag; /* Which frag? */ - int where; /* Where in that frag? */ - int size; /* 1, 2, or 4 usually. */ -@@ -291,9 +293,10 @@ - offsetT offset; /* X_add_number. */ - int pcrel; /* TRUE if PC-relative relocation. */ - RELOC_ENUM r_type; /* Relocation type. */ -+ int baserel; /* TRUE if base-relative data */ - { - return fix_new_internal (frag, where, size, add_symbol, -- (symbolS *) NULL, offset, pcrel, r_type); -+ (symbolS *) NULL, offset, pcrel, r_type, baserel); - } - - /* Create a fixup for an expression. Currently we only support fixups -@@ -301,13 +304,14 @@ - file formats support anyhow. */ - - fixS * --fix_new_exp (frag, where, size, exp, pcrel, r_type) -+fix_new_exp (frag, where, size, exp, pcrel, r_type, baserel) - fragS *frag; /* Which frag? */ - int where; /* Where in that frag? */ - int size; /* 1, 2, or 4 usually. */ - expressionS *exp; /* Expression. */ - int pcrel; /* TRUE if PC-relative relocation. */ - RELOC_ENUM r_type; /* Relocation type. */ -+ int baserel; /* TRUE if base-relative data */ - { - symbolS *add = NULL; - symbolS *sub = NULL; -@@ -333,7 +337,7 @@ - exp->X_add_symbol = stmp; - exp->X_add_number = 0; - -- return fix_new_exp (frag, where, size, exp, pcrel, r_type); -+ return fix_new_exp (frag, where, size, exp, pcrel, r_type, baserel); - } - - case O_symbol_rva: -@@ -371,7 +375,7 @@ - break; - } - -- return fix_new_internal (frag, where, size, add, sub, off, pcrel, r_type); -+ return fix_new_internal (frag, where, size, add, sub, off, pcrel, r_type, baserel); - } - - /* Generic function to determine whether a fixup requires a relocation. */ -@@ -1666,17 +1670,17 @@ - #ifdef TC_CONS_FIX_NEW - TC_CONS_FIX_NEW (lie->frag, - lie->word_goes_here - lie->frag->fr_literal, -- 2, &exp); -+ 2, &exp, 0); - #else - fix_new_exp (lie->frag, - lie->word_goes_here - lie->frag->fr_literal, -- 2, &exp, 0, BFD_RELOC_16); -+ 2, &exp, 0, BFD_RELOC_16, 0); - #endif - #else - #if defined(TC_SPARC) || defined(TC_A29K) || defined(NEED_FX_R_TYPE) - fix_new_exp (lie->frag, - lie->word_goes_here - lie->frag->fr_literal, -- 2, &exp, 0, NO_RELOC); -+ 2, &exp, 0, NO_RELOC, 0); - #else - #ifdef TC_NS32K - fix_new_ns32k_exp (lie->frag, -@@ -1685,7 +1689,7 @@ - #else - fix_new_exp (lie->frag, - lie->word_goes_here - lie->frag->fr_literal, -- 2, &exp, 0, 0); -+ 2, &exp, 0, 0, 0); - #endif /* TC_NS32K */ - #endif /* TC_SPARC|TC_A29K|NEED_FX_R_TYPE */ - #endif /* BFD_ASSEMBLER */ -@@ -2740,6 +2744,11 @@ - } - } - -+#if !defined(BFD_ASSEMBLER) && !defined(MANY_SEGMENTS) -+ if (fixP->tc_fix_data && add_number != fixP->fx_offset) -+ add_number -= text_last_frag->fr_address; -+#endif -+ - if (!fixP->fx_done) - md_apply_fix3 (fixP, &add_number, this_segment); - diff --git a/patches/binutils-2.14/gas/write.h.diff b/patches/binutils-2.14/gas/write.h.diff deleted file mode 100644 index a4f160c..0000000 --- a/patches/binutils-2.14/gas/write.h.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- binutils-2.14/gas/write.h 2002-09-20 01:51:35.000000000 +0200 -+++ binutils-2.14-patched/gas/write.h 2013-04-24 18:38:14.000000000 +0200 -@@ -198,17 +198,18 @@ - #ifdef BFD_ASSEMBLER - extern fixS *fix_new - PARAMS ((fragS * frag, int where, int size, symbolS * add_symbol, -- offsetT offset, int pcrel, bfd_reloc_code_real_type r_type)); -+ offsetT offset, int pcrel, bfd_reloc_code_real_type r_type, -+ int baserel)); - extern fixS *fix_new_exp - PARAMS ((fragS * frag, int where, int size, expressionS *exp, int pcrel, -- bfd_reloc_code_real_type r_type)); -+ bfd_reloc_code_real_type r_type, int baserel)); - #else - extern fixS *fix_new - PARAMS ((fragS * frag, int where, int size, symbolS * add_symbol, -- offsetT offset, int pcrel, int r_type)); -+ offsetT offset, int pcrel, int r_type, int baserel)); - extern fixS *fix_new_exp - PARAMS ((fragS * frag, int where, int size, expressionS *exp, int pcrel, -- int r_type)); -+ int r_type, int baserel)); - #endif - - extern void write_print_statistics PARAMS ((FILE *)); diff --git a/patches/binutils-2.14/ld/Makefile.am.diff b/patches/binutils-2.14/ld/Makefile.am.diff deleted file mode 100644 index dba2e1c..0000000 --- a/patches/binutils-2.14/ld/Makefile.am.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- binutils-2.14/ld/Makefile.am 2003-04-24 14:36:07.000000000 +0200 -+++ binutils-2.14-patched/ld/Makefile.am 2013-04-24 18:37:52.000000000 +0200 -@@ -111,6 +111,8 @@ - ea29k.o \ - eaixppc.o \ - eaixrs6.o \ -+ eamiga.o \ -+ eamiga_bss.o \ - ealpha.o \ - earcelf.o \ - earm_epoc_pe.o \ -@@ -432,6 +440,12 @@ - GEN_DEPENDS = $(srcdir)/genscripts.sh stringify.sed - @TDIRS@ - -+eamiga.c: $(srcdir)/emulparams/amiga.sh\ -+ $(srcdir)/emultempl/amiga.em $(srcdir)/scripttempl/amiga.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} amiga "$(tdir_amiga)" -+eamiga_bss.c: $(srcdir)/emulparams/amiga_bss.sh\ -+ $(srcdir)/emultempl/amiga.em $(srcdir)/scripttempl/amiga_bss.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} amiga_bss "$(tdir_amiga_bss)" - ea29k.c: $(srcdir)/emulparams/a29k.sh \ - $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/a29k.sc ${GEN_DEPENDS} - ${GENSCRIPTS} a29k "$(tdir_a29k)" diff --git a/patches/binutils-2.14/ld/Makefile.in.diff b/patches/binutils-2.14/ld/Makefile.in.diff deleted file mode 100644 index 7693ae0..0000000 --- a/patches/binutils-2.14/ld/Makefile.in.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- binutils-2.14/ld/Makefile.in 2003-04-24 14:36:07.000000000 +0200 -+++ binutils-2.14-patched/ld/Makefile.in 2013-04-24 18:37:45.000000000 +0200 -@@ -225,6 +272,8 @@ - ea29k.o \ - eaixppc.o \ - eaixrs6.o \ -+ eamiga.o \ -+ eamiga_bss.o \ - ealpha.o \ - earcelf.o \ - earm_epoc_pe.o \ -@@ -1158,6 +1183,12 @@ - cp ${srcdir}/emultempl/$(STRINGIFY) stringify.sed - @TDIRS@ - -+eamiga.c: $(srcdir)/emulparams/amiga.sh\ -+ $(srcdir)/emultempl/amiga.em $(srcdir)/scripttempl/amiga.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} amiga "$(tdir_amiga)" -+eamiga_bss.c: $(srcdir)/emulparams/amiga_bss.sh\ -+ $(srcdir)/emultempl/amiga.em $(srcdir)/scripttempl/amiga_bss.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} amiga_bss "$(tdir_amiga_bss)" - ea29k.c: $(srcdir)/emulparams/a29k.sh \ - $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/a29k.sc ${GEN_DEPENDS} - ${GENSCRIPTS} a29k "$(tdir_a29k)" diff --git a/patches/binutils-2.14/ld/configure.tgt.diff b/patches/binutils-2.14/ld/configure.tgt.diff deleted file mode 100644 index 43669dd..0000000 --- a/patches/binutils-2.14/ld/configure.tgt.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- binutils-2.14/ld/configure.tgt 2003-06-12 16:25:52.000000000 +0200 -+++ binutils-2.14-patched/ld/configure.tgt 2013-04-24 18:37:52.000000000 +0200 -@@ -340,6 +341,7 @@ - m68k-sony-*) targ_emul=news ;; - m68k-hp-bsd*) targ_emul=hp300bsd ;; - m68*-motorola-sysv*) targ_emul=delta68 ;; -+m68*-*-amigaos*) targ_emul=amiga ; targ_extra_emuls=amiga_bss;; - m68*-*-aout) targ_emul=m68kaout ;; - m68*-*-coff) targ_emul=m68kcoff ;; - m68*-*-elf) targ_emul=m68kelf ;; diff --git a/patches/binutils-2.14/ld/emulparams/amiga.sh b/patches/binutils-2.14/ld/emulparams/amiga.sh deleted file mode 100644 index c2915d4..0000000 --- a/patches/binutils-2.14/ld/emulparams/amiga.sh +++ /dev/null @@ -1,6 +0,0 @@ -SCRIPT_NAME=amiga -OUTPUT_FORMAT="amiga" -TEXT_START_ADDR=0x0 -SEGMENT_SIZE=0x0 -TEMPLATE_NAME=amiga -ARCH=m68k diff --git a/patches/binutils-2.14/ld/emulparams/amiga_bss.sh b/patches/binutils-2.14/ld/emulparams/amiga_bss.sh deleted file mode 100644 index 5405d73..0000000 --- a/patches/binutils-2.14/ld/emulparams/amiga_bss.sh +++ /dev/null @@ -1,6 +0,0 @@ -SCRIPT_NAME=amiga_bss -OUTPUT_FORMAT="amiga" -TEXT_START_ADDR=0x0 -SEGMENT_SIZE=0x0 -TEMPLATE_NAME=amiga -ARCH=m68k diff --git a/patches/binutils-2.14/ld/emultempl/amiga.em b/patches/binutils-2.14/ld/emultempl/amiga.em deleted file mode 100644 index f3dd63e..0000000 --- a/patches/binutils-2.14/ld/emultempl/amiga.em +++ /dev/null @@ -1,288 +0,0 @@ -# This shell script emits a C file. -*- C -*- -# It does some substitutions. -cat >e${EMULATION_NAME}.c <the_bfd)==bfd_target_amiga_flavour) - { - for (s=inp->the_bfd->sections;s!=NULL;s=s->next) - amiga_per_section(s)->attribute=inp->amiga_attribute; - } -} - -void -amiga_after_allocation () -{ - if (0) /* Does not work at the moment */ - lang_for_each_input_file (amiga_assign_attribute); -} - -#endif - -static void -gld${EMULATION_NAME}_before_parse () -{ - write_debug_hunk = 0; - -#if defined(TARGET_IS_amiga_bss) - amiga_base_relative = 1; -#endif - -#ifndef TARGET_ /* I.e., if not generic. */ - ldfile_output_architecture = bfd_arch_${ARCH}; -#endif /* not TARGET_ */ -} - -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 <> e${EMULATION_NAME}.c -echo ' ; else if (link_info.relocateable == 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 <>e${EMULATION_NAME}.c <h->type == bfd_link_hash_defined -- || p->h->type == bfd_link_hash_defweak) -+ /* dgv -- libnix v1.1 uses absolute sets that are also explicitly -+ defined in the library so that the sets need to be build even -+ if the symbol is defined */ -+ if ((bfd_get_flavour (output_bfd) != bfd_target_amiga_flavour) && -+ (p->h->type == bfd_link_hash_defined -+ || p->h->type == bfd_link_hash_defweak)) - continue; - - /* For each set we build: -@@ -361,15 +365,21 @@ - - if (e->name != NULL) - minfo ("%T\n", e->name); -- else -+ else if (e->section->owner) - minfo ("%G\n", e->section->owner, e->section, e->value); -+ else -+ minfo ("%s\n", "** ABS **"); - } - - /* Need SEC_KEEP for --gc-sections. */ - if (! bfd_is_abs_section (e->section)) - e->section->flags |= SEC_KEEP; - -- if (link_info.relocateable) -+ /* dgv -- on the amiga, we want the constructors to be relocateable -+ objects. However, this should be arranged somewhere else (FIXME) */ -+ if (link_info.relocateable || -+ (bfd_get_flavour (output_bfd) == bfd_target_amiga_flavour && -+ e->section != bfd_abs_section_ptr)) - lang_add_reloc (p->reloc, howto, e->section, e->name, - exp_intop (e->value)); - else diff --git a/patches/binutils-2.14/ld/ldfile.c.diff b/patches/binutils-2.14/ld/ldfile.c.diff deleted file mode 100644 index c686387..0000000 --- a/patches/binutils-2.14/ld/ldfile.c.diff +++ /dev/null @@ -1,109 +0,0 @@ ---- binutils-2.14/ld/ldfile.c 2003-04-18 17:33:49.000000000 +0200 -+++ binutils-2.14-patched/ld/ldfile.c 2013-04-24 18:37:50.000000000 +0200 -@@ -74,6 +74,40 @@ - static bfd_boolean is_sysrooted_pathname - PARAMS ((const char *, bfd_boolean)); - -+/* Flavour support. */ -+ -+static int flavors_cmp PARAMS ((const void *f1, const void *f2)); -+ -+static int n_flavors, flavors_len; -+static char **flavors; -+ -+static int -+flavors_cmp (f1, f2) -+ const void *f1, *f2; -+{ -+ return strcmp (*(char **)f1, *(char **)f2); -+} -+ -+void -+ldfile_sort_flavors () -+{ -+ if (n_flavors > 1) -+ qsort ((void *) flavors, n_flavors, sizeof (char **), flavors_cmp); -+} -+ -+void -+ldfile_add_flavor (name) -+ const char *name; -+{ -+ n_flavors++; -+ if (flavors) -+ flavors = (char **) xrealloc ((PTR)flavors, n_flavors * sizeof (char *)); -+ else -+ flavors = (char **) xmalloc (sizeof (char *)); -+ flavors [n_flavors-1] = (char *) name; -+ flavors_len += strlen (name); -+} -+ - /* Test whether a pathname, after canonicalization, is the same or a - sub-directory of the sysroot directory. */ - -@@ -304,6 +338,7 @@ - const char *lib; - const char *suffix; - { -+ char *flavor_dir = (char *) alloca (flavors_len + n_flavors + 1); - search_dirs_type *search; - - /* If this is not an archive, try to open it in the current -@@ -337,6 +372,7 @@ - search = search->next) - { - char *string; -+ int i, count; - - if (entry->dynamic && ! link_info.relocateable) - { -@@ -347,6 +383,7 @@ - } - } - -+#if 0 - string = (char *) xmalloc (strlen (search->name) - + strlen (slash) - + strlen (lib) -@@ -369,6 +406,41 @@ - } - - free (string); -+#else -+ for (count=n_flavors; count>=0; count--) { -+ -+ *flavor_dir = '\0'; -+ for (i=0; iname) -+ + strlen (slash) -+ + strlen (flavor_dir) -+ + strlen (lib) -+ + strlen (entry->filename) -+ + strlen (arch) -+ + strlen (suffix) -+ + 1); -+ -+ if (entry->is_archive) -+ sprintf (string, "%s%s%s%s%s%s%s", search->name, slash, flavor_dir, -+ lib, entry->filename, arch, suffix); -+ else if (entry->filename[0] == '/' || entry->filename[0] == '.') -+ strcpy (string, entry->filename); -+ else -+ sprintf (string, "%s%s%s%s", search->name, slash, flavor_dir, -+ entry->filename); -+ -+ if (ldfile_try_open_bfd (string, entry)) -+ { -+ entry->filename = string; -+ return TRUE; -+ } -+ -+ free (string); -+ } -+#endif - } - - return FALSE; diff --git a/patches/binutils-2.14/ld/ldfile.h.diff b/patches/binutils-2.14/ld/ldfile.h.diff deleted file mode 100644 index 845c86e..0000000 --- a/patches/binutils-2.14/ld/ldfile.h.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- binutils-2.14/ld/ldfile.h 2003-03-03 21:00:35.000000000 +0100 -+++ binutils-2.14-patched/ld/ldfile.h 2013-04-24 18:37:50.000000000 +0200 -@@ -61,4 +61,9 @@ - PARAMS ((const char *arch, struct lang_input_statement_struct *, - const char *lib, const char *suffix)); - -+extern void ldfile_sort_flavors -+ PARAMS ((void)); -+extern void ldfile_add_flavor -+ PARAMS ((const char *)); -+ - #endif diff --git a/patches/binutils-2.14/ld/ldlang.h.diff b/patches/binutils-2.14/ld/ldlang.h.diff deleted file mode 100644 index e2337a2..0000000 --- a/patches/binutils-2.14/ld/ldlang.h.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- binutils-2.14/ld/ldlang.h 2003-03-03 21:00:35.000000000 +0100 -+++ binutils-2.14-patched/ld/ldlang.h 2013-04-24 18:37:50.000000000 +0200 -@@ -255,6 +255,8 @@ - #endif - const char *target; - bfd_boolean real; -+ /* Added for AMIGA support of section attributes */ -+ int amiga_attribute; - } lang_input_statement_type; - - typedef struct { diff --git a/patches/binutils-2.14/ld/scripttempl/amiga.sc b/patches/binutils-2.14/ld/scripttempl/amiga.sc deleted file mode 100644 index f5c9d69..0000000 --- a/patches/binutils-2.14/ld/scripttempl/amiga.sc +++ /dev/null @@ -1,49 +0,0 @@ -cat <&5; (eval $ac_link) 2>&5; }; then - for file in conftest.*; do - case $file in -- *.c | *.o | *.obj | *.ilk | *.pdb) ;; -+ *.c | *.o | *.obj | *.ilk | *.pdb | *.dSYM) ;; - *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; - esac - done -@@ -2407,7 +2407,7 @@ - if { (eval echo configure:2408: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then - for file in conftest.*; do - case $file in -- *.c | *.o | *.obj | *.ilk | *.pdb) ;; -+ *.c | *.o | *.obj | *.ilk | *.pdb | *.dSYM) ;; - *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; - esac - done diff --git a/patches/binutils-2.14/opcodes/m68k-dis.c.diff b/patches/binutils-2.14/opcodes/m68k-dis.c.diff deleted file mode 100644 index ca55226..0000000 --- a/patches/binutils-2.14/opcodes/m68k-dis.c.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- binutils-2.14/opcodes/m68k-dis.c 2002-06-08 09:29:27.000000000 +0200 -+++ binutils-2.14-patched/opcodes/m68k-dis.c 2013-04-24 18:38:26.000000000 +0200 -@@ -53,7 +53,7 @@ - - static char *const reg_names[] = { - "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", -- "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", -+ "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", - "%ps", "%pc" - }; - diff --git a/submodules/binutils-2.14 b/submodules/binutils-2.14 new file mode 160000 index 0000000..2a89d7f --- /dev/null +++ b/submodules/binutils-2.14 @@ -0,0 +1 @@ +Subproject commit 2a89d7fe20a0d8621c9dd1fb7038ae5ea812e699 diff --git a/toolchain-m68k b/toolchain-m68k index 61e0252..4f06947 100755 --- a/toolchain-m68k +++ b/toolchain-m68k @@ -695,7 +695,7 @@ if __name__ == "__main__": default='build', help='perform action') parser.add_argument('args', metavar='ARGS', type=str, nargs='*', help='action arguments') - parser.add_argument('--binutils', choices=['2.9.1'], default='2.9.1', + parser.add_argument('--binutils', choices=['2.9.1', '2.14'], default='2.9.1', help='desired binutils version') parser.add_argument('--gcc', choices=['2.95.3'], default='2.95.3', help='desired gcc version')