mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-25 18:29:36 +03:00
dd4a76e872
git-svn-id: svn://kolibrios.org@3196 a494cfbc-eb01-0410-851d-a64ba20cac60
713 lines
23 KiB
Diff
713 lines
23 KiB
Diff
diff -r -u -N binutils-2.23.1/bfd/config.bfd kos32-binutils-2.23.1/bfd/config.bfd
|
|
--- binutils-2.23.1/bfd/config.bfd 2012-09-04 18:14:59.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/bfd/config.bfd 2013-01-23 15:58:39.000000000 +0400
|
|
@@ -512,6 +512,11 @@
|
|
targ_defvec=bfd_elf32_i386_vec
|
|
targ_selvecs=bfd_elf32_i386_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
|
|
+ ;;
|
|
i[3-7]86-*-nto*)
|
|
targ_defvec=bfd_elf32_i386_vec
|
|
targ_selvecs=i386coff_vec
|
|
diff -r -u -N binutils-2.23.1/bfd/configure kos32-binutils-2.23.1/bfd/configure
|
|
--- binutils-2.23.1/bfd/configure 2012-11-13 18:17:40.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/bfd/configure 2013-01-23 16:00:34.000000000 +0400
|
|
@@ -15421,6 +15421,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 -r -u -N binutils-2.23.1/bfd/configure.in kos32-binutils-2.23.1/bfd/configure.in
|
|
--- binutils-2.23.1/bfd/configure.in 2012-11-13 18:17:38.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/bfd/configure.in 2013-01-23 16:02:35.000000000 +0400
|
|
@@ -913,6 +913,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 -r -u -N binutils-2.23.1/bfd/kos32.c kos32-binutils-2.23.1/bfd/kos32.c
|
|
--- binutils-2.23.1/bfd/kos32.c 1970-01-01 03:00:00.000000000 +0300
|
|
+++ kos32-binutils-2.23.1/bfd/kos32.c 2013-01-23 16:29:39.000000000 +0400
|
|
@@ -0,0 +1,222 @@
|
|
+/* 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_lookup_section_flags bfd_generic_lookup_section_flags
|
|
+#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_copy_link_hash_symbol_type \
|
|
+ _bfd_generic_copy_link_hash_symbol_type
|
|
+#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 */
|
|
+ 0, /* match priority */
|
|
+ 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 -r -u -N binutils-2.23.1/bfd/targets.c kos32-binutils-2.23.1/bfd/targets.c
|
|
--- binutils-2.23.1/bfd/targets.c 2012-09-04 16:53:42.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/bfd/targets.c 2013-01-23 16:06:37.000000000 +0400
|
|
@@ -806,6 +806,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;
|
|
diff -r -u -N binutils-2.23.1/config.sub kos32-binutils-2.23.1/config.sub
|
|
--- binutils-2.23.1/config.sub 2012-04-25 19:53:25.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/config.sub 2013-01-23 16:07:13.000000000 +0400
|
|
@@ -1368,7 +1368,7 @@
|
|
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
|
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
|
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
|
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
|
|
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es | -kos32*)
|
|
# Remember, each alternative MUST END IN *, to match a version number.
|
|
;;
|
|
-qnx*)
|
|
diff -r -u -N binutils-2.23.1/gas/configure.tgt kos32-binutils-2.23.1/gas/configure.tgt
|
|
--- binutils-2.23.1/gas/configure.tgt 2012-09-04 16:53:45.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/gas/configure.tgt 2013-01-23 16:08:33.000000000 +0400
|
|
@@ -238,6 +238,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 -r -u -N binutils-2.23.1/ld/configure.tgt kos32-binutils-2.23.1/ld/configure.tgt
|
|
--- binutils-2.23.1/ld/configure.tgt 2012-09-04 16:53:47.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/ld/configure.tgt 2013-01-23 16:12:11.000000000 +0400
|
|
@@ -299,6 +299,7 @@
|
|
x86_64-*-mingw*) targ_emul=i386pep ;
|
|
targ_extra_emuls=i386pe
|
|
targ_extra_ofiles="deffilep.o pep-dll.o pe-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 ;;
|
|
diff -r -u -N binutils-2.23.1/ld/emulparams/kos32.sh kos32-binutils-2.23.1/ld/emulparams/kos32.sh
|
|
--- binutils-2.23.1/ld/emulparams/kos32.sh 1970-01-01 03:00:00.000000000 +0300
|
|
+++ kos32-binutils-2.23.1/ld/emulparams/kos32.sh 2013-01-23 16:13:36.000000000 +0400
|
|
@@ -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 -r -u -N binutils-2.23.1/ld/emultempl/kos32.em kos32-binutils-2.23.1/ld/emultempl/kos32.em
|
|
--- binutils-2.23.1/ld/emultempl/kos32.em 1970-01-01 03:00:00.000000000 +0300
|
|
+++ kos32-binutils-2.23.1/ld/emultempl/kos32.em 2013-01-23 16:57:01.000000000 +0400
|
|
@@ -0,0 +1,246 @@
|
|
+# 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.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_assign (init[j].symbol, exp_intop (val), FALSE));
|
|
+ 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 -r -u -N binutils-2.23.1/ld/Makefile.in kos32-binutils-2.23.1/ld/Makefile.in
|
|
--- binutils-2.23.1/ld/Makefile.in 2012-09-04 16:53:47.000000000 +0400
|
|
+++ kos32-binutils-2.23.1/ld/Makefile.in 2013-01-23 16:11:11.000000000 +0400
|
|
@@ -619,6 +619,7 @@
|
|
ei386pe.c \
|
|
ei386pe_posix.c \
|
|
ei386pep.c \
|
|
+ ekos32.c \
|
|
elnk960.c \
|
|
em32relf.c \
|
|
em32relf_linux.c \
|
|
@@ -2853,6 +2854,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 -r -u -N binutils-2.23.1/ld/scripttempl/kos32.sc kos32-binutils-2.23.1/ld/scripttempl/kos32.sc
|
|
--- binutils-2.23.1/ld/scripttempl/kos32.sc 1970-01-01 03:00:00.000000000 +0300
|
|
+++ kos32-binutils-2.23.1/ld/scripttempl/kos32.sc 2013-01-23 17:47:19.000000000 +0400
|
|
@@ -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
|