Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 362559
Collapse All | Expand All

(-)binutils-2.21.51.0.7/bfd/Makefile.am (+2 lines)
Lines 379-384 Link Here
379
	peigen.lo \
379
	peigen.lo \
380
	plugin.lo \
380
	plugin.lo \
381
	ppcboot.lo \
381
	ppcboot.lo \
382
	prg-mint.lo \
382
	reloc16.lo \
383
	reloc16.lo \
383
	riscix.lo \
384
	riscix.lo \
384
	som.lo \
385
	som.lo \
Lines 559-564 Link Here
559
	pei-sh.c \
560
	pei-sh.c \
560
	plugin.c \
561
	plugin.c \
561
	ppcboot.c \
562
	ppcboot.c \
563
	prg-mint.c \
562
	reloc16.c \
564
	reloc16.c \
563
	riscix.c \
565
	riscix.c \
564
	som.c \
566
	som.c \
(-)binutils-2.21.51.0.7/bfd/Makefile.in (+2 lines)
Lines 679-684 Link Here
679
	peigen.lo \
679
	peigen.lo \
680
	plugin.lo \
680
	plugin.lo \
681
	ppcboot.lo \
681
	ppcboot.lo \
682
	prg-mint.lo \
682
	reloc16.lo \
683
	reloc16.lo \
683
	riscix.lo \
684
	riscix.lo \
684
	som.lo \
685
	som.lo \
Lines 859-864 Link Here
859
	pei-sh.c \
860
	pei-sh.c \
860
	plugin.c \
861
	plugin.c \
861
	ppcboot.c \
862
	ppcboot.c \
863
	prg-mint.c \
862
	reloc16.c \
864
	reloc16.c \
863
	riscix.c \
865
	riscix.c \
864
	som.c \
866
	som.c \
(-)binutils-2.21.51.0.7/bfd/acinclude.m4 (-1 / +1 lines)
Lines 5-11 Link Here
5
[AC_REQUIRE([AC_CANONICAL_TARGET])
5
[AC_REQUIRE([AC_CANONICAL_TARGET])
6
case "${host}" in
6
case "${host}" in
7
changequote(,)dnl
7
changequote(,)dnl
8
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
8
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows* | *-*-mint*)
9
changequote([,])dnl
9
changequote([,])dnl
10
  AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
10
  AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
11
esac])dnl
11
esac])dnl
(-)binutils-2.21.51.0.7/bfd/aoutx.h (+12 lines)
Lines 1841-1846 Link Here
1841
  bfd_byte buffer[BYTES_IN_WORD];
1841
  bfd_byte buffer[BYTES_IN_WORD];
1842
  bfd_size_type amt = BYTES_IN_WORD;
1842
  bfd_size_type amt = BYTES_IN_WORD;
1843
1843
1844
  /* The MiNT backend writes past the string table.  It therefore has to
1845
     know about the table size.  */
1846
  obj_aout_external_string_size (abfd) = _bfd_stringtab_size (tab) +
1847
    BYTES_IN_WORD;
1848
1844
  /* The string table starts with the size.  */
1849
  /* The string table starts with the size.  */
1845
  PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
1850
  PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
1846
  if (bfd_bwrite ((void *) buffer, amt, abfd) != amt)
1851
  if (bfd_bwrite ((void *) buffer, amt, abfd) != amt)
Lines 4220-4229 Link Here
4220
		return FALSE;
4225
		return FALSE;
4221
	    }
4226
	    }
4222
4227
4228
#ifdef MY_final_link_relocate_rel
4229
	  r = MY_final_link_relocate_rel (howto,
4230
					  input_bfd, input_section,
4231
					  contents, r_addr, relocation,
4232
					  (bfd_vma) 0, rel);
4233
#else
4223
	  r = MY_final_link_relocate (howto,
4234
	  r = MY_final_link_relocate (howto,
4224
				      input_bfd, input_section,
4235
				      input_bfd, input_section,
4225
				      contents, r_addr, relocation,
4236
				      contents, r_addr, relocation,
4226
				      (bfd_vma) 0);
4237
				      (bfd_vma) 0);
4238
#endif
4227
	}
4239
	}
4228
4240
4229
      if (r != bfd_reloc_ok)
4241
      if (r != bfd_reloc_ok)
(-)binutils-2.21.51.0.7/bfd/bfd-in.h (+9 lines)
Lines 742-747 Link Here
742
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
742
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
743
  (bfd *, struct bfd_link_info *);
743
  (bfd *, struct bfd_link_info *);
744
744
745
/* MiNT executable support routines for the linker.  */
746
747
extern bfd_boolean bfd_m68kmint_set_extended_flags
748
  (bfd *, flagword);
749
extern bfd_boolean bfd_m68kmint_set_stack_size
750
  (bfd *, bfd_signed_vma);
751
extern bfd_boolean bfd_m68kmint_add_tpa_relocation_entry
752
  (bfd *, bfd_vma);
753
745
/* mmap hacks */
754
/* mmap hacks */
746
755
747
struct _bfd_window_internal;
756
struct _bfd_window_internal;
(-)binutils-2.21.51.0.7/bfd/bfd-in2.h (+9 lines)
Lines 749-754 Link Here
749
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
749
extern bfd_boolean bfd_sparclinux_size_dynamic_sections
750
  (bfd *, struct bfd_link_info *);
750
  (bfd *, struct bfd_link_info *);
751
751
752
/* MiNT executable support routines for the linker.  */
753
754
extern bfd_boolean bfd_m68kmint_set_extended_flags
755
  (bfd *, flagword);
756
extern bfd_boolean bfd_m68kmint_set_stack_size
757
  (bfd *, bfd_signed_vma);
758
extern bfd_boolean bfd_m68kmint_add_tpa_relocation_entry
759
  (bfd *, bfd_vma);
760
752
/* mmap hacks */
761
/* mmap hacks */
753
762
754
struct _bfd_window_internal;
763
struct _bfd_window_internal;
(-)binutils-2.21.51.0.7/bfd/config.bfd (+5 lines)
Lines 823-828 Link Here
823
    # targ_selvecs=m68kmach3_vec
823
    # targ_selvecs=m68kmach3_vec
824
    # targ_cflags=-DSTAT_FOR_EXEC
824
    # targ_cflags=-DSTAT_FOR_EXEC
825
    ;;
825
    ;;
826
  m68*-*-mint*)
827
    targ_defvec=aout0_big_vec
828
    targ_selvecs=m68kmint_prg_vec
829
    targ_underscore=yes
830
    ;;
826
  m68*-hp*-netbsd*)
831
  m68*-hp*-netbsd*)
827
    targ_defvec=m68k4knetbsd_vec
832
    targ_defvec=m68k4knetbsd_vec
828
    targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec"
833
    targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec"
(-)binutils-2.21.51.0.7/bfd/configure (-1 / +2 lines)
Lines 13623-13629 Link Here
13623
13623
13624
13624
13625
case "${host}" in
13625
case "${host}" in
13626
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
13626
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows* | *-*-mint*)
13627
13627
13628
$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
13628
$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
13629
 ;;
13629
 ;;
Lines 15237-15242 Link Here
15237
    m68kcoff_vec)		tb="$tb coff-m68k.lo cofflink.lo" ;;
15237
    m68kcoff_vec)		tb="$tb coff-m68k.lo cofflink.lo" ;;
15238
    m68kcoffun_vec)		tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
15238
    m68kcoffun_vec)		tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
15239
    m68klinux_vec)		tb="$tb m68klinux.lo aout32.lo" ;;
15239
    m68klinux_vec)		tb="$tb m68klinux.lo aout32.lo" ;;
15240
    m68kmint_prg_vec)		tb="$tb prg-mint.lo aout32.lo" ;;
15240
    m68knetbsd_vec)		tb="$tb m68knetbsd.lo aout32.lo" ;;
15241
    m68knetbsd_vec)		tb="$tb m68knetbsd.lo aout32.lo" ;;
15241
    m68ksysvcoff_vec)		tb="$tb coff-svm68k.lo cofflink.lo" ;;
15242
    m68ksysvcoff_vec)		tb="$tb coff-svm68k.lo cofflink.lo" ;;
15242
    m88kbcs_vec)		tb="$tb coff-m88k.lo" ;;
15243
    m88kbcs_vec)		tb="$tb coff-m88k.lo" ;;
(-)binutils-2.21.51.0.7/bfd/configure.in (+1 lines)
Lines 880-885 Link Here
880
    m68kcoff_vec)		tb="$tb coff-m68k.lo cofflink.lo" ;;
880
    m68kcoff_vec)		tb="$tb coff-m68k.lo cofflink.lo" ;;
881
    m68kcoffun_vec)		tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
881
    m68kcoffun_vec)		tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
882
    m68klinux_vec)		tb="$tb m68klinux.lo aout32.lo" ;;
882
    m68klinux_vec)		tb="$tb m68klinux.lo aout32.lo" ;;
883
    m68kmint_prg_vec)		tb="$tb prg-mint.lo aout32.lo" ;;
883
    m68knetbsd_vec)		tb="$tb m68knetbsd.lo aout32.lo" ;;
884
    m68knetbsd_vec)		tb="$tb m68knetbsd.lo aout32.lo" ;;
884
    m68ksysvcoff_vec)		tb="$tb coff-svm68k.lo cofflink.lo" ;;
885
    m68ksysvcoff_vec)		tb="$tb coff-svm68k.lo cofflink.lo" ;;
885
    m88kbcs_vec)		tb="$tb coff-m88k.lo" ;;
886
    m88kbcs_vec)		tb="$tb coff-m88k.lo" ;;
(-)binutils-2.21.51.0.7/bfd/libaout.h (+5 lines)
Lines 422-427 Link Here
422
     table, used when linking on SunOS.  This is indexed by the symbol
422
     table, used when linking on SunOS.  This is indexed by the symbol
423
     index.  */
423
     index.  */
424
  bfd_vma *local_got_offsets;
424
  bfd_vma *local_got_offsets;
425
426
  /* A pointer for data used by aout extensions.  (Currently only used
427
     by MiNT executables (see prg-mint.c).  */
428
  void *ext;
425
};
429
};
426
430
427
struct  aout_data_struct
431
struct  aout_data_struct
Lines 449-454 Link Here
449
#define obj_aout_string_window(bfd)        (adata (bfd).string_window)
453
#define obj_aout_string_window(bfd)        (adata (bfd).string_window)
450
#define obj_aout_sym_hashes(bfd)           (adata (bfd).sym_hashes)
454
#define obj_aout_sym_hashes(bfd)           (adata (bfd).sym_hashes)
451
#define obj_aout_dynamic_info(bfd)         (adata (bfd).dynamic_info)
455
#define obj_aout_dynamic_info(bfd)         (adata (bfd).dynamic_info)
456
#define obj_aout_ext(bfd)                  (adata (bfd).ext)
452
457
453
/* We take the address of the first element of an asymbol to ensure that the
458
/* We take the address of the first element of an asymbol to ensure that the
454
   macro is only ever applied to an asymbol.  */
459
   macro is only ever applied to an asymbol.  */
(-)binutils-2.21.51.0.7/bfd/prg-mint.c (+1732 lines)
Line 0 Link Here
1
/* BFD backend for traditional MiNT executables.
2
   Copyright 1998, 2007, 2008, 2009 Free Software Foundation, Inc.
3
   Originally written by Guido Flohr (guido@freemint.de).
4
   Modified by Vincent Riviere (vincent.riviere@freesbee.fr).
5
6
   This file is part of BFD, the Binary File Descriptor library.
7
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21
   MA 02110-1301, USA.  */
22
23
/* The format of executables on Atari is actually not a.out,  it is
24
   only chosen as an approach which comes close enough.  The layout of a
25
   program image on disk looked like this:
26
27
   +-----------------+
28
   | 28 Bytes Header |
29
   +-----------------+
30
   | Text segment    |
31
   +-----------------+
32
   | Data segment    |
33
   +-----------------+
34
   | BSS	     |
35
   +-----------------+
36
   | Symbol table    |
37
   +-----------------+
38
   | TPA relocation  |
39
   +-----------------+
40
41
   The 28 byte exec header used to look like this:
42
43
   struct old_exec_header
44
   {
45
     bfd_byte a_magic[2];
46
     bfd_byte a_text[4];
47
     bfd_byte a_data[4];
48
     bfd_byte a_bss[4];
49
     bfd_byte a_syms[4];
50
     bfd_byte a_resvd[4];
51
     bfd_byte a_abs[2];
52
   };
53
54
   The first two bytes (A_MAGIC) contained an assembler branch
55
   instruction to the beginning of the text segment.  Because the
56
   exec header had a fixed size and the text entry point was constant
57
   this assembler instruction also had a constant value (0x601a).
58
   In fact the operating system never really executed the branch
59
   instruction but used this value (0x601a) as a magic value.
60
61
   TEXT, DATA and BSS were as one would expect them.  The symbol
62
   table wasn't.  Several different formats were in use, none of them
63
   very efficient, none of them powerful enough to support source
64
   level debugging.  I've changed that and the GNU symbol table will
65
   now be used instead (unless the --traditional-format option was
66
   given to the linker).
67
68
   If the last member A_ABS of the exec header is zero the program
69
   image contains an additional table with relocation information
70
   at the end of the image.  The kernel can load program images at
71
   virtually any address in the address space.  In fact it will load
72
   it at the start of the biggest block of free memory.  This block
73
   is then called the Transient Program Area TPA and the image has
74
   to be relocated against the TPA at runtime.  The relocation info
75
   itself is in a simply way compressed:  It starts with a four-byte
76
   value, the first address within the image to be relocated.  Now
77
   following are one-byte offsets to the last address.  The special
78
   value of 1 (which is impossible as an offset) signifies that 254
79
   has to be added to the next offset.  The table is finished with
80
   a zero-byte.
81
82
   I now simply extended the header from its old 28 bytes to 256
83
   bytes.  The first 28 bytes give home to a standard Atari header,
84
   the rest is for extensions.  The extension header starts with
85
   a ``real'' assembler instruction, a far jump to the text entry
86
   point.  The extension header gives home to a standard a.out
87
   exec header (currently NMAGIC) plus some extra
88
   more or less useful fields plus space to future extensions.
89
   For the OS the extension header will already belong to the text
90
   segment, for BFD backends the text segment is 228 (or 0xe4)
91
   bytes smaller than for the OS.  This explains for example the
92
   funny TEXT_START_ADDR 0xe4.
93
94
   The TARGET_PAGE_SIZE is 2 which is only fake.  There is currently
95
   no such thing as memory paging on the Atari (and this is why
96
   ZMAGICs are disabled for now to allow for future enhancements).
97
98
   If you think that this whole file looks quite like a big hack
99
   you're probably right.  But the results (mainly the output of
100
   the linker) seem to work and they allow to use up-to-date
101
   binutils on the Atari until a better executable format (maybe
102
   ELF) has been established for this machine.  */
103
104
#include "sysdep.h"
105
#include "bfd.h"
106
107
#define N_HEADER_IN_TEXT(x) 0
108
#define BYTES_IN_WORD 4
109
#define ENTRY_CAN_BE_ZERO
110
#define N_SHARED_LIB(x) 0
111
#define TEXT_START_ADDR 0xe4
112
#define TARGET_PAGE_SIZE 2
113
#define TARGET_IS_BIG_ENDIAN_P
114
#define DEFAULT_ARCH bfd_arch_m68k
115
#define N_TXTADDR(x) TEXT_START_ADDR
116
117
/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
118
   remove whitespace added here, and thus will fail to concatenate
119
   the tokens.  */
120
#define MY(OP) CONCAT2 (m68kmint_prg_,OP)
121
#define TARGETNAME "a.out-mintprg"
122
#define NAME(x,y) CONCAT3 (mintprg,_32_,y)
123
124
/* We have to do quite a lot of magic to make the Atari format
125
   for GEMDOS executables fit into the standard a.out format.
126
   We start with the original header.  */
127
#define external_exec mint_external_exec
128
struct mint_external_exec
129
{
130
  bfd_byte g_branch[2]; 	     /* 0x601a.  */
131
  bfd_byte g_text[4];		     /* Length of text section.  */
132
  bfd_byte g_data[4];		     /* Length of data section.  */
133
  bfd_byte g_bss[4];		     /* Length of bss section.  */
134
  bfd_byte g_syms[4];		     /* Length of symbol table.  */
135
  bfd_byte g_extmagic[4];	     /* Always 0x4d694e54
136
					(in ASCII: ``MiNT'').  */
137
  bfd_byte g_flags[4];		     /* Atari special flags.  */
138
  bfd_byte g_abs[2];		     /* Non-zero if absolute (no relocation
139
					info.  */
140
141
  /* We extend this header now to provide the information that the
142
     binutils want to see.  Everything following will actually be part
143
     of the text segment (from MiNT's point of view).  As a
144
     consequence the text section has 228 bytes of redundancy.
145
146
     The following eight bytes should be treated as opaque.
147
     If the word ``opaque'' always attracts your curiosity in
148
     typedefs and structs, here's the explanation:  These eight bytes
149
     are really two assembler instructions.  The first one moves
150
     the contents of e_entry into register d0, the second one
151
     jumps (pc-relative) to the entry point.  See swap_exec_header_out
152
     for details.  */
153
  bfd_byte g_jump_entry[8];
154
155
  /* Now following a standard a.out header.  Note that the values
156
     may differ from the one given on top.  The traditional header
157
     contains the values that the OS wants to see, the values below
158
     are the values that make the binutils work.  */
159
  bfd_byte e_info[4];		     /* Magic number and stuff.  */
160
  bfd_byte e_text[4];		     /* Length of text section in bytes.  */
161
  bfd_byte e_data[4];		     /* Length of data section.  */
162
  bfd_byte e_bss[4];		     /* Length of standard symbol
163
					table.  */
164
  bfd_byte e_syms[4];		     /* Length of symbol table.  */
165
  bfd_byte e_entry[4];		     /* Start address.  */
166
  bfd_byte e_trsize[4]; 	     /* Length of text relocation
167
					info.  */
168
  bfd_byte e_drsize[4]; 	     /* Length of data relocation
169
					info.  */
170
171
  bfd_byte g_tparel_pos[4];	     /* File position of TPA relative
172
					relocation info.  */
173
  bfd_byte g_tparel_size[4];	     /* Length of TPA relative relocation
174
					info.  */
175
176
  /* This is for extensions.  */
177
  bfd_byte g_stkpos[4]; 	     /* If stacksize is hardcoded into
178
					the executable you will find it
179
					at file offset g_stkpos.  If
180
					not this is NULL.  */
181
182
  bfd_byte g_symbol_format[4];	     /* Format of the symbol table.  See
183
					definitions for _MINT_SYMBOL_FORMAT*
184
					above.  */
185
186
  /* Pad with zeros.  */
187
  bfd_byte g_pad0[172];
188
};
189
#define EXEC_BYTES_SIZE 256
190
#define GEMDOS_HEADER_SIZE 28
191
192
/* The following defines are required by aoutx.h.
193
   They are not automatically defined in aout/aout64.h
194
   if external_exec is defined.  */
195
196
#define OMAGIC 0407	/* Object file or impure executable.  */
197
#define NMAGIC 0410	/* Code indicating pure executable.  */
198
#define ZMAGIC 0413	/* Code indicating demand-paged executable.  */
199
#define BMAGIC 0415	/* Used by a b.out object.  */
200
#define QMAGIC 0314	/* Like ZMAGIC but with N_HEADER_IN_TEXT true.  */
201
202
/* Files using the following magic flags will not be loaded.  */
203
#define N_BADMAG(x)	(N_MAGIC(x) != NMAGIC)
204
205
/* For DRI symbol table format.  */
206
struct dri_symbol
207
{
208
  bfd_byte a_name[8];	  /* Symbol name */
209
  bfd_byte a_type[2];	  /* Type flag, i.e. A_TEXT etc; see below.  */
210
  bfd_byte a_value[4];	  /* value of this symbol (or sdb offset).  */
211
};
212
#define DRI_SYMBOL_SIZE 14
213
214
/* Simple values for a_type.  */
215
#define A_UNDF	0
216
#define A_BSS	0x0100
217
#define A_TEXT	0x0200
218
#define A_DATA	0x0400
219
#define A_EXT	0x0800	      /* External.  */
220
#define A_EQREG 0x1000	      /* Equated register.  */
221
#define A_GLOBL 0x2000	      /* Global.  */
222
#define A_EQU	0x4000	      /* Equated.  */
223
#define A_DEF	0x8000	      /* Defined.  */
224
#define A_LNAM	0x0048	      /* GST compatible long name.  */
225
			      /* File symbols ala aln.  */
226
#define A_TFILE 0x0280	      /* Text file corresponding to object module.  */
227
#define A_TFARC 0x02C0	      /* Text file archive.  Unfortunately this
228
				 conflicts with the bits in A_LNAM.  */
229
230
/* The following include contains the definitions for internal a.out structures
231
   as well as the prototypes for the NAME(...) functions defined in aoutx.h.  */
232
233
#include "libaout.h"
234
235
/* The following function is similar to _bfd_final_link_relocate, except it
236
   adds the reloc structure as an additional parameter.
237
   It will be used int aoutx.h.  */
238
239
static bfd_reloc_status_type
240
m68kmint_prg_final_link_relocate_rel (reloc_howto_type *howto,
241
				      bfd *input_bfd,
242
				      asection *input_section,
243
				      bfd_byte *contents,
244
				      bfd_vma address,
245
				      bfd_vma value,
246
				      bfd_vma addend,
247
				      struct reloc_std_external *rel);
248
249
#define MY_final_link_relocate_rel m68kmint_prg_final_link_relocate_rel
250
251
/* The following include contains the definitions for the NAME(...) functions.  */
252
253
#include "aoutx.h"
254
255
/* Data structure that holds some private information for us.  */
256
struct mint_internal_info
257
{
258
  struct bfd_link_info *linkinfo;    /* Remembered from final_link.  */
259
  bfd_boolean	traditional_format;  /* Saved from link info.  */
260
  int		symbol_format;	     /* Format of the symbol table.  */
261
  void		*tparel;	     /* Data for TPA relative relocation
262
					information.  */
263
  file_ptr	tparel_pos;	     /* File position of TPA relative
264
					relocation information.  */
265
  bfd_size_type tparel_size;	     /* Size of TPA relative relocation
266
					information.  */
267
  bfd_size_type dri_symtab_size;     /* Size of traditional symbol table.  */
268
269
#define MINT_RELOC_CHUNKSIZE 0x1000
270
  bfd_vma	*relocs;	     /* Array of address relocations.  */
271
  unsigned long relocs_used;	     /* Number of relocation entries
272
					already used up.  */
273
  unsigned long relocs_allocated;    /* Number of relocation entries
274
					allocated.  */
275
276
  bfd_vma	stkpos; 	     /* File offset to value of _stksize.  */
277
278
  flagword	prg_flags;	     /* Standard GEMDOS flags.  */
279
280
  bfd_boolean 	override_stack_size; /* TRUE if the executable stack size
281
					must be overriden with stack_size.  */
282
  bfd_signed_vma stack_size;
283
284
  bfd_boolean	reloc_error;	     /* TRUE if an unhandled error during
285
					relocation occured.  */
286
};
287
288
/* If --traditional-format was given to the linker an old-style DRI
289
   symbol table is written into the executable.  This is with respect
290
   to many old debugging tools or disassemblers which expect this format.
291
   Although created by the linker, these symbols will be ignored from
292
   input files.  */
293
#define _MINT_SYMBOL_FORMAT_GNU  0
294
#define _MINT_SYMBOL_FORMAT_DRI  1
295
296
/* Declarations for the variables and functions
297
   defined later in aout-target.h.  */
298
299
static const bfd_target *
300
m68kmint_prg_callback (bfd *abfd);
301
302
static void
303
MY_final_link_callback (bfd *abfd,
304
			file_ptr *ptreloff,
305
			file_ptr *pdreloff,
306
			file_ptr *psymoff);
307
308
extern const bfd_target m68kmint_prg_vec;
309
310
/* Initialize a new BFD using our file format.  */
311
312
#define MY_mkobject m68kmint_prg_mkobject
313
314
static bfd_boolean
315
m68kmint_prg_mkobject (bfd *abfd)
316
{
317
  struct mint_internal_info *myinfo;
318
319
  if (!NAME (aout, mkobject (abfd)))
320
    return FALSE;
321
322
  /* Allocate our private BFD data.  */
323
  myinfo = bfd_zalloc (abfd, sizeof (*myinfo));
324
  if (myinfo == NULL)
325
    return FALSE;
326
  obj_aout_ext (abfd) = myinfo;
327
328
  return TRUE;
329
}
330
331
/* Finish up the reading of an a.out file header.  */
332
333
#define MY_object_p m68kmint_prg_object_p
334
335
static const bfd_target *
336
m68kmint_prg_object_p (bfd *abfd)
337
{
338
  struct external_exec exec_bytes;	/* Raw exec header from file.  */
339
  struct internal_exec exec;		/* Cleaned-up exec header.  */
340
  const bfd_target *target;
341
  bfd_size_type amt = EXEC_BYTES_SIZE;
342
  struct mint_internal_info *myinfo;
343
344
  /* Read the exec bytesd from the file.  */
345
  if (bfd_bread (&exec_bytes, amt, abfd) != amt)
346
    {
347
      if (bfd_get_error () != bfd_error_system_call)
348
	bfd_set_error (bfd_error_wrong_format);
349
      return NULL;
350
    }
351
352
  /* Instead of byte-swapping we compare bytes.  */
353
  if (exec_bytes.g_branch[0] != 0x60
354
      || exec_bytes.g_branch[1] != 0x1a
355
      || exec_bytes.g_extmagic[0] != 'M'
356
      || exec_bytes.g_extmagic[1] != 'i'
357
      || exec_bytes.g_extmagic[2] != 'N'
358
      || exec_bytes.g_extmagic[3] != 'T')
359
    {
360
      bfd_set_error (bfd_error_wrong_format);
361
      return NULL;
362
    }
363
364
  /* Swap the standard a.out fields.  */
365
  NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec);
366
367
  /* Check a.out magic value.  */
368
  if (N_BADMAG (exec))
369
    {
370
      bfd_set_error (bfd_error_wrong_format);
371
      return NULL;
372
    }
373
374
  /* Initialize this BFD with the exec values.  */
375
  target = NAME (aout, some_aout_object_p) (abfd, &exec, m68kmint_prg_callback);
376
377
  /* Allocate our private BFD data.  */
378
  myinfo = bfd_zalloc (abfd, sizeof (*myinfo));
379
  if (myinfo == NULL)
380
    return NULL;
381
  obj_aout_ext (abfd) = myinfo;
382
383
  /* Now get the missing information.  */
384
  myinfo->prg_flags = bfd_h_get_32 (abfd, exec_bytes.g_flags);
385
  myinfo->stkpos = bfd_h_get_32 (abfd, exec_bytes.g_stkpos);
386
  myinfo->symbol_format = bfd_h_get_32 (abfd, exec_bytes.g_symbol_format);
387
388
  /* TPA relocation information.  */
389
  myinfo->tparel_pos = bfd_h_get_32 (abfd, exec_bytes.g_tparel_pos);
390
  myinfo->tparel_size = bfd_h_get_32 (abfd, exec_bytes.g_tparel_size);
391
392
  /* FIXME:  Currently we always read the TPA relative relocation
393
     information.  This is suboptimal because often times there
394
     is no need for it.  Read it only if need be!  Maybe this should
395
     also depend on abfd->cacheable?  */
396
  if (myinfo->tparel_size == 0)
397
    myinfo->tparel = bfd_zalloc (abfd, 4);
398
  else
399
    myinfo->tparel = bfd_alloc (abfd, myinfo->tparel_size);
400
401
  if (myinfo->tparel == NULL)
402
    return NULL;
403
404
  if (myinfo->tparel_size == 0)
405
    {
406
      myinfo->tparel_size = 4;
407
    }
408
  else
409
    {
410
      /* Read the information from the bfd.  */
411
      if (bfd_seek (abfd, myinfo->tparel_pos, SEEK_SET) != 0
412
	  || (bfd_bread (myinfo->tparel, myinfo->tparel_size, abfd)
413
	      != myinfo->tparel_size))
414
	return NULL;
415
    }
416
417
  return target;
418
}
419
420
/* Free all information we have cached for this BFD.  We can always
421
   read it again later if we need it.  */
422
423
#define MY_bfd_free_cached_info m68kmint_prg_bfd_free_cached_info
424
425
static bfd_boolean
426
m68kmint_prg_bfd_free_cached_info (bfd *abfd)
427
{
428
  struct mint_internal_info *myinfo = obj_aout_ext (abfd);
429
430
  if (myinfo != NULL && myinfo->relocs != NULL)
431
    {
432
      free (myinfo->relocs);
433
      myinfo->relocs = NULL;
434
    }
435
436
  /* myinfo itself has been allocated by bfd_zalloc()
437
     so will be automatically freed along with the BFD.
438
     Same for myinfo->tparel.  */
439
440
  return NAME (aout, bfd_free_cached_info) (abfd);
441
}
442
443
/* Write a DRI symbol with TYPE and VALUE.  If the NAME of the
444
   symbol exceeds 8 characters write a long symbol.  If it
445
   exceeds 22 characters truncate the name.  */
446
447
static int
448
write_dri_symbol (bfd *abfd, const char *name, int type, bfd_vma value)
449
{
450
  int written_bytes = 0;
451
  struct dri_symbol sym;
452
  int is_long_name = strlen (name) > sizeof (sym.a_name);
453
454
  if (is_long_name)
455
    type |= A_LNAM;
456
457
  strncpy ((char*)sym.a_name, name, sizeof (sym.a_name));
458
  bfd_put_16 (abfd, type, sym.a_type);
459
  bfd_put_32 (abfd, value, sym.a_value);
460
461
  if (bfd_bwrite (&sym, DRI_SYMBOL_SIZE, abfd) != DRI_SYMBOL_SIZE)
462
    return -1;
463
  written_bytes += DRI_SYMBOL_SIZE;
464
465
  if (is_long_name)
466
    {
467
      char more_name[DRI_SYMBOL_SIZE];
468
469
      strncpy (more_name, name + sizeof (sym.a_name), DRI_SYMBOL_SIZE);
470
471
      if (bfd_bwrite (more_name, DRI_SYMBOL_SIZE, abfd) != DRI_SYMBOL_SIZE)
472
	return -1;
473
      written_bytes += DRI_SYMBOL_SIZE;
474
    }
475
476
  return written_bytes;
477
}
478
479
/* Emit a traditional DRI symbol table while linking.
480
   Most of this code comes from aout_link_write_symbols() in aoutx.h.  */
481
482
static bfd_boolean
483
link_write_traditional_syms (bfd *abfd, struct bfd_link_info *info)
484
{
485
  bfd			     *input_bfd;
486
  enum bfd_link_strip	     strip = info->strip;
487
  enum bfd_link_discard      discard = info->discard;
488
  struct mint_internal_info  *myinfo = obj_aout_ext (abfd);
489
  bfd			     *last_archive = NULL;
490
491
  /* Position file pointer.  */
492
  if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
493
    return FALSE;
494
495
  myinfo->dri_symtab_size = 0;
496
497
  for (input_bfd = info->input_bfds; input_bfd != NULL; input_bfd = input_bfd->link_next)
498
    {
499
      bfd_size_type sym_count = obj_aout_external_sym_count (input_bfd);
500
      char *strings = obj_aout_external_strings (input_bfd);
501
      struct external_nlist *sym = obj_aout_external_syms (input_bfd);
502
      struct external_nlist *sym_end = sym + sym_count;
503
      struct aout_link_hash_entry **sym_hash = obj_aout_sym_hashes (input_bfd);
504
      bfd_boolean pass = FALSE;
505
      bfd_boolean skip = FALSE;
506
      bfd_boolean skip_next = FALSE;
507
      int written_bytes;
508
      int a_type;
509
      bfd_boolean write_archive_name = FALSE;
510
      bfd_vma val = 0;
511
512
      /* First write out a symbol for the archive if we do not
513
	 strip these symbols and if it differs from the last
514
	 one.  */
515
      if (input_bfd->my_archive != last_archive
516
	  && input_bfd->my_archive != NULL)
517
	{
518
	  write_archive_name = TRUE;
519
	  last_archive = input_bfd->my_archive;
520
	}
521
522
      if (write_archive_name
523
	  && strip != strip_all
524
	  && (strip != strip_some
525
	      || bfd_hash_lookup (info->keep_hash,
526
				  input_bfd->my_archive->filename,
527
				  FALSE, FALSE) != NULL)
528
	  && discard != discard_all)
529
	{
530
	  val = bfd_get_section_vma (abfd,
531
				     obj_textsec (input_bfd)->output_section)
532
	    + obj_textsec (input_bfd)->output_offset;
533
534
	  written_bytes = write_dri_symbol (abfd,
535
					    input_bfd->my_archive->filename,
536
					    A_TFILE, val);
537
538
	  if (written_bytes < 0)
539
	    return FALSE;
540
	  else
541
	    myinfo->dri_symtab_size += written_bytes;
542
	}
543
544
      /* Now write out a symbol for the object file if we do not
545
	 strip these symbols.  */
546
      if (strip != strip_all
547
	  && (strip != strip_some
548
	      || bfd_hash_lookup (info->keep_hash, input_bfd->filename,
549
				  FALSE, FALSE) != NULL)
550
	  && discard != discard_all)
551
	{
552
	  val = bfd_get_section_vma (abfd,
553
				     obj_textsec (input_bfd)->output_section)
554
	    + obj_textsec (input_bfd)->output_offset;
555
556
	  written_bytes = write_dri_symbol (abfd, input_bfd->filename,
557
					    A_TFILE, val);
558
	  if (written_bytes < 0)
559
	    return FALSE;
560
	  else
561
	    myinfo->dri_symtab_size += written_bytes;
562
	}
563
564
      /* Now we have a problem.  All symbols that we see have already
565
	 been marked written (because we write them a second time
566
	 here.  If we would do it the clean way we would have
567
	 to traverse the entire symbol map and reset the written
568
	 flag.  We hack here instead...  */
569
#define mark_written(h) (* (int *) &h->written = (int) TRUE + 1)
570
#define is_written(h) ((int) h->written == (int) TRUE + 1)
571
      for (; sym < sym_end; sym++, sym_hash++)
572
	{
573
	  const char *name;
574
	  int type;
575
	  struct aout_link_hash_entry *h;
576
	  asection *symsec;
577
	  val = 0;
578
579
	  type = H_GET_8 (input_bfd, sym->e_type);
580
	  name = strings + GET_WORD (input_bfd, sym->e_strx);
581
582
	  h = NULL;
583
584
	  if (pass)
585
	    {
586
	      /* Pass this symbol through.  It is the target of an
587
	      indirect or warning symbol.  */
588
	      val = GET_WORD (input_bfd, sym->e_value);
589
	      pass = FALSE;
590
	    }
591
	  else if (skip_next)
592
	    {
593
	      /* Skip this symbol, which is the target of an indirect
594
		 symbol that we have changed to no longer be an indirect
595
		 symbol.  */
596
	      skip_next = FALSE;
597
	      continue;
598
	    }
599
	  else
600
	    {
601
	      struct aout_link_hash_entry *hresolve = *sym_hash;
602
603
	      /* We have saved the hash table entry for this symbol, if
604
		 there is one.  Note that we could just look it up again
605
		 in the hash table, provided we first check that it is an
606
		 external symbol. */
607
	      h = *sym_hash;
608
609
	      /* Use the name from the hash table, in case the symbol was
610
		 wrapped.  */
611
	    if (h != NULL
612
		&& h->root.type != bfd_link_hash_warning)
613
		name = h->root.root.string;
614
615
	      /* If this is an indirect or warning symbol, then change
616
		 hresolve to the base symbol.  */
617
	      hresolve = h;
618
	      if (h != (struct aout_link_hash_entry *) NULL
619
		  && (h->root.type == bfd_link_hash_indirect
620
		      || h->root.type == bfd_link_hash_warning))
621
		{
622
		  hresolve = (struct aout_link_hash_entry*) h->root.u.i.link;
623
		  while (hresolve->root.type == bfd_link_hash_indirect
624
			 || hresolve->root.type == bfd_link_hash_warning)
625
		    hresolve = ((struct aout_link_hash_entry*)
626
				hresolve->root.u.i.link);
627
		}
628
629
	      /* If the symbol has already been written out skip it.  */
630
	      if (h != NULL
631
		  && is_written (h))
632
		{
633
		  if ((type & N_TYPE) == N_INDR
634
		      || type == N_WARNING)
635
		    skip_next = TRUE;
636
		  continue;
637
		}
638
639
	      /* See if we are stripping this symbol.  */
640
	      skip = FALSE;
641
642
	      /* Skip all debugger symbols.  No way to output them in
643
		 DRI format.  This will also reduce a lot of headaches.  */
644
	      if ((type & N_STAB) != 0)
645
		skip = TRUE;
646
647
	      switch (strip)
648
		{
649
		case strip_none:
650
		case strip_debugger:
651
		  break;
652
		case strip_some:
653
		  if (bfd_hash_lookup (info->keep_hash, name, FALSE, FALSE)
654
		      == NULL)
655
		    skip = TRUE;
656
		  break;
657
		case strip_all:
658
		  skip = TRUE;
659
		  break;
660
		}
661
662
	      if (skip)
663
		{
664
		  if (h != NULL)
665
		    mark_written (h);
666
		  continue;
667
		}
668
669
	      /* Get the value of the symbol.  */
670
	      if ((type & N_TYPE) == N_TEXT
671
		  || type == N_WEAKT)
672
		symsec = obj_textsec (input_bfd);
673
	      else if ((type & N_TYPE) == N_DATA
674
		       || type == N_WEAKD)
675
		symsec = obj_datasec (input_bfd);
676
	      else if ((type & N_TYPE) == N_BSS
677
		       || type == N_WEAKB)
678
		symsec = obj_bsssec (input_bfd);
679
	      else if ((type & N_TYPE) == N_ABS
680
		       || type == N_WEAKA)
681
		symsec = bfd_abs_section_ptr;
682
	      else if (((type & N_TYPE) == N_INDR
683
			&& (hresolve == NULL
684
			    || (hresolve->root.type != bfd_link_hash_defined
685
				&& hresolve->root.type != bfd_link_hash_defweak
686
				&& hresolve->root.type != bfd_link_hash_common)))
687
		       || type == N_WARNING)
688
		{
689
		  /* Pass the next symbol through unchanged.  The
690
		     condition above for indirect symbols is so that if
691
		     the indirect symbol was defined, we output it with
692
		     the correct definition so the debugger will
693
		     understand it.  */
694
		  pass = TRUE;
695
		  val = GET_WORD (input_bfd, sym->e_value);
696
		  symsec = NULL;
697
		}
698
	      else
699
		{
700
		  /* If we get here with an indirect symbol, it means that
701
		     we are outputting it with a real definition.  In such
702
		     a case we do not want to output the next symbol,
703
		     which is the target of the indirection.  */
704
		  if ((type & N_TYPE) == N_INDR)
705
		    skip_next = TRUE;
706
707
		  symsec = NULL;
708
709
		  /* We need to get the value from the hash table.  We use
710
		     hresolve so that if we have defined an indirect
711
		     symbol we output the final definition.  */
712
		  if (h == NULL)
713
		    {
714
		      switch (type & N_TYPE)
715
			{
716
			case N_SETT:
717
			  symsec = obj_textsec (input_bfd);
718
			  break;
719
			case N_SETD:
720
			  symsec = obj_datasec (input_bfd);
721
			  break;
722
			case N_SETB:
723
			  symsec = obj_bsssec (input_bfd);
724
			  break;
725
			case N_SETA:
726
			  symsec = bfd_abs_section_ptr;
727
			  break;
728
			default:
729
			  val = 0;
730
			  break;
731
			}
732
		    }
733
		  else if (hresolve->root.type == bfd_link_hash_defined
734
			   || hresolve->root.type == bfd_link_hash_defweak)
735
		    {
736
		      asection *input_section;
737
		      asection *output_section;
738
739
		      /* This case usually means a common symbol which was
740
			 turned into a defined symbol.  */
741
		      input_section = hresolve->root.u.def.section;
742
		      output_section = input_section->output_section;
743
		      BFD_ASSERT (bfd_is_abs_section (output_section)
744
				  || output_section->owner == abfd);
745
746
		      /* The following reference to the output section VMA
747
			 is commented out because DRI symbols are relative
748
			 to the beginning of the section.  */
749
		      val = (hresolve->root.u.def.value
750
			     /*+ bfd_get_section_vma (abfd, output_section)*/
751
			     + input_section->output_offset);
752
753
		      /* TEXT symbols values must be adjusted
754
			 by adding the size of the extended header.  */
755
		      if (output_section == obj_textsec (abfd))
756
			val += TEXT_START_ADDR;
757
758
		      /* Get the correct type based on the section.  If
759
			 this is a constructed set, force it to be
760
			 globally visible.  */
761
		      if (type == N_SETT
762
			  || type == N_SETD
763
			  || type == N_SETB
764
			  || type == N_SETA)
765
			type |= N_EXT;
766
767
		      type &=~ N_TYPE;
768
769
		      if (output_section == obj_textsec (abfd))
770
			type |= N_TEXT;
771
		      else if (output_section == obj_datasec (abfd))
772
			type |= N_DATA;
773
		      else if (output_section == obj_bsssec (abfd))
774
			type |= N_BSS;
775
		      else
776
			type |= N_ABS;
777
		    }
778
		  else if (hresolve->root.type == bfd_link_hash_common)
779
		    val = hresolve->root.u.c.size;
780
		  else if (hresolve->root.type == bfd_link_hash_undefweak)
781
		    {
782
		      val = 0;
783
		      type = N_UNDF;
784
		    }
785
		  else
786
		    val = 0;
787
		}
788
	      if (symsec != NULL)
789
		{
790
		  /* The following reference to the output section VMA
791
		     is commented out because DRI symbols are relative
792
		     to the beginning of the section.  */
793
		  val = (/*symsec->output_section->vma
794
			 +*/ symsec->output_offset
795
			 + (GET_WORD (input_bfd, sym->e_value)
796
			 - symsec->vma));
797
798
		  /* TEXT symbols values must be adjusted
799
		     by adding the size of the extended header.  */
800
		  if (symsec == obj_textsec (input_bfd))
801
		    val += TEXT_START_ADDR;
802
		}
803
804
	      /* If this is a global symbol set the written flag, and if
805
		 it is a local symbol see if we should discard it.  */
806
	      if (h != NULL)
807
		{
808
		  mark_written (h);
809
		}
810
	      else if ((type & N_TYPE) != N_SETT
811
		       && (type & N_TYPE) != N_SETD
812
		       && (type & N_TYPE) != N_SETB
813
		       && (type & N_TYPE) != N_SETA)
814
		{
815
		  switch (discard)
816
		    {
817
		    case discard_none:
818
		    case discard_sec_merge:
819
		      break;
820
		    case discard_l:
821
		      if (bfd_is_local_label_name (input_bfd, name))
822
			skip = TRUE;
823
		      break;
824
		    default:
825
		    case discard_all:
826
		      skip = TRUE;
827
		      break;
828
		    }
829
		  if (skip)
830
		    {
831
		      pass = FALSE;
832
		      continue;
833
		    }
834
		}
835
	    }
836
837
	  /* Now find the nearest type in DRI format.  */
838
	  switch (type)
839
	    {
840
	    case N_ABS:
841
	    case N_ABS | N_EXT:
842
	    case N_SETA:
843
	    case N_SETA | N_EXT:
844
	    case N_WEAKA:
845
	      a_type = A_EQU | A_DEF | A_GLOBL;
846
	      break;
847
	    case N_TEXT:
848
	    case N_TEXT | N_EXT:
849
	    case N_SETT:
850
	    case N_SETT | N_EXT:
851
	    case N_WEAKT:
852
	      a_type = A_TEXT | A_DEF | A_GLOBL;
853
	      break;
854
	    case N_DATA:
855
	    case N_DATA | N_EXT:
856
	    case N_SETD:
857
	    case N_SETD | N_EXT:
858
	    case N_WEAKD:
859
	      a_type = A_DATA | A_DEF | A_GLOBL;
860
	      break;
861
	    case N_BSS:
862
	    case N_BSS | N_EXT:
863
	    case N_SETB:
864
	    case N_SETB | N_EXT:
865
	    case N_WEAKB:
866
	      a_type = A_BSS | A_DEF | A_GLOBL;
867
	      break;
868
	    default:
869
	      continue;
870
	    }
871
872
	  written_bytes = write_dri_symbol (abfd, name, a_type, val);
873
	  if (written_bytes < 0)
874
	    return FALSE;
875
876
	  myinfo->dri_symtab_size += written_bytes;
877
	}
878
    }
879
880
  obj_aout_external_string_size (abfd) = 0;
881
  return TRUE;
882
}
883
884
/* This is used for qsort() to sort addresses
885
   for the TPA relocation table.  */
886
887
static int
888
vma_cmp (const void *v1, const void *v2)
889
{
890
  return (int) ((*((bfd_vma *) v1)) - (*((bfd_vma *) v2)));
891
}
892
893
/* Alloc and fill the TPA relocation table.  */
894
895
static bfd_boolean
896
fill_tparel (bfd *abfd)
897
{
898
  struct mint_internal_info *myinfo = obj_aout_ext (abfd);
899
  unsigned long i;
900
  bfd_size_type bytes;
901
  unsigned char *ptr;
902
903
  /* Sort the relocation info.  */
904
  if (myinfo->relocs != NULL)
905
    qsort (myinfo->relocs, myinfo->relocs_used, sizeof (bfd_vma),
906
	   vma_cmp);
907
908
  /* Now calculate the number of bytes we need.  The relocation info
909
     is encoded as follows:  The first entry is a 32-bit value
910
     denoting the first offset to relocate.  All following entries
911
     are relative to the preceding one.  For relative offsets of
912
     more than 254 bytes a value of 1 is used.  The OS will then
913
     add 254 bytes to the current offset.  The list is then terminated
914
     with the byte 0.  */
915
  bytes = 4; /* First entry is a long.  */
916
  for (i = 1; i < myinfo->relocs_used; i++)
917
    {
918
      unsigned long diff = myinfo->relocs[i] - myinfo->relocs[i - 1];
919
      BFD_ASSERT(diff > 0);
920
      bytes += (diff + 253) / 254;
921
    }
922
  /* Last entry is (bfd_byte) 0 if there are some relocations.  */
923
  if (myinfo->relocs_used > 0)
924
    bytes++;
925
926
  myinfo->tparel_size = bytes;
927
  myinfo->tparel = bfd_alloc (abfd, bytes);
928
  if (myinfo->tparel == NULL)
929
    return FALSE;
930
931
  /* Now fill the array.  */
932
  ptr = (bfd_byte*) myinfo->tparel;
933
  if (myinfo->relocs != NULL)
934
    bfd_put_32 (abfd, myinfo->relocs[0], ptr);
935
  else
936
    bfd_put_32 (abfd, 0, ptr);
937
  ptr += 4;
938
939
  for (i = 1; i < myinfo->relocs_used; i++)
940
    {
941
      unsigned long diff = myinfo->relocs[i] - myinfo->relocs[i - 1];
942
      while (diff > 254)
943
	{
944
	  *ptr++ = 1;
945
	  diff -= 254;
946
	}
947
      *ptr++ = (bfd_byte) diff;
948
    }
949
950
  if (myinfo->relocs_used > 0)
951
    *ptr = 0;
952
953
  return TRUE;
954
}
955
956
/* Final link routine.  We need to use a call back to get the correct
957
   offsets in the output file.  And we need to malloc some internal
958
   buffers.  */
959
960
#define MY_bfd_final_link m68kmint_prg_bfd_final_link
961
962
static bfd_boolean
963
m68kmint_prg_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
964
{
965
  struct mint_internal_info *myinfo = obj_aout_ext (abfd);
966
  struct bfd_link_hash_table *hash = info->hash;
967
  enum bfd_link_strip original_strip = info->strip;
968
969
  if (info->relocatable)
970
    {
971
      _bfd_error_handler ("%B: relocatable output is not supported by format %s",
972
	abfd, bfd_get_target (abfd));
973
      bfd_set_error (bfd_error_invalid_operation);
974
      return FALSE;
975
    }
976
977
  myinfo->linkinfo = info;
978
979
  /* Make sure that for now we never write zmagics.  */
980
  abfd->flags &= ~D_PAGED;
981
982
  /* Find the __stksize symbol.  This symbol is used for a MiNT
983
     special kludge.  The libc defines this symbol in an object file
984
     initialized to a default value to make sure it is defined in
985
     every output file.  The start-up code in crtinit() then simply
986
     sets the stacksize accordingly.  In your programs (if they need
987
     an unusual stacksize) you can then simply code:
988
989
	   long _stksize = 0x2000;
990
991
     This will create a program stack of 2k.  Since MiNT cannot detect
992
     a stack overflow this is the only way to prevent program crashes
993
     caused by a stack that is too small.
994
995
     The ancient linker ignored this feature, the ancient strip
996
     program paid heed to it.  By default, strip never stripped this
997
     special symbol from the binary.
998
999
     Another program called ``printstk'' and its colleague ``fixstk''
1000
     could be used to either print the current value of the stacksize
1001
     or to modify it without recompiling and rebuilding.  These
1002
     programs traversed the symbol table and then took the appropriate
1003
     measures if the symbol was found.
1004
1005
     Here we do a different approach.  Since we already expanded the
1006
     standard executable header we now hardcode the address (as a file
1007
     offset) that the __stksize symbol points to into the header.  We
1008
     can now let strip safely remove the entry from the symbol table
1009
     and we're not dependent on a special format of the symbol table.
1010
     Because the address is kept in the header we will always be able
1011
     to manipulate the stacksize value later.  */
1012
  if (hash != NULL)
1013
    {
1014
      struct aout_link_hash_entry *h =
1015
	aout_link_hash_lookup (aout_hash_table (info), "__stksize",
1016
			       FALSE, FALSE, FALSE);
1017
      asection *sec;
1018
1019
      if (h != NULL)
1020
	{
1021
	  switch (h->root.type)
1022
	    {
1023
	    case bfd_link_hash_defined:
1024
	    case bfd_link_hash_defweak:
1025
	      sec = h->root.u.def.section->output_section;
1026
	      BFD_ASSERT (sec->owner == abfd);
1027
1028
	      myinfo->stkpos = (h->root.u.def.value + sec->vma
1029
				+ h->root.u.def.section->output_offset
1030
				+ GEMDOS_HEADER_SIZE);
1031
	      break;
1032
	    default:  /* Ignore other types.  */
1033
	      break;
1034
	    }
1035
	}
1036
    }
1037
1038
  if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
1039
    {
1040
      myinfo->traditional_format = TRUE;
1041
      myinfo->symbol_format = _MINT_SYMBOL_FORMAT_DRI;
1042
    }
1043
1044
  /* Unconditionally unset the traditional flag.  The only effect in
1045
     the a.out code is to disable string hashing (with respect to
1046
     SunOS gdx).  This is not necessary for us.  */
1047
1048
  abfd->flags &= ~BFD_TRADITIONAL_FORMAT;
1049
1050
  /* Do not write GNU symbols in traditional format.  */
1051
  if (myinfo->traditional_format)
1052
    info->strip = strip_all;
1053
1054
  if (NAME(aout,final_link) (abfd, info, MY_final_link_callback)
1055
      != TRUE)
1056
    return FALSE;
1057
1058
  if (myinfo->reloc_error)
1059
    return FALSE;
1060
1061
  /* Restore the strip status for the traditional symbols.  */
1062
  info->strip = original_strip;
1063
1064
  if (myinfo->traditional_format
1065
      && link_write_traditional_syms (abfd, info) != TRUE)
1066
    return FALSE;
1067
1068
  if (fill_tparel (abfd) != TRUE)
1069
    return FALSE;
1070
1071
  return TRUE;
1072
}
1073
1074
/* Copy private BFD header information from the input BFD.  */
1075
1076
#define MY_bfd_copy_private_header_data m68kmint_prg_bfd_copy_private_header_data
1077
1078
static bfd_boolean
1079
m68kmint_prg_bfd_copy_private_header_data (bfd *ibfd, bfd *obfd)
1080
{
1081
  (void)obfd; /* Unused.  */
1082
1083
  /* We can only copy BFD files using our own file format.  */
1084
  if (ibfd->xvec != &m68kmint_prg_vec)
1085
    {
1086
      _bfd_error_handler ("%B: cannot convert from format %s to format %s",
1087
	ibfd, bfd_get_target (ibfd), bfd_get_target (obfd));
1088
      bfd_set_error (bfd_error_invalid_operation);
1089
      return FALSE;
1090
    }
1091
1092
  return TRUE;
1093
}
1094
1095
/* Copy backend specific data from one object module to another.
1096
   This function is used by objcopy and strip.  */
1097
1098
#define MY_bfd_copy_private_bfd_data m68kmint_prg_bfd_copy_private_bfd_data
1099
1100
static bfd_boolean
1101
m68kmint_prg_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
1102
{
1103
  struct mint_internal_info *myinfo_in;
1104
  struct mint_internal_info *myinfo_out;
1105
1106
  /* obfd uses our file format, ibfd may be foreign.  */
1107
  if (ibfd->xvec != &m68kmint_prg_vec)
1108
    return TRUE;
1109
1110
  myinfo_in = obj_aout_ext (ibfd);
1111
  BFD_ASSERT (myinfo_in != NULL);
1112
1113
  myinfo_out = obj_aout_ext (obfd);
1114
  BFD_ASSERT (myinfo_out != NULL);
1115
1116
  /* Copy myinfo.  */
1117
  memcpy (myinfo_out, myinfo_in, sizeof (*myinfo_out));
1118
1119
  /* Copy tparel.  */
1120
  myinfo_out->tparel = bfd_alloc (obfd, myinfo_out->tparel_size);
1121
  if (myinfo_out->tparel == NULL)
1122
    return FALSE;
1123
  memcpy (myinfo_out->tparel, myinfo_in->tparel, myinfo_out->tparel_size);
1124
1125
  /* Normalize the type of empty symbols.  */
1126
  if (bfd_get_symcount (obfd) == 0)
1127
    myinfo_out->symbol_format = _MINT_SYMBOL_FORMAT_GNU;
1128
1129
  return TRUE; /* _bfd_generic_bfd_copy_private_bfd_data (ibfd, obfd); */
1130
}
1131
1132
/* Merge private BFD information from an input BFD to the output BFD when linking.  */
1133
1134
#define MY_bfd_merge_private_bfd_data m68kmint_prg_merge_private_bfd_data
1135
1136
static bfd_boolean
1137
m68kmint_prg_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
1138
{
1139
  (void)obfd; /* Unused.  */
1140
1141
  /* Our file format cannot be used as linker input.  */
1142
  if (ibfd->xvec == &m68kmint_prg_vec)
1143
    {
1144
      _bfd_error_handler ("%B: file format %s cannot be used as linker input",
1145
	ibfd, bfd_get_target (ibfd));
1146
      bfd_set_error (bfd_error_invalid_operation);
1147
      return FALSE;
1148
    }
1149
1150
  return TRUE; /* _bfd_generic_bfd_merge_private_bfd_data (ibfd, obfd); */
1151
}
1152
1153
/* Find out the symbol name.  */
1154
1155
static const char *
1156
find_symbol_name (reloc_howto_type *howto, bfd *input_bfd,
1157
		  bfd_byte *location, struct reloc_std_external *rel)
1158
{
1159
  struct external_nlist *syms = obj_aout_external_syms (input_bfd);
1160
  char *strings = obj_aout_external_strings (input_bfd);
1161
  struct aout_link_hash_entry **sym_hashes
1162
    = obj_aout_sym_hashes (input_bfd);
1163
  struct aout_link_hash_entry *h = NULL;
1164
  const char *name;
1165
  bfd_size_type r_index;
1166
  int r_extern;
1167
1168
  if (bfd_get_reloc_size (howto) != 4)
1169
    return "(not a symbol)";
1170
1171
  /* The input bfd is always big-endian.  There is no need to
1172
     call bfd_header_big_endian (input_bfd).  */
1173
  r_index  = ((rel->r_index[0] << 16)
1174
	      | (rel->r_index[1] << 8)
1175
	      | (rel->r_index[2]));
1176
  r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
1177
1178
  if (sym_hashes != NULL)
1179
    h = sym_hashes[r_index];
1180
1181
  if (!r_extern)
1182
    {
1183
      bfd_size_type i;
1184
      bfd_vma wanted_value = bfd_get_32 (input_bfd, location);
1185
1186
      name = NULL;
1187
      for (i = 0; i < obj_aout_external_sym_count (input_bfd); i++)
1188
	{
1189
	  bfd_vma this_value = bfd_get_32 (input_bfd, syms[i].e_value);
1190
1191
	  if (this_value == wanted_value)
1192
	    {
1193
	      bfd_byte symtype = bfd_get_8 (input_bfd, syms[i].e_type);
1194
1195
	      /* Skip debug symbols and the like.  */
1196
	      if ((symtype & N_STAB) != 0)
1197
		continue;
1198
1199
	      /* This is dirty but preferable to a plethoria of
1200
		 single comparisons.  */
1201
	      if (symtype <= (N_BSS | N_EXT)
1202
		  || (symtype >= N_WEAKU && symtype <= N_COMM))
1203
		{
1204
		  name = strings + GET_WORD (input_bfd, syms[i].e_strx);
1205
		  break;
1206
		}
1207
	    }
1208
	}
1209
1210
      /* FIXME:  If the relocation is against a section there is
1211
	 probably a symbol for that section floating around somewhere
1212
	 in the bfd jungle.  */
1213
      if (name == NULL)
1214
	{
1215
	  switch ((r_index & N_TYPE) & ~N_EXT)
1216
	    {
1217
	    case N_TEXT:
1218
	      name = "text section";
1219
	      break;
1220
	    case N_DATA:
1221
	      name = "data section";
1222
	      break;
1223
	    case N_BSS:
1224
	      name = "bss section";
1225
	      break;
1226
	    case N_ABS:
1227
	      name = "absolute section";
1228
	      break;
1229
	    default:
1230
	      name = "unknown section";
1231
	      break;
1232
	    }
1233
	}
1234
    }
1235
  else if (h != NULL)
1236
    name = h->root.root.string;
1237
  else if (r_index >= obj_aout_external_sym_count (input_bfd))
1238
    name = "(unknown symbol)";	/* Shouldn't happen.  */
1239
  else
1240
    name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
1241
1242
  return name;
1243
}
1244
1245
/* This relocation routine is used by some of the backend linkers.
1246
   They do not construct asymbol or arelent structures, so there is no
1247
   reason for them to use bfd_perform_relocation.  Also,
1248
   bfd_perform_relocation is so hacked up it is easier to write a new
1249
   function than to try to deal with it.
1250
1251
   This routine does a final relocation.  Whether it is useful for a
1252
   relocatable link depends upon how the object format defines
1253
   relocations.
1254
1255
   FIXME: This routine ignores any special_function in the HOWTO,
1256
   since the existing special_function values have been written for
1257
   bfd_perform_relocation.
1258
1259
   HOWTO is the reloc howto information.
1260
   INPUT_BFD is the BFD which the reloc applies to.
1261
   INPUT_SECTION is the section which the reloc applies to.
1262
   CONTENTS is the contents of the section.
1263
   ADDRESS is the address of the reloc within INPUT_SECTION.
1264
   VALUE is the value of the symbol the reloc refers to.
1265
   ADDEND is the addend of the reloc.  */
1266
1267
/* The additional parameter REL is specific to this backend.
1268
   This function is derived from _bfd_final_link_relocate()
1269
   found in reloc.c. It adds additional checking for dangerous
1270
   relocations in MiNT sharable text sections, then it records
1271
   the relocated offset in myinfo->relocs[] for further processing.  */
1272
1273
static bfd_reloc_status_type
1274
m68kmint_prg_final_link_relocate_rel (reloc_howto_type *howto,
1275
				      bfd *input_bfd,
1276
				      asection *input_section,
1277
				      bfd_byte *contents,
1278
				      bfd_vma address,
1279
				      bfd_vma value,
1280
				      bfd_vma addend,
1281
				      struct reloc_std_external *rel)
1282
{
1283
  bfd_vma relocation;
1284
  bfd *output_bfd = input_section->output_section->owner;
1285
  struct mint_internal_info *myinfo = obj_aout_ext (output_bfd);
1286
  bfd_reloc_status_type retval;
1287
  int r_index;
1288
  int r_extern;
1289
  bfd_boolean need_tpa_relocation;
1290
1291
  /* The input bfd is always big-endian.  There is no need to
1292
     call bfd_header_big_endian (input_bfd).  */
1293
  r_index  = ((rel->r_index[0] << 16)
1294
	      | (rel->r_index[1] << 8)
1295
	      | (rel->r_index[2]));
1296
  r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
1297
1298
#define _MINT_F_SHTEXT 0x800
1299
1300
  /* Sanity check the address.  */
1301
  if (address > bfd_get_section_limit (input_bfd, input_section))
1302
    return bfd_reloc_outofrange;
1303
1304
  /* This function assumes that we are dealing with a basic relocation
1305
     against a symbol.  We want to compute the value of the symbol to
1306
     relocate to.  This is just VALUE, the value of the symbol, plus
1307
     ADDEND, any addend associated with the reloc.  */
1308
  relocation = value + addend;
1309
1310
  /* Check for dangerous relocations in images with a sharable
1311
     text section.  */
1312
  if ((myinfo->prg_flags & _MINT_F_SHTEXT) != 0
1313
      && bfd_get_reloc_size (howto) == 4)
1314
    {
1315
      bfd_boolean error_found = FALSE;
1316
      const char *name = NULL;
1317
1318
      if (input_section == obj_textsec (input_bfd))
1319
	{
1320
	  if (!r_extern)
1321
	    {
1322
	      /* This is a relocation against another section.  Only
1323
		 relocations against the text section are allowed.  */
1324
	      if (r_index != N_TEXT && r_index != (N_TEXT | N_EXT))
1325
		error_found = TRUE;
1326
	    }
1327
	  else if (relocation > (input_section->output_section->vma
1328
			    + input_section->output_section->size))
1329
	    {
1330
	      error_found = TRUE;
1331
	    }
1332
	  else if (relocation == (input_section->output_section->vma
1333
				  + input_section->output_section->size))
1334
	    {
1335
	      name = find_symbol_name (howto, input_bfd,
1336
						    contents + address,
1337
						    rel);
1338
	      if (strcmp (name, "_etext") == 0)
1339
		error_found = FALSE;
1340
	    }
1341
	}
1342
1343
      if (error_found)
1344
	{
1345
	  const struct bfd_link_callbacks *callbacks
1346
	    = myinfo->linkinfo->callbacks;
1347
1348
	  myinfo->reloc_error = TRUE;
1349
1350
	  if (callbacks->reloc_dangerous != NULL)
1351
	    {
1352
	      if (name == NULL)
1353
		name = find_symbol_name (howto, input_bfd,
1354
						      contents + address,
1355
						      rel);
1356
1357
	      callbacks->reloc_dangerous (myinfo->linkinfo, name,
1358
					  input_bfd,
1359
					  input_section, address);
1360
	    }
1361
	}
1362
    }
1363
1364
  /* If the relocation is PC relative, we want to set RELOCATION to
1365
     the distance between the symbol (currently in RELOCATION) and the
1366
     location we are relocating.  Some targets (e.g., i386-aout)
1367
     arrange for the contents of the section to be the negative of the
1368
     offset of the location within the section; for such targets
1369
     pcrel_offset is FALSE.  Other targets (e.g., m88kbcs or ELF)
1370
     simply leave the contents of the section as zero; for such
1371
     targets pcrel_offset is TRUE.  If pcrel_offset is FALSE we do not
1372
     need to subtract out the offset of the location within the
1373
     section (which is just ADDRESS).  */
1374
  if (howto->pc_relative)
1375
    {
1376
      relocation -= (input_section->output_section->vma
1377
		     + input_section->output_offset);
1378
      if (howto->pcrel_offset)
1379
	relocation -= address;
1380
    }
1381
1382
  retval = _bfd_relocate_contents (howto, input_bfd, relocation,
1383
				   contents + address);
1384
1385
  /* The symbol has to be relocated again iff the length of the relocation
1386
     is 2 words and it is not pc relative.  */
1387
  need_tpa_relocation = FALSE;
1388
  if (!howto->pc_relative && bfd_get_reloc_size (howto) == 4)
1389
    {
1390
      if (r_extern)
1391
	{
1392
	  struct aout_link_hash_entry **sym_hashes = obj_aout_sym_hashes (input_bfd);
1393
	  struct aout_link_hash_entry *h = sym_hashes[r_index];
1394
	  asection *output_section = h->root.u.def.section->output_section;
1395
1396
	  /* Do not relocate absolute symbols.  */
1397
	  if (output_section == obj_textsec (output_bfd)
1398
	      || output_section == obj_datasec (output_bfd)
1399
	      || output_section == obj_bsssec (output_bfd))
1400
	    {
1401
	      need_tpa_relocation = TRUE;
1402
	    }
1403
	}
1404
      else
1405
	{
1406
	  need_tpa_relocation = TRUE;
1407
	}
1408
    }
1409
1410
  /* Here we add the TPA relocation entries for the address references
1411
     located inside the input sections. Note that if some references
1412
     to addresses are generated using data statements in the linker
1413
     script, they will not be relocated here because they do not
1414
     belong to any input section.  */
1415
  if (need_tpa_relocation)
1416
    {
1417
      bfd_vma tpa_address = input_section->output_section->vma
1418
	+ input_section->output_offset + address;
1419
1420
      if (!bfd_m68kmint_add_tpa_relocation_entry(output_bfd, tpa_address))
1421
	return bfd_reloc_other;
1422
    }
1423
1424
  return retval;
1425
}
1426
1427
/* Write out the TPA relocation table.  */
1428
1429
static bfd_boolean
1430
write_tparel (bfd *abfd, struct internal_exec *execp)
1431
{
1432
  struct mint_internal_info* myinfo = obj_aout_ext (abfd);
1433
1434
  if (myinfo->dri_symtab_size == 0)
1435
    myinfo->tparel_pos = N_STROFF (*execp)
1436
      + obj_aout_external_string_size (abfd);
1437
  else
1438
    myinfo->tparel_pos = N_SYMOFF (*execp)
1439
      + myinfo->dri_symtab_size;
1440
1441
  if (bfd_seek (abfd, myinfo->tparel_pos, SEEK_SET) != 0)
1442
    return FALSE;
1443
1444
  if (bfd_bwrite (myinfo->tparel, myinfo->tparel_size, abfd)
1445
      != myinfo->tparel_size)
1446
    return FALSE;
1447
1448
  return TRUE;
1449
}
1450
1451
/* Write the full exec header.
1452
   This function must be called last to ensure that we have all the
1453
   information needed to fill the MiNT-specific header fields.  */
1454
1455
static bfd_boolean
1456
write_exec_header (bfd *abfd, struct internal_exec *execp, struct external_exec *exec_bytes)
1457
{
1458
  struct mint_internal_info *myinfo = obj_aout_ext (abfd);
1459
  bfd_size_type symtab_size;
1460
1461
  bfd_h_put_16 (abfd, 0x601a, exec_bytes->g_branch);
1462
1463
  /* The OS will load our extension header fields into the text segment.  */
1464
  bfd_h_put_32 (abfd, execp->a_text + (EXEC_BYTES_SIZE - GEMDOS_HEADER_SIZE),
1465
		exec_bytes->g_text);
1466
  bfd_h_put_32 (abfd, execp->a_data, exec_bytes->g_data);
1467
  bfd_h_put_32 (abfd, execp->a_bss, exec_bytes->g_bss);
1468
1469
  /* The OS' notion of the size of the symbol table is another than
1470
     the bfd library's.  We have to fill in the size of the table
1471
     itself plus the size of the string table but only if we have not written
1472
     a traditional symbol table.  If we have written a traditional symbol
1473
     table we know the size.  */
1474
  if (myinfo->dri_symtab_size != 0)
1475
    symtab_size = myinfo->dri_symtab_size;
1476
  else
1477
    symtab_size = myinfo->tparel_pos - N_SYMOFF (*execp);
1478
1479
  bfd_h_put_32 (abfd, symtab_size, exec_bytes->g_syms);
1480
1481
  bfd_h_put_32 (abfd, 0x4d694e54, exec_bytes->g_extmagic);
1482
  bfd_h_put_32 (abfd, myinfo->prg_flags, exec_bytes->g_flags);
1483
  bfd_h_put_16 (abfd, 0, exec_bytes->g_abs);
1484
1485
  /* Generate the jump instruction to the entry point.  In m68k
1486
     assembler mnemnonics it looks more or less like this:
1487
1488
       move.l  exec_bytes->e_entry(pc),d0
1489
       jmp     -6(pc,d0.l)
1490
1491
     Sorry for the wrong syntax.  As a real assembler addict I
1492
     never actually use an assembler.  I edit my binaries manually
1493
     with a hex editor, looks much cooler and it strengthens your
1494
     abstraction abilities.  */
1495
1496
  exec_bytes->g_jump_entry[0] = 0x20;
1497
  exec_bytes->g_jump_entry[1] = 0x3a;
1498
  exec_bytes->g_jump_entry[2] = 0x00;
1499
  exec_bytes->g_jump_entry[3] = 0x1a;
1500
  exec_bytes->g_jump_entry[4] = 0x4e;
1501
  exec_bytes->g_jump_entry[5] = 0xfb;
1502
  exec_bytes->g_jump_entry[6] = 0x08;
1503
  exec_bytes->g_jump_entry[7] = 0xfa;
1504
1505
  bfd_h_put_32 (abfd, myinfo->tparel_pos, exec_bytes->g_tparel_pos);
1506
  bfd_h_put_32 (abfd, myinfo->tparel_size, exec_bytes->g_tparel_size);
1507
  bfd_h_put_32 (abfd, myinfo->stkpos, exec_bytes->g_stkpos);
1508
1509
  /* If there are no symbols, pretend they are in GNU format.  */
1510
  if (symtab_size == 0)
1511
    myinfo->symbol_format = _MINT_SYMBOL_FORMAT_GNU;
1512
1513
  bfd_h_put_32 (abfd, myinfo->symbol_format, exec_bytes->g_symbol_format);
1514
1515
  memset (&exec_bytes->g_pad0, 0, sizeof (exec_bytes->g_pad0));
1516
1517
  /* The standard stuff.  */
1518
  NAME(aout, swap_exec_header_out) (abfd, execp, exec_bytes);
1519
  if (myinfo->symbol_format != _MINT_SYMBOL_FORMAT_GNU)
1520
    PUT_WORD (abfd, 0, exec_bytes->e_syms);
1521
1522
  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1523
    return FALSE;
1524
1525
  if (bfd_bwrite (exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
1526
      != EXEC_BYTES_SIZE)
1527
    return FALSE;
1528
1529
  /* Override the stack size.  */
1530
  if (myinfo->override_stack_size && myinfo->stkpos)
1531
  {
1532
    bfd_byte big_endian_stack_size[4];
1533
1534
    bfd_put_32 (abfd, myinfo->stack_size, &big_endian_stack_size);
1535
1536
    if (bfd_seek (abfd, (file_ptr) myinfo->stkpos, SEEK_SET) != 0)
1537
      return FALSE;
1538
1539
    if (bfd_bwrite (big_endian_stack_size, 4, abfd) != 4)
1540
      return FALSE;
1541
  }
1542
1543
  return TRUE;
1544
}
1545
1546
/* Write an object file.
1547
   Section contents have already been written.  We write the
1548
   file header, symbols, and relocation.  */
1549
1550
#define MY_write_object_contents m68kmint_prg_write_object_contents
1551
1552
static bfd_boolean
1553
m68kmint_prg_write_object_contents (bfd *abfd)
1554
{
1555
  struct external_exec exec_bytes;
1556
  struct internal_exec *execp = exec_hdr (abfd);
1557
  bfd_size_type text_size;
1558
  file_ptr text_end;
1559
1560
  BFD_ASSERT (obj_aout_ext (abfd) != NULL);
1561
1562
  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
1563
1564
  /* Most of the following code come from the WRITE_HEADERS macro
1565
     found in libaout.h.  */
1566
1567
  if (adata(abfd).magic == undecided_magic)
1568
    NAME (aout, adjust_sizes_and_vmas) (abfd, & text_size, & text_end);
1569
1570
  execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;
1571
  execp->a_entry = bfd_get_start_address (abfd);
1572
1573
  execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
1574
		     obj_reloc_entry_size (abfd));
1575
  execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
1576
		     obj_reloc_entry_size (abfd));
1577
1578
  /* Now write out reloc info, followed by syms and strings.  */
1579
1580
  if (bfd_get_outsymbols (abfd) != NULL
1581
      && bfd_get_symcount (abfd) != 0)
1582
    {
1583
      if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)
1584
	return FALSE;
1585
1586
      if (! NAME (aout, write_syms) (abfd))
1587
	return FALSE;
1588
    }
1589
1590
  if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)
1591
    return FALSE;
1592
  if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
1593
    return FALSE;
1594
1595
  if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)
1596
    return FALSE;
1597
  if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
1598
    return FALSE;
1599
1600
  if (write_tparel (abfd, execp) != TRUE)
1601
    return FALSE;
1602
1603
  if (write_exec_header (abfd, execp, &exec_bytes) != TRUE)
1604
    return FALSE;
1605
1606
  return TRUE;
1607
}
1608
1609
/* Print private BFD data. Used by objdump -p.  */
1610
1611
#define MY_bfd_print_private_bfd_data m68kmint_prg_print_private_bfd_data
1612
1613
static bfd_boolean
1614
m68kmint_prg_print_private_bfd_data (bfd *abfd, void *ptr)
1615
{
1616
  FILE *file = (FILE *) ptr;
1617
  struct mint_internal_info *myinfo = obj_aout_ext (abfd);
1618
  const char* symbol_format;
1619
  long stksize = 0;
1620
1621
  fprintf (file, "\n");
1622
1623
  fprintf (file, " GEMDOS flags: 0x%08lx\n", (unsigned long) myinfo->prg_flags);
1624
  fprintf (file, "Start address: 0x%08lx\n", bfd_get_start_address (abfd));
1625
1626
  /* Stack size.  */
1627
  if (myinfo->stkpos != 0)
1628
    {
1629
      if (bfd_seek (abfd, myinfo->stkpos, SEEK_SET) != 0
1630
	  || (bfd_bread (&stksize, sizeof(long), abfd) != sizeof(long)))
1631
	return FALSE;
1632
1633
      stksize = bfd_get_signed_32 (abfd, &stksize);
1634
    }
1635
  fprintf (file, "   Stack size: %ld\n", stksize);
1636
1637
  /* Symbol format.  */
1638
  switch (myinfo->symbol_format)
1639
    {
1640
      case _MINT_SYMBOL_FORMAT_GNU: symbol_format = "stabs"; break;
1641
      case _MINT_SYMBOL_FORMAT_DRI: symbol_format = "DRI";   break;
1642
      default:			    symbol_format = "?";     break;
1643
    }
1644
  fprintf (file, "Symbol format: %s\n", symbol_format);
1645
1646
  return TRUE;
1647
}
1648
1649
/* Special case for NAME (aout, get_section_contents)
1650
   It is not declared in libaout.h, neither implemented in aoutx.h.
1651
   Instead, a macro named aout_32_get_section_contents is defined in libaout.h.
1652
   So the default value of MY_get_section_contents provided by aout-target.h
1653
   is not correct, it has to be defined here with the right value.  */
1654
1655
#define MY_get_section_contents aout_32_get_section_contents
1656
1657
/* The following include will define m68kmint_prg_vec
1658
   and a default implementation for all the MY_ functions
1659
   not overriden here.  */
1660
1661
#include "aout-target.h"
1662
1663
/* Set the GEMDOS executable flags.
1664
   It is called by the linker emulation script.  */
1665
1666
bfd_boolean
1667
bfd_m68kmint_set_extended_flags (bfd *abfd, flagword prg_flags)
1668
{
1669
  struct mint_internal_info *myinfo;
1670
1671
  BFD_ASSERT(abfd->xvec == &m68kmint_prg_vec);
1672
  myinfo = obj_aout_ext (abfd);
1673
  BFD_ASSERT(myinfo != NULL);
1674
1675
  myinfo->prg_flags = prg_flags;
1676
1677
  return TRUE;
1678
}
1679
1680
/* Override the stack size.
1681
   It is called by the linker emulation script.  */
1682
1683
bfd_boolean
1684
bfd_m68kmint_set_stack_size (bfd *abfd, bfd_signed_vma stack_size)
1685
{
1686
  struct mint_internal_info *myinfo;
1687
1688
  BFD_ASSERT(abfd->xvec == &m68kmint_prg_vec);
1689
  myinfo = obj_aout_ext (abfd);
1690
  BFD_ASSERT(myinfo != NULL);
1691
1692
  myinfo->stack_size = stack_size;
1693
  myinfo->override_stack_size = TRUE;
1694
1695
  return TRUE;
1696
}
1697
1698
/* Add a TPA relocation entry.
1699
   It is called by BFD when linking the input sections, and by the
1700
   linker when it generates a reference to an address (in particular,
1701
   when building the constructors list).  */
1702
1703
bfd_boolean
1704
bfd_m68kmint_add_tpa_relocation_entry (bfd *abfd, bfd_vma address)
1705
{
1706
  struct mint_internal_info *myinfo;
1707
1708
  BFD_ASSERT(abfd->xvec == &m68kmint_prg_vec);
1709
  myinfo = obj_aout_ext (abfd);
1710
  BFD_ASSERT(myinfo != NULL);
1711
1712
  /* Enlarge the buffer if necessary.  */
1713
  if (myinfo->relocs_used * sizeof (bfd_vma) >= myinfo->relocs_allocated)
1714
    {
1715
      bfd_vma *newbuf;
1716
      myinfo->relocs_allocated += MINT_RELOC_CHUNKSIZE;
1717
      newbuf = bfd_realloc (myinfo->relocs, myinfo->relocs_allocated);
1718
      if (newbuf == NULL)
1719
	return FALSE;
1720
1721
      myinfo->relocs = newbuf;
1722
    }
1723
1724
  /* The TPA relative relocation actually just adds the address of
1725
     the text segment (i. e. beginning of the executable in memory)
1726
     to the addresses at the specified locations.  This allows an
1727
     executable to be loaded everywhere in the address space without
1728
     memory management.  */
1729
  myinfo->relocs[myinfo->relocs_used++] = address;
1730
1731
  return TRUE;
1732
}
(-)binutils-2.21.51.0.7/bfd/targets.c (+1 lines)
Lines 770-775 Link Here
770
extern const bfd_target m68kcoff_vec;
770
extern const bfd_target m68kcoff_vec;
771
extern const bfd_target m68kcoffun_vec;
771
extern const bfd_target m68kcoffun_vec;
772
extern const bfd_target m68klinux_vec;
772
extern const bfd_target m68klinux_vec;
773
extern const bfd_target m68kmint_prg_vec;
773
extern const bfd_target m68knetbsd_vec;
774
extern const bfd_target m68knetbsd_vec;
774
extern const bfd_target m68ksysvcoff_vec;
775
extern const bfd_target m68ksysvcoff_vec;
775
extern const bfd_target m88kbcs_vec;
776
extern const bfd_target m88kbcs_vec;
(-)binutils-2.21.51.0.7/binutils/configure (-1 / +1 lines)
Lines 13041-13047 Link Here
13041
13041
13042
13042
13043
case "${host}" in
13043
case "${host}" in
13044
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
13044
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows* | *-*-mint*)
13045
13045
13046
$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
13046
$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
13047
 ;;
13047
 ;;
(-)binutils-2.21.51.0.7/binutils/dlltool.c (-1 / +1 lines)
Lines 4360-4366 Link Here
4360
      if (*cp == '-')
4360
      if (*cp == '-')
4361
	dash = cp;
4361
	dash = cp;
4362
      if (
4362
      if (
4363
#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__)
4363
#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) || defined(__MINT__)
4364
	  *cp == ':' || *cp == '\\' ||
4364
	  *cp == ':' || *cp == '\\' ||
4365
#endif
4365
#endif
4366
	  *cp == '/')
4366
	  *cp == '/')
(-)binutils-2.21.51.0.7/binutils/dllwrap.c (-1 / +1 lines)
Lines 263-269 Link Here
263
	dash = cp;
263
	dash = cp;
264
264
265
      if (
265
      if (
266
#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__)
266
#if defined(__DJGPP__) || defined (__CYGWIN__) || defined(__WIN32__) || defined(__MINT__)
267
	  *cp == ':' || *cp == '\\' ||
267
	  *cp == ':' || *cp == '\\' ||
268
#endif
268
#endif
269
	  *cp == '/')
269
	  *cp == '/')
(-)binutils-2.21.51.0.7/binutils/readelf.c (+4 lines)
Lines 9903-9909 Link Here
9903
#ifndef __MSVCRT__
9903
#ifndef __MSVCRT__
9904
	  /* PR 11128: Use two separate invocations in order to work
9904
	  /* PR 11128: Use two separate invocations in order to work
9905
             around bugs in the Solaris 8 implementation of printf.  */
9905
             around bugs in the Solaris 8 implementation of printf.  */
9906
#if GCC_VERSION < 3000
9907
	  printf ("  [%6lx]  ", (unsigned long) (data - start));
9908
#else
9906
	  printf ("  [%6tx]  ", data - start);
9909
	  printf ("  [%6tx]  ", data - start);
9910
#endif
9907
	  printf ("%s\n", data);
9911
	  printf ("%s\n", data);
9908
#else
9912
#else
9909
	  printf ("  [%6Ix]  %s\n", (size_t) (data - start), data);
9913
	  printf ("  [%6Ix]  %s\n", (size_t) (data - start), data);
(-)binutils-2.21.51.0.7/binutils/resrc.c (-2 / +2 lines)
Lines 396-402 Link Here
396
    *space = 0;
396
    *space = 0;
397
397
398
  if (
398
  if (
399
#if defined (__DJGPP__) || defined (__CYGWIN__) || defined (_WIN32)
399
#if defined (__DJGPP__) || defined (__CYGWIN__) || defined (_WIN32) || defined (__MINT__)
400
      strchr (cmd, '\\') ||
400
      strchr (cmd, '\\') ||
401
#endif
401
#endif
402
      strchr (cmd, '/'))
402
      strchr (cmd, '/'))
Lines 514-520 Link Here
514
	  if (*cp == '-')
514
	  if (*cp == '-')
515
	    dash = cp;
515
	    dash = cp;
516
	  if (
516
	  if (
517
#if defined (__DJGPP__) || defined (__CYGWIN__) || defined(_WIN32)
517
#if defined (__DJGPP__) || defined (__CYGWIN__) || defined(_WIN32) || defined (__MINT__)
518
	      *cp == ':' || *cp == '\\' ||
518
	      *cp == ':' || *cp == '\\' ||
519
#endif
519
#endif
520
	      *cp == '/')
520
	      *cp == '/')
(-)binutils-2.21.51.0.7/gas/config/te-mint.h (+30 lines)
Line 0 Link Here
1
/* Copyright 2008 Free Software Foundation, Inc.
2
3
   This file is part of GAS, the GNU Assembler.
4
5
   GAS is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as
7
   published by the Free Software Foundation; either version 3,
8
   or (at your option) any later version.
9
10
   GAS is distributed in the hope that it will be useful, but
11
   WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13
   the GNU General Public License for more details.
14
15
   You should have received a copy of the GNU General Public License
16
   along with GAS; see the file COPYING.  If not, write to the Free
17
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
18
   02110-1301, USA.  */
19
20
#define TE_MINT
21
22
#define LOCAL_LABELS_DOLLAR 1
23
#define LOCAL_LABELS_FB 1
24
25
/* These define interfaces.  */
26
#ifdef   OBJ_HEADER
27
#include OBJ_HEADER
28
#else
29
#include "obj-format.h"
30
#endif
(-)binutils-2.21.51.0.7/gas/configure.tgt (+1 lines)
Lines 266-271 Link Here
266
  m68k-*-linux-*)			fmt=elf em=linux ;;
266
  m68k-*-linux-*)			fmt=elf em=linux ;;
267
  m68k-*-uclinux*)			fmt=elf em=uclinux ;;
267
  m68k-*-uclinux*)			fmt=elf em=uclinux ;;
268
  m68k-*-gnu*)				fmt=elf ;;
268
  m68k-*-gnu*)				fmt=elf ;;
269
  m68k-*-mint*)				fmt=aout em=mint bfd_gas=yes ;;
269
  m68k-*-netbsdelf*)			fmt=elf em=nbsd ;;
270
  m68k-*-netbsdelf*)			fmt=elf em=nbsd ;;
270
  m68k-*-netbsd*)			fmt=aout em=nbsd bfd_gas=yes ;;
271
  m68k-*-netbsd*)			fmt=aout em=nbsd bfd_gas=yes ;;
271
  m68k-*-openbsd*)			fmt=aout em=nbsd bfd_gas=yes ;;
272
  m68k-*-openbsd*)			fmt=aout em=nbsd bfd_gas=yes ;;
(-)binutils-2.21.51.0.7/gas/testsuite/gas/all/weakref1u.d (-1 / +1 lines)
Lines 3-9 Link Here
3
#source: weakref1.s
3
#source: weakref1.s
4
# aout turns undefined into *ABS* symbols.
4
# aout turns undefined into *ABS* symbols.
5
# see weakref1.d for comments on the other not-targets
5
# see weakref1.d for comments on the other not-targets
6
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd* ns32k-*-netbsd alpha*-*-osf* *-*-ecoff
6
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd* m68k-*-mint* ns32k-*-netbsd alpha*-*-osf* *-*-ecoff
7
7
8
# the rest of this file is generated with the following script:
8
# the rest of this file is generated with the following script:
9
# # script begin
9
# # script begin
(-)binutils-2.21.51.0.7/gas/testsuite/gas/m68k/all.exp (-1 / +1 lines)
Lines 71-77 Link Here
71
71
72
    gas_test_error "p11673.s" "-march=isab" "movel immediate with offset unsupported on isab"
72
    gas_test_error "p11673.s" "-march=isab" "movel immediate with offset unsupported on isab"
73
73
74
    if { [istarget *-*-*aout] || [istarget *-*-netbsd] || [istarget *-*-openbsd*] } then {
74
    if { [istarget *-*-*aout] || [istarget *-*-netbsd] || [istarget *-*-openbsd*] || [istarget *-*-mint*] } then {
75
      run_dump_test p3041
75
      run_dump_test p3041
76
      run_dump_test p3041data
76
      run_dump_test p3041data
77
      run_dump_test p3041pcrel
77
      run_dump_test p3041pcrel
(-)binutils-2.21.51.0.7/gas/testsuite/gas/m68k/br-isaa.d (-1 / +1 lines)
Lines 1-7 Link Here
1
#name: br-isaa.d
1
#name: br-isaa.d
2
#objdump: -dr
2
#objdump: -dr
3
#as: -march=isaa -pcrel
3
#as: -march=isaa -pcrel
4
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd*
4
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd* m68k-*-mint*
5
5
6
.*:     file format .*
6
.*:     file format .*
7
7
(-)binutils-2.21.51.0.7/gas/testsuite/gas/m68k/br-isab.d (-1 / +1 lines)
Lines 1-7 Link Here
1
#name: br-isab.d
1
#name: br-isab.d
2
#objdump: -dr
2
#objdump: -dr
3
#as: -march=isab -pcrel
3
#as: -march=isab -pcrel
4
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd*
4
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd* m68k-*-mint*
5
5
6
.*:     file format .*
6
.*:     file format .*
7
7
(-)binutils-2.21.51.0.7/gas/testsuite/gas/m68k/br-isac.d (-1 / +1 lines)
Lines 1-7 Link Here
1
#name: br-isac.d
1
#name: br-isac.d
2
#objdump: -dr
2
#objdump: -dr
3
#as: -march=isac -pcrel
3
#as: -march=isac -pcrel
4
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd*
4
#not-target: *-*-*aout m68k-*-netbsd m68k-*-openbsd* m68k-*-mint*
5
5
6
.*:     file format .*
6
.*:     file format .*
7
7
(-)binutils-2.21.51.0.7/include/filenames.h (-1 / +1 lines)
Lines 30-36 Link Here
30
extern "C" {
30
extern "C" {
31
#endif
31
#endif
32
32
33
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
33
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) || defined (__MINT__)
34
#  ifndef HAVE_DOS_BASED_FILE_SYSTEM
34
#  ifndef HAVE_DOS_BASED_FILE_SYSTEM
35
#    define HAVE_DOS_BASED_FILE_SYSTEM 1
35
#    define HAVE_DOS_BASED_FILE_SYSTEM 1
36
#  endif
36
#  endif
(-)binutils-2.21.51.0.7/include/getopt.h (-1 / +1 lines)
Lines 106-112 Link Here
106
   to find the declaration so provide a fully prototyped one.  If it
106
   to find the declaration so provide a fully prototyped one.  If it
107
   is 1, we found it so don't provide any declaration at all.  */
107
   is 1, we found it so don't provide any declaration at all.  */
108
#if !HAVE_DECL_GETOPT
108
#if !HAVE_DECL_GETOPT
109
#if defined (__GNU_LIBRARY__) || defined (HAVE_DECL_GETOPT)
109
#if defined (__GNU_LIBRARY__) || defined (__MINT__) || defined (HAVE_DECL_GETOPT)
110
/* Many other libraries have conflicting prototypes for getopt, with
110
/* Many other libraries have conflicting prototypes for getopt, with
111
   differences in the consts, in unistd.h.  To avoid compilation
111
   differences in the consts, in unistd.h.  To avoid compilation
112
   errors, only prototype getopt for the GNU C library.  */
112
   errors, only prototype getopt for the GNU C library.  */
(-)binutils-2.21.51.0.7/ld/Makefile.am (+5 lines)
Lines 308-313 Link Here
308
	em68kelf.c \
308
	em68kelf.c \
309
	em68kelfnbsd.c \
309
	em68kelfnbsd.c \
310
	em68klinux.c \
310
	em68klinux.c \
311
	em68kmint.c \
311
	em68knbsd.c \
312
	em68knbsd.c \
312
	em68kpsos.c \
313
	em68kpsos.c \
313
	em88kbcs.c \
314
	em88kbcs.c \
Lines 1319-1324 Link Here
1319
em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \
1320
em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \
1320
  $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
1321
  $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
1321
	${GENSCRIPTS} m68klinux "$(tdir_m68klinux)"
1322
	${GENSCRIPTS} m68klinux "$(tdir_m68klinux)"
1323
em68kmint.c: $(srcdir)/emulparams/m68kmint.sh \
1324
  $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/mint.em \
1325
  $(srcdir)/scripttempl/m68kmint.sc ${GEN_DEPENDS}
1326
	${GENSCRIPTS} m68kmint "$(tdir_m68kmint)"
1322
em68knbsd.c:	$(srcdir)/emulparams/m68knbsd.sh \
1327
em68knbsd.c:	$(srcdir)/emulparams/m68knbsd.sh \
1323
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
1328
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
1324
	${GENSCRIPTS} m68knbsd "$(tdir_m68knbsd)"
1329
	${GENSCRIPTS} m68knbsd "$(tdir_m68knbsd)"
(-)binutils-2.21.51.0.7/ld/Makefile.in (+6 lines)
Lines 614-619 Link Here
614
	em68kelf.c \
614
	em68kelf.c \
615
	em68kelfnbsd.c \
615
	em68kelfnbsd.c \
616
	em68klinux.c \
616
	em68klinux.c \
617
	em68kmint.c \
617
	em68knbsd.c \
618
	em68knbsd.c \
618
	em68kpsos.c \
619
	em68kpsos.c \
619
	em88kbcs.c \
620
	em88kbcs.c \
Lines 1229-1234 Link Here
1229
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kelf.Po@am__quote@
1230
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kelf.Po@am__quote@
1230
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kelfnbsd.Po@am__quote@
1231
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kelfnbsd.Po@am__quote@
1231
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68klinux.Po@am__quote@
1232
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68klinux.Po@am__quote@
1233
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kmint.Po@am__quote@
1232
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68knbsd.Po@am__quote@
1234
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68knbsd.Po@am__quote@
1233
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kpsos.Po@am__quote@
1235
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em68kpsos.Po@am__quote@
1234
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em88kbcs.Po@am__quote@
1236
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/em88kbcs.Po@am__quote@
Lines 2762-2767 Link Here
2762
em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \
2764
em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \
2763
  $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
2765
  $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
2764
	${GENSCRIPTS} m68klinux "$(tdir_m68klinux)"
2766
	${GENSCRIPTS} m68klinux "$(tdir_m68klinux)"
2767
em68kmint.c: $(srcdir)/emulparams/m68kmint.sh \
2768
  $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/mint.em \
2769
  $(srcdir)/scripttempl/m68kmint.sc ${GEN_DEPENDS}
2770
	${GENSCRIPTS} m68kmint "$(tdir_m68kmint)"
2765
em68knbsd.c:	$(srcdir)/emulparams/m68knbsd.sh \
2771
em68knbsd.c:	$(srcdir)/emulparams/m68knbsd.sh \
2766
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
2772
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
2767
	${GENSCRIPTS} m68knbsd "$(tdir_m68knbsd)"
2773
	${GENSCRIPTS} m68knbsd "$(tdir_m68knbsd)"
(-)binutils-2.21.51.0.7/ld/configure (-1 / +1 lines)
Lines 16557-16563 Link Here
16557
16557
16558
16558
16559
case "${host}" in
16559
case "${host}" in
16560
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
16560
*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows* | *-*-mint*)
16561
16561
16562
$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
16562
$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
16563
 ;;
16563
 ;;
(-)binutils-2.21.51.0.7/ld/configure.tgt (+1 lines)
Lines 344-349 Link Here
344
			tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'` ;;
344
			tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'` ;;
345
m68k-*-uclinux*)	targ_emul=m68kelf ;;
345
m68k-*-uclinux*)	targ_emul=m68kelf ;;
346
m68*-*-gnu*)		targ_emul=m68kelf ;;
346
m68*-*-gnu*)		targ_emul=m68kelf ;;
347
m68*-*-mint*)		targ_emul=m68kmint ;;
347
m68*-*-netbsd*4k*)	targ_emul=m68k4knbsd
348
m68*-*-netbsd*4k*)	targ_emul=m68k4knbsd
348
			targ_extra_emuls="m68knbsd m68kelfnbsd" ;;
349
			targ_extra_emuls="m68knbsd m68kelfnbsd" ;;
349
m68*-*-netbsdelf*)	targ_emul=m68kelfnbsd
350
m68*-*-netbsdelf*)	targ_emul=m68kelfnbsd
(-)binutils-2.21.51.0.7/ld/emulparams/m68kmint.sh (+6 lines)
Line 0 Link Here
1
SCRIPT_NAME=m68kmint
2
OUTPUT_FORMAT="a.out-mintprg"
3
RELOCATEABLE_OUTPUT_FORMAT="a.out-zero-big"
4
TEXT_START_ADDR=0xe4
5
ARCH=m68k
6
EXTRA_EM_FILE=mint
(-)binutils-2.21.51.0.7/ld/emultempl/generic.em (-2 / +2 lines)
Lines 138-145 Link Here
138
  ${LDEMUL_PLACE_ORPHAN-NULL},
138
  ${LDEMUL_PLACE_ORPHAN-NULL},
139
  ${LDEMUL_SET_SYMBOLS-NULL},
139
  ${LDEMUL_SET_SYMBOLS-NULL},
140
  ${LDEMUL_PARSE_ARGS-NULL},
140
  ${LDEMUL_PARSE_ARGS-NULL},
141
  NULL,	/* add_options */
141
  ${LDEMUL_ADD_OPTIONS-NULL},
142
  NULL,	/* handle_option */
142
  ${LDEMUL_HANDLE_OPTION-NULL},
143
  ${LDEMUL_UNRECOGNIZED_FILE-NULL},
143
  ${LDEMUL_UNRECOGNIZED_FILE-NULL},
144
  ${LDEMUL_LIST_OPTIONS-NULL},
144
  ${LDEMUL_LIST_OPTIONS-NULL},
145
  ${LDEMUL_RECOGNIZED_FILE-NULL},
145
  ${LDEMUL_RECOGNIZED_FILE-NULL},
(-)binutils-2.21.51.0.7/ld/emultempl/mint.em (+330 lines)
Line 0 Link Here
1
# This shell script emits a C file. -*- C -*-
2
#   Copyright 2006, 2007 Free Software Foundation, Inc.
3
#
4
# This file is part of the GNU Binutils.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
# MA 02110-1301, USA.
20
#
21
22
# This file is sourced from generic.em
23
#
24
fragment <<EOF
25
26
#include "getopt.h"
27
#include "ldgram.h"
28
29
/* Standard GEMDOS program flags.  */
30
#define _MINT_F_FASTLOAD      0x01    /* Don't clear heap.  */
31
#define _MINT_F_ALTLOAD       0x02    /* OK to load in alternate RAM.  */
32
#define _MINT_F_ALTALLOC      0x04    /* OK to malloc from alt. RAM.  */
33
#define _MINT_F_BESTFIT       0x08    /* Load with optimal heap size.  */
34
/* The memory flags are mutually exclusive.  */
35
#define _MINT_F_MEMPROTECTION 0xf0    /* Masks out protection bits.  */
36
#define _MINT_F_MEMPRIVATE    0x00    /* Memory is private.  */
37
#define _MINT_F_MEMGLOBAL     0x10    /* Read/write access to mem allowed.  */
38
#define _MINT_F_MEMSUPER      0x20    /* Only supervisor access allowed.  */
39
#define _MINT_F_MEMREADABLE   0x30    /* Any read access OK.  */
40
#define _MINT_F_SHTEXT        0x800   /* Program's text may be shared */
41
42
/* Option flags.  */
43
static flagword prg_flags = (_MINT_F_FASTLOAD | _MINT_F_ALTLOAD
44
			     | _MINT_F_ALTALLOC | _MINT_F_MEMPRIVATE);
45
46
/* If override_stack_size is TRUE, then the executable stack size
47
 * must be overriden with the value of stack_size.  */
48
static bfd_boolean override_stack_size = FALSE;
49
static bfd_signed_vma stack_size;
50
51
/* MiNT format extra command line options.  */
52
53
/* Used for setting flags in the MiNT header.  */
54
#define OPTION_FASTLOAD (300)
55
#define OPTION_NO_FASTLOAD (OPTION_FASTLOAD + 1)
56
#define OPTION_FASTRAM (OPTION_NO_FASTLOAD + 1)
57
#define OPTION_NO_FASTRAM (OPTION_FASTRAM + 1)
58
#define OPTION_FASTALLOC (OPTION_NO_FASTRAM + 1)
59
#define OPTION_NO_FASTALLOC (OPTION_FASTALLOC + 1)
60
#define OPTION_BESTFIT (OPTION_NO_FASTALLOC + 1)
61
#define OPTION_NO_BESTFIT (OPTION_BESTFIT + 1)
62
#define OPTION_BASEREL (OPTION_NO_BESTFIT + 1)
63
#define OPTION_NO_BASEREL (OPTION_BASEREL + 1)
64
#define OPTION_MEM_PRIVATE (OPTION_NO_BASEREL + 1)
65
#define OPTION_MEM_GLOBAL (OPTION_MEM_PRIVATE + 1)
66
#define OPTION_MEM_SUPER (OPTION_MEM_GLOBAL + 1)
67
#define OPTION_MEM_READONLY (OPTION_MEM_SUPER + 1)
68
#define OPTION_PRG_FLAGS (OPTION_MEM_READONLY + 1)
69
#define OPTION_STACK (OPTION_PRG_FLAGS + 1)
70
71
static void
72
gld${EMULATION_NAME}_add_options
73
  (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
74
    struct option **longopts, int nrl ATTRIBUTE_UNUSED,
75
    struct option **really_longopts ATTRIBUTE_UNUSED)
76
{
77
  static const struct option xtra_long[] = {
78
    {"mfastload", no_argument, NULL, OPTION_FASTLOAD},
79
    {"mno-fastload", no_argument, NULL, OPTION_NO_FASTLOAD},
80
    {"mfastram", no_argument, NULL, OPTION_FASTRAM},
81
    {"mno-fastram", no_argument, NULL, OPTION_NO_FASTRAM},
82
    {"maltram", no_argument, NULL, OPTION_FASTRAM},
83
    {"mno-altram", no_argument, NULL, OPTION_NO_FASTRAM},
84
    {"mfastalloc", no_argument, NULL, OPTION_FASTALLOC},
85
    {"mno-fastalloc", no_argument, NULL, OPTION_NO_FASTALLOC},
86
    {"maltalloc", no_argument, NULL, OPTION_FASTALLOC},
87
    {"mno-altalloc", no_argument, NULL, OPTION_NO_FASTALLOC},
88
    {"mbest-fit", no_argument, NULL, OPTION_BESTFIT},
89
    {"mno-best-fit", no_argument, NULL, OPTION_NO_BESTFIT},
90
    {"mbaserel", no_argument, NULL, OPTION_BASEREL},
91
    {"mno-baserel", no_argument, NULL, OPTION_NO_BASEREL},
92
    {"mshared-text", no_argument, NULL, OPTION_BASEREL},
93
    {"mno-shared-text", no_argument, NULL, OPTION_NO_BASEREL},
94
    {"msharable-text", no_argument, NULL, OPTION_BASEREL},
95
    {"mno-sharable-text", no_argument, NULL, OPTION_NO_BASEREL},
96
    /* Memory protection bits.  */
97
    {"mprivate-memory", no_argument, NULL, OPTION_MEM_PRIVATE },
98
    {"mglobal-memory", no_argument, NULL, OPTION_MEM_GLOBAL},
99
    {"msuper-memory", no_argument, NULL, OPTION_MEM_SUPER},
100
    {"mreadable-memory", no_argument, NULL, OPTION_MEM_READONLY},
101
    {"mreadonly-memory", no_argument, NULL, OPTION_MEM_READONLY},
102
    {"mprg-flags", required_argument, NULL, OPTION_PRG_FLAGS},
103
    {"stack", required_argument, NULL, OPTION_STACK},
104
    {NULL, no_argument, NULL, 0}
105
  };
106
107
  *longopts = (struct option *)
108
    xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
109
  memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
110
}
111
112
static bfd_boolean
113
gld${EMULATION_NAME}_handle_option (int optc)
114
{
115
  switch (optc)
116
    {
117
    default:
118
      return FALSE;
119
120
    case OPTION_FASTLOAD:
121
      prg_flags |= _MINT_F_FASTLOAD;
122
      break;
123
124
    case OPTION_NO_FASTLOAD:
125
      prg_flags &= ~_MINT_F_FASTLOAD;
126
      break;
127
128
    case OPTION_FASTRAM:
129
      prg_flags |= _MINT_F_ALTLOAD;
130
      break;
131
132
    case OPTION_NO_FASTRAM:
133
      prg_flags &= ~_MINT_F_ALTLOAD;
134
      break;
135
136
    case OPTION_FASTALLOC:
137
      prg_flags |= _MINT_F_ALTALLOC;
138
      break;
139
140
    case OPTION_NO_FASTALLOC:
141
      prg_flags &= ~_MINT_F_ALTALLOC;
142
      break;
143
144
    case OPTION_BESTFIT:
145
      prg_flags |= _MINT_F_BESTFIT;
146
      break;
147
148
    case OPTION_NO_BESTFIT:
149
      prg_flags &= ~_MINT_F_BESTFIT;
150
      break;
151
152
    case OPTION_BASEREL:
153
      prg_flags |= _MINT_F_SHTEXT;
154
      break;
155
156
    case OPTION_NO_BASEREL:
157
      prg_flags &= ~_MINT_F_SHTEXT;
158
      break;
159
160
    case OPTION_MEM_PRIVATE:
161
      prg_flags &= ~_MINT_F_MEMPROTECTION;
162
      break;
163
164
    case OPTION_MEM_GLOBAL:
165
      prg_flags &= ~_MINT_F_MEMPROTECTION;
166
      prg_flags |= _MINT_F_MEMPRIVATE;
167
      break;
168
169
    case OPTION_MEM_SUPER:
170
      prg_flags &= ~_MINT_F_MEMPROTECTION;
171
      prg_flags |= _MINT_F_MEMSUPER;
172
      break;
173
174
    case OPTION_MEM_READONLY:
175
      prg_flags &= ~_MINT_F_MEMPROTECTION;
176
      prg_flags |= _MINT_F_MEMREADABLE;
177
      break;
178
179
    case OPTION_PRG_FLAGS:
180
      {
181
	char* tail;
182
	unsigned long flag_value = strtoul (optarg, &tail, 0);
183
184
	if (*tail != '\0')
185
	  einfo (_("%P: warning: ignoring invalid program flags %s\n"), optarg);
186
	else
187
	  prg_flags = flag_value;
188
189
	break;
190
      }
191
    case OPTION_STACK:
192
      {
193
	char* tail;
194
	long size = strtol (optarg, &tail, 0);
195
196
	if (*tail == 'K' || *tail == 'k')
197
	  {
198
	    size *= 1024;
199
	    ++tail;
200
	  }
201
	else if (*tail == 'M' || *tail == 'm')
202
	  {
203
	    size *= 1024*1024;
204
	    ++tail;
205
	  }
206
207
	if (*tail != '\0')
208
	  einfo (_("%P: warning: ignoring invalid stack size %s\n"), optarg);
209
	else
210
	{
211
	  stack_size = (bfd_signed_vma) size;
212
	  override_stack_size = TRUE;
213
	}
214
215
	break;
216
      }
217
    }
218
  return TRUE;
219
}
220
221
/* This callback is called when ld is invoked
222
   with the --help and --target-help options.  */
223
224
static void
225
gld_${EMULATION_NAME}_list_options (FILE *file)
226
{
227
  fprintf (file, _("  --m[no-]fastload            Enable/Disable not cleaning the heap on startup\n"));
228
  fprintf (file, _("  --m[no-]altram, --m[no-]fastram\n"));
229
  fprintf (file, _("                              Enable/Disable loading into alternate RAM\n"));
230
  fprintf (file, _("  --m[no-]altalloc, --m[no-]fastalloc\n"));
231
  fprintf (file, _("                              Enable/Disable malloc from alternate RAM\n"));
232
  fprintf (file, _("  --m[no-]best-fit            Enable/Disable loading with optimal heap size\n"));
233
  fprintf (file, _("  --m[no-]sharable-text, --m[no-]shared-text, --m[no-]baserel\n"));
234
  fprintf (file, _("                              Enable/Disable sharing the text segment\n"));
235
  fprintf (file, "\n");
236
  fprintf (file, _("The following memory options are mutually exclusive:\n"));
237
  fprintf (file, _("  --mprivate-memory           Process memory is not accessible\n"));
238
  fprintf (file, _("  --mglobal-memory            Process memory is readable and writable\n"));
239
  fprintf (file, _("  --msuper-memory             Process memory is accessible in supervisor mode\n"));
240
  fprintf (file, _("  --mreadonly-memory, --mreadable-memory\n"));
241
  fprintf (file, _("                              Process memory is readable but not writable\n"));
242
  fprintf (file, "\n");
243
  fprintf (file, _("  --mprg-flags <value>        Set all the flags with an integer raw value\n"));
244
  fprintf (file, _("  --stack <size>              Override the stack size (suffix k or M allowed)\n"));
245
}
246
247
/* This callback is called by lang_for_each_statement. It checks that the
248
   output sections speficied in the linker script are compatible with the MiNT
249
   executable format.  */
250
251
static void
252
gld${EMULATION_NAME}_check_output_sections (lang_statement_union_type *s)
253
{
254
  if (s->header.type == lang_output_section_statement_enum)
255
    {
256
      lang_output_section_statement_type *oss = &s->output_section_statement;
257
258
      if (strcmp(oss->name, ".text") == 0 && oss->bfd_section->vma != ${TEXT_START_ADDR})
259
	einfo (_("%F%P: the VMA of section %A must be 0x%V, but actual value is 0x%V\n"),
260
	  oss->bfd_section, ${TEXT_START_ADDR}, oss->bfd_section->vma);
261
      else if (strcmp(oss->name, ".data") == 0 && oss->addr_tree != NULL)
262
	einfo (_("%F%P: the VMA of section %A must not be specified\n"),
263
	  oss->bfd_section);
264
      else if (strcmp(oss->name, ".bss") == 0 && oss->addr_tree != NULL)
265
	einfo (_("%F%P: the VMA of section %A must not be specified\n"),
266
	  oss->bfd_section);
267
    }
268
}
269
270
/* This callback is called by lang_for_each_statement. It looks for the data
271
   statements of type REL generated by the linker, and adds a TPA relocation
272
   entry for them. This is used by the CONSTRUCTORS list.  */
273
274
static void
275
gld${EMULATION_NAME}_add_tpa_relocs (lang_statement_union_type *s)
276
{
277
  if (s->header.type == lang_data_statement_enum)
278
    {
279
      lang_data_statement_type *ds = &s->data_statement;
280
281
      if (ds->exp->type.node_code == REL)
282
	{
283
	  if (ds->type == LONG)
284
	    {
285
	      bfd_vma tpa_address = ds->output_section->vma + ds->output_offset;
286
	      if (!bfd_m68kmint_add_tpa_relocation_entry(link_info.output_bfd, tpa_address))
287
		einfo (_("%F%P:%B: unable to add a relocation entry\n"), link_info.output_bfd);
288
	    }
289
	    else
290
	    {
291
	      einfo (_("%F%P:%B: invalid size for TPA relocation entry in section %A, offset 0x%V\n"),
292
		link_info.output_bfd, ds->output_section, ds->output_offset);
293
	    }
294
	}
295
    }
296
}
297
298
/* Final emulation specific call.  */
299
300
static void
301
gld${EMULATION_NAME}_finish (void)
302
{
303
  /* Do nothing if we are not generating a MiNT executable (ex: binary).  */
304
  if (strcmp (bfd_get_target (link_info.output_bfd), "${OUTPUT_FORMAT}") != 0)
305
    return;
306
307
  /* Check the output sections.  */
308
  lang_for_each_statement (gld${EMULATION_NAME}_check_output_sections);
309
310
  /* Set the GEMDOS executable header flags.  */
311
  if (!bfd_m68kmint_set_extended_flags (link_info.output_bfd, prg_flags))
312
    einfo (_("%F%P:%B: unable to set the header flags\n"), link_info.output_bfd);
313
314
  /* Override the stack size.  */
315
  if (override_stack_size)
316
    if (!bfd_m68kmint_set_stack_size (link_info.output_bfd, stack_size))
317
      einfo (_("%F%P:%B: unable to set the stack size\n"), link_info.output_bfd);
318
319
  /* Generate TPA relocation entries for the data statements.  */
320
  lang_for_each_statement (gld${EMULATION_NAME}_add_tpa_relocs);
321
}
322
323
EOF
324
325
# Put these extra routines in ld_${EMULATION_NAME}_emulation
326
#
327
LDEMUL_ADD_OPTIONS=gld${EMULATION_NAME}_add_options
328
LDEMUL_HANDLE_OPTION=gld${EMULATION_NAME}_handle_option
329
LDEMUL_LIST_OPTIONS=gld_${EMULATION_NAME}_list_options
330
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
(-)binutils-2.21.51.0.7/ld/scripttempl/m68kmint.sc (+35 lines)
Line 0 Link Here
1
cat <<EOF
2
${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
3
${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
4
${RELOCATING+${LIB_SEARCH_DIRS}}
5
SECTIONS
6
{
7
  ${RELOCATING+/* The VMA of the .text section is ${TEXT_START_ADDR} instead of 0
8
     because the extended MiNT header is just before,
9
     at the beginning of the TEXT segment.  */}
10
  .text ${RELOCATING+${TEXT_START_ADDR}}:
11
  {
12
    CREATE_OBJECT_SYMBOLS
13
    *(.text)
14
    ${CONSTRUCTING+CONSTRUCTORS}
15
    ${RELOCATING+_etext = .;}
16
    ${RELOCATING+__etext = .;}
17
  }
18
19
  .data :
20
  {
21
    *(.data)
22
    ${RELOCATING+_edata = .;}
23
    ${RELOCATING+__edata = .;}
24
  }
25
26
  .bss :
27
  {
28
    ${RELOCATING+__bss_start = .;}
29
    *(.bss)
30
    *(COMMON)
31
    ${RELOCATING+_end = .;}
32
    ${RELOCATING+__end = .;}
33
  }
34
}
35
EOF
(-)binutils-2.21.51.0.7/libiberty/configure (+1 lines)
Lines 4850-4855 Link Here
4850
if [ "${shared}" = "yes" ]; then
4850
if [ "${shared}" = "yes" ]; then
4851
  case "${host}" in
4851
  case "${host}" in
4852
    *-*-cygwin*)	;;
4852
    *-*-cygwin*)	;;
4853
    *-*-mint*)		;;
4853
    alpha*-*-linux*)	PICFLAG=-fPIC ;;
4854
    alpha*-*-linux*)	PICFLAG=-fPIC ;;
4854
    arm*-*-*)		PICFLAG=-fPIC ;;
4855
    arm*-*-*)		PICFLAG=-fPIC ;;
4855
    hppa*-*-*)		PICFLAG=-fPIC ;;
4856
    hppa*-*-*)		PICFLAG=-fPIC ;;
(-)binutils-2.21.51.0.7/libiberty/configure.ac (+1 lines)
Lines 201-206 Link Here
201
if [[ "${shared}" = "yes" ]]; then
201
if [[ "${shared}" = "yes" ]]; then
202
  case "${host}" in
202
  case "${host}" in
203
    *-*-cygwin*)	;;
203
    *-*-cygwin*)	;;
204
    *-*-mint*)		;;
204
    alpha*-*-linux*)	PICFLAG=-fPIC ;;
205
    alpha*-*-linux*)	PICFLAG=-fPIC ;;
205
    arm*-*-*)		PICFLAG=-fPIC ;;
206
    arm*-*-*)		PICFLAG=-fPIC ;;
206
    hppa*-*-*)		PICFLAG=-fPIC ;;
207
    hppa*-*-*)		PICFLAG=-fPIC ;;
(-)binutils-2.21.51.0.7/libiberty/hex.c (-1 / +1 lines)
Lines 24-30 Link Here
24
#include "libiberty.h"
24
#include "libiberty.h"
25
#include "safe-ctype.h" /* for HOST_CHARSET_ASCII */
25
#include "safe-ctype.h" /* for HOST_CHARSET_ASCII */
26
26
27
#if EOF != -1
27
#if !(EOF == -1)	/* gcc 2.95.3 has bug in '!=' operator for negative constants */
28
 #error "hex.c requires EOF == -1"
28
 #error "hex.c requires EOF == -1"
29
#endif
29
#endif
30
30
(-)binutils-2.21.51.0.7/libiberty/safe-ctype.c (-1 / +1 lines)
Lines 119-125 Link Here
119
#include <safe-ctype.h>
119
#include <safe-ctype.h>
120
#include <stdio.h>  /* for EOF */
120
#include <stdio.h>  /* for EOF */
121
121
122
#if EOF != -1
122
#if !(EOF == -1)	/* gcc 2.95.3 has bug in '!=' operator for negative constants */
123
 #error "<safe-ctype.h> requires EOF == -1"
123
 #error "<safe-ctype.h> requires EOF == -1"
124
#endif
124
#endif
125
125
(-)binutils-2.21.51.0.7/ld/lexsup.c (+3 lines)
Lines 57-62 Link Here
57
#define	S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
57
#define	S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
58
#endif
58
#endif
59
59
60
/* Report plugin symbols.  */
61
bfd_boolean report_plugin_symbols;
62
60
static void set_default_dirlist (char *);
63
static void set_default_dirlist (char *);
61
static void set_section_start (char *, char *);
64
static void set_section_start (char *, char *);
62
static void set_segment_start (const char *, char *);
65
static void set_segment_start (const char *, char *);
(-)binutils-2.21.51.0.7/ld/plugin.c (-3 lines)
Lines 36-44 Link Here
36
#include <Windows.h>
36
#include <Windows.h>
37
#endif
37
#endif
38
38
39
/* Report plugin symbols.  */
40
bfd_boolean report_plugin_symbols;
41
42
/* Stores a single argument passed to a plugin.  */
39
/* Stores a single argument passed to a plugin.  */
43
typedef struct plugin_arg
40
typedef struct plugin_arg
44
{
41
{

Return to bug 362559