kolibrios-fun/programs/develop/binutils/patch-2.20.diff

789 lines
25 KiB
Diff
Raw Normal View History

diff -u -r -N /d/ftp/binutils-2.20/bfd/config.bfd binutils-2.20/bfd/config.bfd
--- /d/ftp/binutils-2.20/bfd/config.bfd 2009-08-06 17:38:00 +0000
+++ binutils-2.20/bfd/config.bfd 2011-08-07 21:03:49 +0000
@@ -703,6 +703,12 @@
targ_selfvecs=i386chaos_vec
;;
+ i[3-7]86-*-kos32*)
+ targ_defvec=i386aout_vec
+ targ_selvecs="kos32_vec i386pe_vec i386pei_vec bfd_elf32_i386_vec"
+ targ_underscore=yes
+ ;;
+
i860-*-mach3* | i860-*-osf1* | i860-*-coff*)
targ_defvec=i860coff_vec
;;
@@ -746,12 +752,12 @@
targ_defvec=bfd_elf32_lm32_vec
targ_selvecs=bfd_elf32_lm32fdpic_vec
;;
-
+
lm32-*-*linux*)
targ_defvec=bfd_elf32_lm32fdpic_vec
targ_selvecs=bfd_elf32_lm32_vec
;;
-
+
m32c-*-elf | m32c-*-rtems*)
targ_defvec=bfd_elf32_m32c_vec
;;
@@ -963,11 +969,11 @@
want64=true
;;
#endif
- mips*el-sde-elf*)
+ mips*el-sde-elf*)
targ_defvec=bfd_elf32_tradlittlemips_vec
targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
want64=true
- ;;
+ ;;
mips*-sde-elf*)
targ_defvec=bfd_elf32_tradbigmips_vec
targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
diff -u -r -N /d/ftp/binutils-2.20/bfd/configure binutils-2.20/bfd/configure
--- /d/ftp/binutils-2.20/bfd/configure 2009-10-16 11:47:48 +0000
+++ binutils-2.20/bfd/configure 2011-08-08 07:12:50 +0000
@@ -14970,6 +14970,7 @@
icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
ieee_vec) tb="$tb ieee.lo" ;;
+ kos32_vec) tb="$tb kos32.lo" ;;
m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
diff -u -r -N /d/ftp/binutils-2.20/bfd/configure.in binutils-2.20/bfd/configure.in
--- /d/ftp/binutils-2.20/bfd/configure.in 2009-10-16 11:47:44 +0000
+++ binutils-2.20/bfd/configure.in 2011-08-08 07:13:10 +0000
@@ -858,6 +858,7 @@
icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
ieee_vec) tb="$tb ieee.lo" ;;
+ kos32_vec) tb="$tb kos32.lo" ;;
m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
diff -u -r -N /d/ftp/binutils-2.20/bfd/kos32.c binutils-2.20/bfd/kos32.c
--- /d/ftp/binutils-2.20/bfd/kos32.c 1970-01-01 00:00:00 +0000
+++ binutils-2.20/bfd/kos32.c 2011-08-08 05:50:52 +0000
@@ -0,0 +1,220 @@
+/* BFD back-end for MS-DOS executables.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002,
+ 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+ Written by Bryan Ford of the University of Utah.
+
+ Contributed by the Center for Software Science at the
+ University of Utah (pa-gdb-bugs@cs.utah.edu).
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "libaout.h"
+
+#define KOS_MAGIC_0 0x554e454D
+#define KOS_MAGIC_1 0x31305445
+#define KOS_MAGIC_2 0x32305445
+
+
+static int
+kos32_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+static bfd_boolean
+kos32_write_object_contents (bfd *abfd)
+{
+ static char hdr[12];
+ file_ptr outfile_size = sizeof(hdr);
+ bfd_vma high_vma = 0;
+ asection *sec;
+
+ /* Find the total size of the program on disk and in memory. */
+ for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
+ {
+ if (sec->size == 0)
+ continue;
+ if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
+ {
+ bfd_vma sec_vma = bfd_get_section_vma (abfd, sec) + sec->size;
+ if (sec_vma > high_vma)
+ high_vma = sec_vma;
+ }
+ if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
+ {
+ file_ptr sec_end = (sizeof (hdr)
+ + bfd_get_section_vma (abfd, sec)
+ + sec->size);
+ if (sec_end > outfile_size)
+ outfile_size = sec_end;
+ }
+ }
+
+ /* Make sure the program isn't too big. */
+// if (high_vma > (bfd_vma)0xffff)
+// {
+// bfd_set_error(bfd_error_file_too_big);
+// return FALSE;
+// }
+
+ /* Constants. */
+ H_PUT_32 (abfd, KOS_MAGIC_0, &hdr[0]);
+ H_PUT_32 (abfd, KOS_MAGIC_2, &hdr[4]);
+ H_PUT_32 (abfd, 1, &hdr[8]);
+
+// if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+// || bfd_bwrite (hdr, (bfd_size_type) sizeof(hdr), abfd) != sizeof(hdr))
+// return FALSE;
+
+ return TRUE;
+}
+
+static bfd_boolean
+kos32_set_section_contents (bfd *abfd,
+ sec_ptr section,
+ const void *location,
+ file_ptr offset,
+ bfd_size_type count)
+{
+
+ if (count == 0)
+ return TRUE;
+
+ section->filepos = bfd_get_section_vma (abfd, section);
+
+ if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
+ {
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
+ || bfd_bwrite (location, count, abfd) != count)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static bfd_boolean
+kos32_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
+{
+ return TRUE;
+}
+
+
+#define kos32_make_empty_symbol _bfd_generic_make_empty_symbol
+#define kos32_bfd_reloc_type_lookup aout_32_reloc_type_lookup
+#define kos32_bfd_reloc_name_lookup aout_32_reloc_name_lookup
+
+#define kos32_close_and_cleanup _bfd_generic_close_and_cleanup
+#define kos32_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define kos32_new_section_hook _bfd_generic_new_section_hook
+#define kos32_get_section_contents _bfd_generic_get_section_contents
+#define kos32_get_section_contents_in_window \
+ _bfd_generic_get_section_contents_in_window
+#define kos32_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define kos32_bfd_relax_section bfd_generic_relax_section
+#define kos32_bfd_gc_sections bfd_generic_gc_sections
+#define kos32_bfd_merge_sections bfd_generic_merge_sections
+#define kos32_bfd_is_group_section bfd_generic_is_group_section
+#define kos32_bfd_discard_group bfd_generic_discard_group
+#define kos32_section_already_linked \
+ _bfd_generic_section_already_linked
+#define kos32_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define kos32_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define kos32_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#define kos32_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define kos32_bfd_link_just_syms _bfd_generic_link_just_syms
+#define kos32_bfd_final_link _bfd_generic_final_link
+#define kos32_bfd_link_split_section _bfd_generic_link_split_section
+#define kos32_set_arch_mach _bfd_generic_set_arch_mach
+
+#define kos32_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
+#define kos32_canonicalize_symtab _bfd_nosymbols_canonicalize_symtab
+#define kos32_print_symbol _bfd_nosymbols_print_symbol
+#define kos32_get_symbol_info _bfd_nosymbols_get_symbol_info
+#define kos32_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define kos32_find_inliner_info _bfd_nosymbols_find_inliner_info
+#define kos32_get_lineno _bfd_nosymbols_get_lineno
+#define kos32_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define kos32_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
+#define kos32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define kos32_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define kos32_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
+
+#define kos32_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
+#define kos32_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
+#define kos32_32_bfd_link_split_section _bfd_generic_link_split_section
+
+const bfd_target kos32_vec =
+ {
+ "kos32", /* name */
+ bfd_target_msdos_flavour,
+ BFD_ENDIAN_LITTLE, /* target byte order */
+ BFD_ENDIAN_LITTLE, /* target headers byte order */
+ (EXEC_P), /* object flags */
+ (SEC_CODE | SEC_DATA | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 16, /* ar_max_namelen */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
+
+ {
+ _bfd_dummy_target,
+ _bfd_dummy_target, /* bfd_check_format */
+ _bfd_dummy_target,
+ _bfd_dummy_target,
+ },
+ {
+ bfd_false,
+ kos32_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false,
+ },
+ { /* bfd_write_contents */
+ bfd_false,
+ kos32_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false,
+ },
+
+ BFD_JUMP_TABLE_GENERIC (kos32),
+ BFD_JUMP_TABLE_COPY (_bfd_generic),
+ BFD_JUMP_TABLE_CORE (_bfd_nocore),
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
+ BFD_JUMP_TABLE_SYMBOLS (kos32),
+ BFD_JUMP_TABLE_RELOCS (kos32),
+ BFD_JUMP_TABLE_WRITE (kos32),
+ BFD_JUMP_TABLE_LINK (kos32),
+ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+ NULL,
+
+ (PTR) 0
+ };
+
+
diff -u -r -N /d/ftp/binutils-2.20/bfd/targets.c binutils-2.20/bfd/targets.c
--- /d/ftp/binutils-2.20/bfd/targets.c 2009-09-10 11:47:14 +0000
+++ binutils-2.20/bfd/targets.c 2011-08-07 19:50:55 +0000
@@ -737,6 +737,7 @@
extern const bfd_target icoff_big_vec;
extern const bfd_target icoff_little_vec;
extern const bfd_target ieee_vec;
+extern const bfd_target kos32_vec;
extern const bfd_target m68k4knetbsd_vec;
extern const bfd_target m68kaux_coff_vec;
extern const bfd_target m68kcoff_vec;
@@ -1103,6 +1104,7 @@
&icoff_big_vec,
&icoff_little_vec,
&ieee_vec,
+ &kos32_vec,
#if 0
&m68k4knetbsd_vec,
&m68kaux_coff_vec,
diff -u -r -N /d/ftp/binutils-2.20/config.sub binutils-2.20/config.sub
--- /d/ftp/binutils-2.20/config.sub 2009-08-17 04:10:30 +0000
+++ binutils-2.20/config.sub 2011-08-07 16:34:28 +0000
@@ -1293,7 +1293,7 @@
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -kos32*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
diff -u -r -N /d/ftp/binutils-2.20/gas/configure.tgt binutils-2.20/gas/configure.tgt
--- /d/ftp/binutils-2.20/gas/configure.tgt 2009-09-09 08:13:28 +0000
+++ binutils-2.20/gas/configure.tgt 2011-08-07 16:44:51 +0000
@@ -226,6 +226,7 @@
i386-*-pe) fmt=coff em=pe ;;
i386-*-cygwin*) fmt=coff em=pe ;;
i386-*-interix*) fmt=coff em=interix ;;
+ i386-*-kos32*) fmt=coff em=pe ;;
i386-*-mingw*)
case ${cpu} in
x86_64*) fmt=coff em=pep ;;
diff -u -r -N /d/ftp/binutils-2.20/ld/Makefile.in binutils-2.20/ld/Makefile.in
--- /d/ftp/binutils-2.20/ld/Makefile.in 2009-09-07 12:10:24 +0000
+++ binutils-2.20/ld/Makefile.in 2011-08-07 19:00:16 +0000
@@ -551,6 +551,7 @@
ei386pe.o \
ei386pe_posix.o \
ei386pep.o \
+ ekos32.o \
elnk960.o \
em32relf.o \
em32rlelf.o \
@@ -2628,6 +2629,9 @@
ei386pep.c: $(srcdir)/emulparams/i386pep.sh \
$(srcdir)/emultempl/pep.em $(srcdir)/scripttempl/pep.sc ${GEN_DEPENDS}
${GENSCRIPTS} i386pep "$(tdir_i386pe)"
+ekos32.c: $(srcdir)/emulparams/kos32.sh \
+ $(srcdir)/emultempl/kos32.em $(srcdir)/scripttempl/kos32.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} kos32 "$(tdir_kos32)"
elnk960.c: $(srcdir)/emulparams/lnk960.sh \
$(srcdir)/emultempl/lnk960.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS}
${GENSCRIPTS} lnk960 "$(tdir_lnk960)"
diff -u -r -N /d/ftp/binutils-2.20/ld/configure.tgt binutils-2.20/ld/configure.tgt
--- /d/ftp/binutils-2.20/ld/configure.tgt 2009-08-06 17:38:04 +0000
+++ binutils-2.20/ld/configure.tgt 2011-08-07 18:57:57 +0000
@@ -155,7 +155,7 @@
frv-*-*linux*) targ_emul=elf32frvfd ;;
frv-*-*) targ_emul=elf32frv ; targ_extra_emuls="elf32frvfd"
;;
-moxie-*-*) targ_emul=elf32moxie
+moxie-*-*) targ_emul=elf32moxie
;;
h8300-*-hms* | h8300-*-coff* | h8300-*-rtemscoff*)
targ_emul=h8300; targ_extra_emuls="h8300h h8300s h8300hn h8300sn h8300sx h8300sxn" ;;
@@ -275,6 +275,7 @@
targ_extra_ofiles="deffilep.o pe-dll.o" ;;
x86_64-*-mingw*) targ_emul=i386pep ;
targ_extra_ofiles="deffilep.o pep-dll.o" ;;
+i[3-7]86-*-kos32*) targ_emul=kos32 ;;
i[3-7]86-*-interix*) targ_emul=i386pe_posix;
targ_extra_ofiles="deffilep.o pe-dll.o" ;;
i[3-7]86-*-beospe*) targ_emul=i386beos ;;
@@ -307,7 +308,7 @@
iq2000-*-elf) targ_emul=elf32iq2000 ; targ_extra_emuls="elf32iq10"
;;
lm32-*-*linux*) targ_emul=elf32lm32fd ;;
-lm32-*-*) targ_emul=elf32lm32 ; targ_extra_emuls="elf32lm32fd"
+lm32-*-*) targ_emul=elf32lm32 ; targ_extra_emuls="elf32lm32fd"
;;
m32c-*-elf | m32c-*-rtems*)
targ_emul=elf32m32c
@@ -318,9 +319,9 @@
m32r*le-*-linux-*) targ_emul=m32rlelf_linux ;;
m32r*-*-linux-*) targ_emul=m32relf_linux
;;
-m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
+m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb" ;;
-m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
+m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
targ_extra_emuls="m68hc12elfb m68hc11elf m68hc11elfb" ;;
m68*-sun-sunos[34]*) targ_emul=sun3 ;;
m68*-wrs-vxworks*) targ_emul=sun3 ;;
@@ -635,7 +636,7 @@
;;
w65-*-*) targ_emul=w65
;;
-xc16x-*-elf) targ_emul=elf32xc16x
+xc16x-*-elf) targ_emul=elf32xc16x
targ_extra_emuls="elf32xc16xl elf32xc16xs"
;;
xstormy16-*-*) targ_emul=elf32xstormy16
diff -u -r -N /d/ftp/binutils-2.20/ld/emulparams/kos32.sh binutils-2.20/ld/emulparams/kos32.sh
--- /d/ftp/binutils-2.20/ld/emulparams/kos32.sh 1970-01-01 00:00:00 +0000
+++ binutils-2.20/ld/emulparams/kos32.sh 2011-08-07 19:42:30 +0000
@@ -0,0 +1,8 @@
+ARCH=i386
+SCRIPT_NAME=kos32
+OUTPUT_FORMAT="kos32"
+TEMPLATE_NAME=kos32
+ENTRY="__start"
+INITIAL_SYMBOL_CHAR=\"_\"
+NOP=0x90909090
+TARGET_PAGE_SIZE=0x1000
diff -u -r -N /d/ftp/binutils-2.20/ld/emultempl/kos32.em binutils-2.20/ld/emultempl/kos32.em
--- /d/ftp/binutils-2.20/ld/emultempl/kos32.em 1970-01-01 00:00:00 +0000
+++ binutils-2.20/ld/emultempl/kos32.em 2011-08-08 06:34:03 +0000
@@ -0,0 +1,247 @@
+# This shell script emits a C file. -*- C -*-
+# Copyright 2007 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+fragment <<EOF
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "bfdlink.h"
+#include "getopt.h"
+#include "libiberty.h"
+#include "ld.h"
+#include "ldmain.h"
+#include "ldexp.h"
+#include "ldlang.h"
+#include "ldfile.h"
+#include "ldemul.h"
+#include <ldgram.h>
+#include "ldlex.h"
+#include "ldmisc.h"
+#include "ldctor.h"
+#include "coff/internal.h"
+
+/* FIXME: See bfd/peXXigen.c for why we include an architecture specific
+ header in generic PE code. */
+#include "coff/i386.h"
+#include "coff/pe.h"
+
+/* FIXME: This is a BFD internal header file, and we should not be
+ using it here. */
+#include "../bfd/libcoff.h"
+
+#include "deffile.h"
+#include "pe-dll.h"
+#include "safe-ctype.h"
+
+static struct internal_extra_pe_aouthdr pe;
+
+static void
+gld_${EMULATION_NAME}_before_parse (void)
+{
+ ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
+ config.dynamic_link = FALSE;
+ config.has_shared = FALSE;
+}
+
+
+#define OPTION_STACK (300 + 1)
+
+static void
+gld_${EMULATION_NAME}_add_options
+ (int ns ATTRIBUTE_UNUSED,
+ char **shortopts ATTRIBUTE_UNUSED,
+ int nl,
+ struct option **longopts,
+ int nrl ATTRIBUTE_UNUSED,
+ struct option **really_longopts ATTRIBUTE_UNUSED)
+{
+ static const struct option xtra_long[] = {
+ /* KOS32 options */
+ {"stack", required_argument, NULL, OPTION_STACK},
+ {NULL, no_argument, NULL, 0}
+ };
+
+ *longopts
+ = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
+ memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
+}
+
+typedef struct
+{
+ void *ptr;
+ int size;
+ int value;
+ char *symbol;
+ int inited;
+} definfo;
+
+#define D(field,symbol,def) {&pe.field,sizeof(pe.field), def, symbol,0}
+
+
+static definfo init[] =
+{
+ D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x200000),
+ { NULL, 0, 0, NULL, 0 }
+};
+
+static void
+gld_${EMULATION_NAME}_list_options (FILE *file)
+{
+ fprintf (file, _(" --stack <size> Set size of the stack\n"));
+}
+
+static void
+set_pe_name (char *name, long val)
+{
+ int i;
+
+ /* Find the name and set it. */
+ for (i = 0; init[i].ptr; i++)
+ {
+ if (strcmp (name, init[i].symbol) == 0)
+ {
+ init[i].value = val;
+ init[i].inited = 1;
+ return;
+ }
+ }
+ abort ();
+}
+
+static void
+set_pe_value (char *name)
+{
+ char *end;
+
+ set_pe_name (name, strtoul (optarg, &end, 0));
+
+ if (end == optarg)
+ einfo (_("%P%F: invalid hex number for KOS32 parameter '%s'\n"), optarg);
+
+ optarg = end;
+}
+
+static void
+gld_${EMULATION_NAME}_set_symbols (void)
+{
+ /* Run through and invent symbols for all the
+ names and insert the defaults. */
+ int j;
+
+ /* Glue the assignments into the abs section */
+ push_stat_ptr (&abs_output_section->children);
+
+ for (j = 0; init[j].ptr; j++)
+ {
+ long val = init[j].value;
+ lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
+ if (init[j].size == sizeof(short))
+ *(short *)init[j].ptr = val;
+ else if (init[j].size == sizeof(int))
+ *(int *)init[j].ptr = val;
+ else if (init[j].size == sizeof(long))
+ *(long *)init[j].ptr = val;
+ /* This might be a long long or other special type. */
+ else if (init[j].size == sizeof(bfd_vma))
+ *(bfd_vma *)init[j].ptr = val;
+ else abort();
+ }
+ /* Restore the pointer. */
+ pop_stat_ptr ();
+}
+
+static bfd_boolean
+gld_${EMULATION_NAME}_handle_option (int optc)
+{
+ switch (optc)
+ {
+ default:
+ return FALSE;
+
+ /* PE options. */
+ case OPTION_STACK:
+ set_pe_value ("__size_of_stack_reserve__");
+ break;
+ }
+ return TRUE;
+}
+
+static char *
+gld_${EMULATION_NAME}_get_script (int *isfile)
+EOF
+# Scripts compiled in.
+# sed commands to quote an ld script as a C string.
+sc="-f stringify.sed"
+
+fragment <<EOF
+{
+ *isfile = 0;
+
+ if (link_info.relocatable && config.build_constructors)
+ return
+EOF
+sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
+echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
+echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
+echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
+if test -n "$GENERATE_AUTO_IMPORT_SCRIPT" ; then
+echo ' ; else if (link_info.pei386_auto_import == 1) return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.xa >> e${EMULATION_NAME}.c
+fi
+echo ' ; else return' >> e${EMULATION_NAME}.c
+sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
+echo '; }' >> e${EMULATION_NAME}.c
+
+fragment <<EOF
+
+
+struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
+{
+ gld_${EMULATION_NAME}_before_parse,
+ syslib_default,
+ hll_default,
+ after_parse_default,
+ after_open_default,
+ after_allocation_default,
+ set_output_arch_default,
+ ldemul_default_target,
+ before_allocation_default,
+ gld_${EMULATION_NAME}_get_script,
+ "${EMULATION_NAME}",
+ "${OUTPUT_FORMAT}",
+ finish_default,
+ NULL, /* Create output section statements. */
+ NULL, /* open dynamic archive */
+ NULL,
+ gld_${EMULATION_NAME}_set_symbols,
+ NULL, /* parse_args */
+ gld_${EMULATION_NAME}_add_options,
+ gld_${EMULATION_NAME}_handle_option,
+ NULL,
+ gld_${EMULATION_NAME}_list_options,
+ NULL,
+ NULL, /* find_potential_libraries */
+ NULL /* new_vers_pattern. */
+};
+EOF
diff -u -r -N /d/ftp/binutils-2.20/ld/scripttempl/kos32.sc binutils-2.20/ld/scripttempl/kos32.sc
--- /d/ftp/binutils-2.20/ld/scripttempl/kos32.sc 1970-01-01 00:00:00 +0000
+++ binutils-2.20/ld/scripttempl/kos32.sc 2011-08-08 05:44:09 +0000
@@ -0,0 +1,117 @@
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+OUTPUT_ARCH("${OUTPUT_ARCH}")
+ENTRY(__start)
+SECTIONS
+{
+ .text 0x000000:
+ {
+ LONG(0x554e454D);
+ LONG(0x32305445);
+ LONG(1);
+ LONG(__start);
+ LONG(___iend);
+ LONG(___memsize);
+ LONG(___stacktop);
+ LONG(___cmdline);
+ LONG(___pgmname); /* full path */
+ LONG(0); /*FIXME tls data */
+
+ *(.init)
+ *(.text)
+ *(SORT(.text$*))
+ *(.text.*)
+ *(.glue_7t)
+ *(.glue_7)
+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
+ LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0);
+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
+ LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0);
+ *(.fini)
+ /* ??? Why is .gcc_exc here? */
+ *(.gcc_exc)
+ PROVIDE (etext = .);
+ *(.gcc_except_table)
+ }
+
+ .rdata ALIGN(16) :
+ {
+ *(.rdata)
+ *(SORT(.rdata$*))
+ ___RUNTIME_PSEUDO_RELOC_LIST__ = .;
+ __RUNTIME_PSEUDO_RELOC_LIST__ = .;
+ *(.rdata_runtime_pseudo_reloc)
+ ___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
+ __RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
+ }
+ .CRT ALIGN(16) :
+ {
+ ___crt_xc_start__ = . ;
+ *(SORT(.CRT$XC*)) /* C initialization */
+ ___crt_xc_end__ = . ;
+ ___crt_xi_start__ = . ;
+ *(SORT(.CRT$XI*)) /* C++ initialization */
+ ___crt_xi_end__ = . ;
+ ___crt_xl_start__ = . ;
+ *(SORT(.CRT$XL*)) /* TLS callbacks */
+ /* ___crt_xl_end__ is defined in the TLS Directory support code */
+ ___crt_xp_start__ = . ;
+ *(SORT(.CRT$XP*)) /* Pre-termination */
+ ___crt_xp_end__ = . ;
+ ___crt_xt_start__ = . ;
+ *(SORT(.CRT$XT*)) /* Termination */
+ ___crt_xt_end__ = . ;
+ }
+
+ .data ALIGN(16) :
+ {
+ __data_start__ = . ;
+ *(.data)
+ *(.data2)
+ *(SORT(.data$*))
+ *(.jcr)
+ __CRT_MT = .;
+ LONG(0);
+ __data_end__ = . ;
+ *(.data_cygwin_nocopy)
+ }
+
+ .eh_frame ALIGN(16) :
+ {
+ *(.eh_frame)
+ ___iend = . ;
+ }
+
+ bss ALIGN(16):
+ {
+ *(.bss)
+ *(COMMON)
+ . = ALIGN(16);
+ ___cmdline = .;
+ . = . + 256;
+ ___pgmname = .;
+ . = . + 1024 + 16;
+ ___stacktop = .;
+ ___memsize = . ;
+ }
+
+ /DISCARD/ :
+ {
+ *(.debug$S)
+ *(.debug$T)
+ *(.debug$F)
+ *(.drectve)
+ *(.note.GNU-stack)
+ *(.comment)
+ *(.debug_abbrev)
+ *(.debug_info)
+ *(.debug_line)
+ *(.debug_frame)
+ *(.debug_loc)
+ *(.debug_pubnames)
+ *(.debug_aranges)
+ *(.debug_ranges)
+ }
+
+}
+EOF