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

958 lines
31 KiB
Diff
Raw Normal View History

diff -r -u -N binutils-2.24/bfd/config.bfd kos32-binutils-2.24/bfd/config.bfd
--- binutils-2.24/bfd/config.bfd 2013-11-04 19:33:37 +0400
+++ kos32-binutils-2.24/bfd/config.bfd 2014-04-17 23:24:16 +0400
@@ -6,12 +6,12 @@
# 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; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
@@ -730,6 +730,11 @@
targ_selvecs="i386pe_vec i386pei_vec bfd_elf32_i386_vec"
targ_underscore=yes
;;
+ 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-none-*)
targ_defvec=i386coff_vec
;;
@@ -1640,12 +1645,12 @@
w65-*-*)
targ_defvec=w65_vec
;;
-
+
xgate-*-*)
targ_defvec=bfd_elf32_xgate_vec
targ_selvecs="bfd_elf32_xgate_vec"
;;
-
+
xstormy16-*-elf)
targ_defvec=bfd_elf32_xstormy16_vec
;;
diff -r -u -N binutils-2.24/bfd/configure kos32-binutils-2.24/bfd/configure
--- binutils-2.24/bfd/configure 2013-12-02 13:30:30 +0400
+++ kos32-binutils-2.24/bfd/configure 2014-04-18 00:30:37 +0400
@@ -15453,6 +15453,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.24/bfd/configure.in kos32-binutils-2.24/bfd/configure.in
--- binutils-2.24/bfd/configure.in 2013-12-02 13:30:28 +0400
+++ kos32-binutils-2.24/bfd/configure.in 2014-04-18 00:32:16 +0400
@@ -6,12 +6,12 @@
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
-dnl
+dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
-dnl
+dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING3. If not see
dnl <http://www.gnu.org/licenses/>.
@@ -868,7 +868,7 @@
bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
- bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
bfd_elf64_littleaarch64_vec)tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf32_littleaarch64_vec)tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
@@ -942,6 +942,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.24/bfd/kos32.c kos32-binutils-2.24/bfd/kos32.c
--- binutils-2.24/bfd/kos32.c 1970-01-01 04:00:00 +0400
+++ kos32-binutils-2.24/bfd/kos32.c 2014-04-18 01:09:22 +0400
@@ -0,0 +1,224 @@
+/* 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
+
+#define kos32_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type
+#define kos32_bfd_lookup_section_flags bfd_generic_lookup_section_flags
+
+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_HAS_CONTENTS |
+ SEC_CODE | SEC_DATA | SEC_ALLOC | SEC_LOAD), /* section flags */
+ 0, /* leading underscore */
+ ' ', /* ar_pad_char */
+ 15, /* 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_archive_coff),
+ 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.24/bfd/targets.c kos32-binutils-2.24/bfd/targets.c
--- binutils-2.24/bfd/targets.c 2013-11-04 19:33:37 +0400
+++ kos32-binutils-2.24/bfd/targets.c 2014-04-18 00:47:36 +0400
@@ -813,6 +813,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.24/config.sub kos32-binutils-2.24/config.sub
--- binutils-2.24/config.sub 2013-11-26 15:37:33 +0400
+++ kos32-binutils-2.24/config.sub 2014-04-17 23:31:31 +0400
@@ -1376,7 +1376,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.24/gas/configure.tgt kos32-binutils-2.24/gas/configure.tgt
--- binutils-2.24/gas/configure.tgt 2013-11-04 19:33:37 +0400
+++ kos32-binutils-2.24/gas/configure.tgt 2014-04-17 23:29:11 +0400
@@ -6,12 +6,12 @@
# 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; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
@@ -265,6 +265,7 @@
x86_64*) fmt=coff em=pep ;;
i*) fmt=coff em=pe ;;
esac ;;
+ i386-*-kos32*) fmt=coff em=pe ;;
i386-*-nto-qnx*) fmt=elf ;;
i386-*-*nt*) fmt=coff em=pe ;;
i386-*-chaos) fmt=elf ;;
@@ -445,7 +446,7 @@
vax-*-linux-*) fmt=elf em=linux ;;
xstormy16-*-*) fmt=elf ;;
-
+
xgate-*-*) fmt=elf ;;
xtensa*-*-*) fmt=elf ;;
diff -r -u -N binutils-2.24/ld/Makefile.in kos32-binutils-2.24/ld/Makefile.in
--- binutils-2.24/ld/Makefile.in 2013-11-26 15:37:33 +0400
+++ kos32-binutils-2.24/ld/Makefile.in 2014-04-18 02:44:03 +0400
@@ -611,6 +611,7 @@
ei386bsd.c \
ei386coff.c \
ei386go32.c \
+ ekos32.c \
ei386linux.c \
ei386lynx.c \
ei386mach.c \
@@ -2922,6 +2923,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.24/ld/configure.tgt kos32-binutils-2.24/ld/configure.tgt
--- binutils-2.24/ld/configure.tgt 2013-11-26 15:37:33 +0400
+++ kos32-binutils-2.24/ld/configure.tgt 2014-04-18 08:54:18 +0400
@@ -6,12 +6,12 @@
# 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; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
@@ -317,6 +317,9 @@
test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api' ;;
i[3-7]86-*-mingw32*) targ_emul=i386pe ;
targ_extra_ofiles="deffilep.o pe-dll.o" ;;
+i[3-7]86-*-kos32*) targ_emul=i386pe ;
+ targ_extra_emuls=kos32 ;
+ targ_extra_ofiles="deffilep.o pe-dll.o" ;;
x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
targ_extra_emuls=i386pe ;
targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" ;;
@@ -752,7 +755,7 @@
;;
xtensa*-*-*) targ_emul=elf32xtensa
;;
-xgate-*-*) targ_emul=xgateelf
+xgate-*-*) targ_emul=xgateelf
;;
z80-*-coff) targ_emul=z80
;;
@@ -783,6 +786,9 @@
hppa*64*-*-hpux11*)
NATIVE_LIB_DIRS=/usr/lib/pa20_64
;;
+i[3-7]86-*-kos32*)
+ NATIVE_LIB_DIRS='/home/kos32/lib'
+ ;;
i[3-7]86-*-sysv4*)
NATIVE_LIB_DIRS='/usr/local/lib /usr/ccs/lib /lib /usr/lib'
diff -r -u -N binutils-2.24/ld/emulparams/kos32.sh kos32-binutils-2.24/ld/emulparams/kos32.sh
--- binutils-2.24/ld/emulparams/kos32.sh 1970-01-01 04:00:00 +0400
+++ kos32-binutils-2.24/ld/emulparams/kos32.sh 2014-04-17 23:49:45 +0400
@@ -0,0 +1,9 @@
+ARCH=i386
+SCRIPT_NAME=kos32
+OUTPUT_FORMAT="kos32"
+TARGET_PAGE_SIZE=0x1000
+TEMPLATE_NAME=kos32
+TEXT_START_ADDR=0
+ENTRY="__start"
+INITIAL_SYMBOL_CHAR=\"_\"
+NOP=0x90909090
diff -r -u -N binutils-2.24/ld/emultempl/kos32.em kos32-binutils-2.24/ld/emultempl/kos32.em
--- binutils-2.24/ld/emultempl/kos32.em 1970-01-01 04:00:00 +0400
+++ kos32-binutils-2.24/ld/emultempl/kos32.em 2014-04-18 02:24:20 +0400
@@ -0,0 +1,281 @@
+# 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 "filenames.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 int is_underscoring (void)
+{
+ int u = 0;
+ if (pe_leading_underscore != -1)
+ return pe_leading_underscore;
+ if (!bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL))
+ bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL);
+
+ if (u == -1)
+ abort ();
+ pe_leading_underscore = (u != 0 ? 1 : 0);
+ return pe_leading_underscore;
+}
+
+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;
+ /* FALSE for an assembly level symbol and TRUE for a C visible symbol.
+ C visible symbols can be prefixed by underscore dependent to target's
+ settings. */
+ bfd_boolean is_c_symbol;
+} definfo;
+
+/* Get symbol name dependent to kind and C visible state of
+ underscore. */
+#define GET_INIT_SYMBOL_NAME(IDX) \
+ (init[(IDX)].symbol \
+ + ((init[(IDX)].is_c_symbol == FALSE || (is_underscoring () != 0)) ? 0 : 1))
+#define D(field,symbol,def,usc) {&pe.field,sizeof(pe.field), def, symbol, 0, usc}
+
+static definfo init[] =
+{
+ D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x200000, FALSE),
+ { NULL, 0, 0, NULL, 0, FALSE }
+};
+
+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 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 void
+gld_${EMULATION_NAME}_set_symbols (void)
+{
+ /* Run through and invent symbols for all the
+ names and insert the defaults. */
+ int j;
+
+ is_underscoring ();
+
+ /* 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_assignment_statement_type *rv;
+
+ lang_add_assignment (exp_assign (GET_INIT_SYMBOL_NAME (j),
+ 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 int
+gld_${EMULATION_NAME}_find_potential_libraries
+ (char *name, lang_input_statement_type *entry)
+{
+ return ldfile_open_file_search (name, entry, "", ".a");
+}
+
+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,
+ gld_${EMULATION_NAME}_find_potential_libraries,
+ NULL /* new_vers_pattern. */
+};
+EOF
diff -r -u -N binutils-2.24/ld/emultempl/pe.em kos32-binutils-2.24/ld/emultempl/pe.em
--- binutils-2.24/ld/emultempl/pe.em 2013-11-26 15:37:33 +0400
+++ kos32-binutils-2.24/ld/emultempl/pe.em 2014-04-18 09:35:18 +0400
@@ -110,7 +110,7 @@
#undef NT_EXE_IMAGE_BASE
#undef PE_DEF_SECTION_ALIGNMENT
#undef PE_DEF_FILE_ALIGNMENT
-#define NT_EXE_IMAGE_BASE 0x00010000
+#define NT_EXE_IMAGE_BASE 0x00000000
#if defined(TARGET_IS_armpe) || defined(TARGET_IS_arm_wince_pe)
#define PE_DEF_SECTION_ALIGNMENT 0x00001000
@@ -522,46 +522,16 @@
{
const char *entry;
const char *initial_symbol_char;
- int i;
-
- static const struct
- {
- const int value;
- const char *entry;
- }
- v[] =
- {
- { 1, "NtProcessStartup" },
- { 2, "WinMainCRTStartup" },
- { 3, "mainCRTStartup" },
- { 7, "__PosixProcessStartup"},
- { 9, "WinMainCRTStartup" },
- {14, "mainCRTStartup" },
- { 0, NULL }
- };
/* Entry point name for arbitrary subsystem numbers. */
- static const char default_entry[] = "mainCRTStartup";
+ static const char default_entry[] = "__start";
if (link_info.shared || dll)
{
-#if defined (TARGET_IS_i386pe)
- entry = "DllMainCRTStartup@12";
-#else
- entry = "DllMainCRTStartup";
-#endif
+ entry = "DllStartup";
}
else
{
-
- for (i = 0; v[i].entry; i++)
- if (v[i].value == pe_subsystem)
- break;
-
- /* If no match, use the default. */
- if (v[i].entry != NULL)
- entry = v[i].entry;
- else
entry = default_entry;
}
@@ -2087,7 +2057,7 @@
libfoo.dll and foo.dll in the search. */
{ "lib%s.a", FALSE },
/* The 'native' spelling of an import lib name is "foo.lib". */
- { "%s.lib", FALSE },
+ { "%s.a", FALSE },
#ifdef DLL_SUPPORT
/* Try "<prefix>foo.dll" (preferred dll name, if specified). */
{ "%s%s.dll", TRUE },
@@ -2173,7 +2143,7 @@
gld_${EMULATION_NAME}_find_potential_libraries
(char *name, lang_input_statement_type *entry)
{
- return ldfile_open_file_search (name, entry, "", ".lib");
+ return ldfile_open_file_search (name, entry, "", ".a");
}
static char *
diff -r -u -N binutils-2.24/ld/scripttempl/kos32.sc kos32-binutils-2.24/ld/scripttempl/kos32.sc
--- binutils-2.24/ld/scripttempl/kos32.sc 1970-01-01 04:00:00 +0400
+++ kos32-binutils-2.24/ld/scripttempl/kos32.sc 2014-04-18 00:38:18 +0400
@@ -0,0 +1,131 @@
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+OUTPUT_ARCH("${OUTPUT_ARCH}")
+${LIB_SEARCH_DIRS}
+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 */
+ LONG(__idata_start)
+ LONG(__idata_end)
+ LONG(_main)
+
+ *(.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(64) :
+ {
+ PROVIDE ( __data_start__ = .) ;
+ *(.data)
+ *(.data2)
+ *(SORT(.data$*))
+ *(.jcr)
+ __CRT_MT = .;
+ LONG(0);
+ PROVIDE ( __data_end__ = .) ;
+ *(.data_cygwin_nocopy)
+ ___iend = . ;
+ }
+
+ .idata ALIGN(16):
+ {
+ __idata_start = .;
+ SORT(*)(.idata$2)
+ SORT(*)(.idata$3)
+ /* These zeroes mark the end of the import list. */
+ LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
+ SORT(*)(.idata$4)
+ SORT(*)(.idata$5)
+ SORT(*)(.idata$6)
+ SORT(*)(.idata$7)
+ __idata_end = . ;
+ }
+
+ 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)
+ *(.eh_frame)
+ *(.comment)
+ *(.debug_abbrev)
+ *(.debug_info)
+ *(.debug_line)
+ *(.debug_frame)
+ *(.debug_loc)
+ *(.debug_pubnames)
+ *(.debug_aranges)
+ *(.debug_ranges)
+ }
+
+}
+EOF