Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. diff -u -r -N /d/ftp/binutils-2.20/bfd/config.bfd binutils-2.20/bfd/config.bfd
  2. --- /d/ftp/binutils-2.20/bfd/config.bfd 2009-08-06 17:38:00 +0000
  3. +++ binutils-2.20/bfd/config.bfd        2011-08-07 21:03:49 +0000
  4. @@ -703,6 +703,12 @@
  5.      targ_selfvecs=i386chaos_vec
  6.      ;;
  7.  
  8. +  i[3-7]86-*-kos32*)
  9. +    targ_defvec=i386aout_vec
  10. +    targ_selvecs="kos32_vec i386pe_vec i386pei_vec bfd_elf32_i386_vec"
  11. +    targ_underscore=yes
  12. +    ;;
  13. +
  14.    i860-*-mach3* | i860-*-osf1* | i860-*-coff*)
  15.      targ_defvec=i860coff_vec
  16.      ;;
  17. @@ -746,12 +752,12 @@
  18.      targ_defvec=bfd_elf32_lm32_vec
  19.      targ_selvecs=bfd_elf32_lm32fdpic_vec
  20.      ;;
  21. -    
  22. +
  23.    lm32-*-*linux*)
  24.      targ_defvec=bfd_elf32_lm32fdpic_vec
  25.      targ_selvecs=bfd_elf32_lm32_vec
  26.      ;;
  27. -    
  28. +
  29.    m32c-*-elf | m32c-*-rtems*)
  30.      targ_defvec=bfd_elf32_m32c_vec
  31.      ;;
  32. @@ -963,11 +969,11 @@
  33.      want64=true
  34.      ;;
  35.  #endif
  36. -  mips*el-sde-elf*)    
  37. +  mips*el-sde-elf*)
  38.      targ_defvec=bfd_elf32_tradlittlemips_vec
  39.      targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
  40.      want64=true
  41. -    ;;  
  42. +    ;;
  43.    mips*-sde-elf*)
  44.      targ_defvec=bfd_elf32_tradbigmips_vec
  45.      targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
  46. diff -u -r -N /d/ftp/binutils-2.20/bfd/configure binutils-2.20/bfd/configure
  47. --- /d/ftp/binutils-2.20/bfd/configure  2009-10-16 11:47:48 +0000
  48. +++ binutils-2.20/bfd/configure 2011-08-08 07:12:50 +0000
  49. @@ -14970,6 +14970,7 @@
  50.      icoff_big_vec)             tb="$tb coff-i960.lo cofflink.lo" ;;
  51.      icoff_little_vec)          tb="$tb coff-i960.lo cofflink.lo" ;;
  52.      ieee_vec)                  tb="$tb ieee.lo" ;;
  53. +    kos32_vec)                  tb="$tb kos32.lo" ;;
  54.      m68k4knetbsd_vec)          tb="$tb m68k4knetbsd.lo aout32.lo" ;;
  55.      m68kaux_coff_vec)          tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
  56.      m68kcoff_vec)              tb="$tb coff-m68k.lo cofflink.lo" ;;
  57. diff -u -r -N /d/ftp/binutils-2.20/bfd/configure.in binutils-2.20/bfd/configure.in
  58. --- /d/ftp/binutils-2.20/bfd/configure.in       2009-10-16 11:47:44 +0000
  59. +++ binutils-2.20/bfd/configure.in      2011-08-08 07:13:10 +0000
  60. @@ -858,6 +858,7 @@
  61.      icoff_big_vec)             tb="$tb coff-i960.lo cofflink.lo" ;;
  62.      icoff_little_vec)          tb="$tb coff-i960.lo cofflink.lo" ;;
  63.      ieee_vec)                  tb="$tb ieee.lo" ;;
  64. +    kos32_vec)                 tb="$tb kos32.lo" ;;
  65.      m68k4knetbsd_vec)          tb="$tb m68k4knetbsd.lo aout32.lo" ;;
  66.      m68kaux_coff_vec)          tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
  67.      m68kcoff_vec)              tb="$tb coff-m68k.lo cofflink.lo" ;;
  68. diff -u -r -N /d/ftp/binutils-2.20/bfd/kos32.c binutils-2.20/bfd/kos32.c
  69. --- /d/ftp/binutils-2.20/bfd/kos32.c    1970-01-01 00:00:00 +0000
  70. +++ binutils-2.20/bfd/kos32.c   2011-08-08 05:50:52 +0000
  71. @@ -0,0 +1,220 @@
  72. +/* BFD back-end for MS-DOS executables.
  73. +   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002,
  74. +   2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
  75. +   Written by Bryan Ford of the University of Utah.
  76. +
  77. +   Contributed by the Center for Software Science at the
  78. +   University of Utah (pa-gdb-bugs@cs.utah.edu).
  79. +
  80. +   This file is part of BFD, the Binary File Descriptor library.
  81. +
  82. +   This program is free software; you can redistribute it and/or modify
  83. +   it under the terms of the GNU General Public License as published by
  84. +   the Free Software Foundation; either version 3 of the License, or
  85. +   (at your option) any later version.
  86. +
  87. +   This program is distributed in the hope that it will be useful,
  88. +   but WITHOUT ANY WARRANTY; without even the implied warranty of
  89. +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  90. +   GNU General Public License for more details.
  91. +
  92. +   You should have received a copy of the GNU General Public License
  93. +   along with this program; if not, write to the Free Software
  94. +   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  95. +   MA 02110-1301, USA.  */
  96. +
  97. +
  98. +#include "sysdep.h"
  99. +#include "bfd.h"
  100. +#include "libbfd.h"
  101. +#include "libaout.h"
  102. +
  103. +#define KOS_MAGIC_0       0x554e454D
  104. +#define KOS_MAGIC_1       0x31305445
  105. +#define KOS_MAGIC_2       0x32305445
  106. +
  107. +
  108. +static int
  109. +kos32_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
  110. +                     struct bfd_link_info *info ATTRIBUTE_UNUSED)
  111. +{
  112. +  return 0;
  113. +}
  114. +
  115. +static bfd_boolean
  116. +kos32_write_object_contents (bfd *abfd)
  117. +{
  118. +  static char hdr[12];
  119. +  file_ptr outfile_size = sizeof(hdr);
  120. +  bfd_vma high_vma = 0;
  121. +  asection *sec;
  122. +
  123. +  /* Find the total size of the program on disk and in memory.  */
  124. +  for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
  125. +    {
  126. +      if (sec->size == 0)
  127. +        continue;
  128. +      if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
  129. +        {
  130. +         bfd_vma sec_vma = bfd_get_section_vma (abfd, sec) + sec->size;
  131. +         if (sec_vma > high_vma)
  132. +           high_vma = sec_vma;
  133. +       }
  134. +      if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
  135. +        {
  136. +         file_ptr sec_end = (sizeof (hdr)
  137. +                             + bfd_get_section_vma (abfd, sec)
  138. +                             + sec->size);
  139. +         if (sec_end > outfile_size)
  140. +           outfile_size = sec_end;
  141. +       }
  142. +    }
  143. +
  144. +  /* Make sure the program isn't too big.  */
  145. +//  if (high_vma > (bfd_vma)0xffff)
  146. +//    {
  147. +//      bfd_set_error(bfd_error_file_too_big);
  148. +//      return FALSE;
  149. +//    }
  150. +
  151. +  /* Constants.  */
  152. +  H_PUT_32 (abfd, KOS_MAGIC_0, &hdr[0]);
  153. +  H_PUT_32 (abfd, KOS_MAGIC_2, &hdr[4]);
  154. +  H_PUT_32 (abfd, 1, &hdr[8]);
  155. +
  156. +//  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
  157. +//      || bfd_bwrite (hdr, (bfd_size_type) sizeof(hdr), abfd) != sizeof(hdr))
  158. +//    return FALSE;
  159. +
  160. +  return TRUE;
  161. +}
  162. +
  163. +static bfd_boolean
  164. +kos32_set_section_contents (bfd *abfd,
  165. +                           sec_ptr section,
  166. +                           const void *location,
  167. +                           file_ptr offset,
  168. +                           bfd_size_type count)
  169. +{
  170. +
  171. +  if (count == 0)
  172. +    return TRUE;
  173. +
  174. +  section->filepos = bfd_get_section_vma (abfd, section);
  175. +
  176. +  if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
  177. +    {
  178. +      if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
  179. +          || bfd_bwrite (location, count, abfd) != count)
  180. +        return FALSE;
  181. +    }
  182. +
  183. +  return TRUE;
  184. +}
  185. +
  186. +static bfd_boolean
  187. +kos32_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
  188. +{
  189. +  return TRUE;
  190. +}
  191. +
  192. +
  193. +#define kos32_make_empty_symbol _bfd_generic_make_empty_symbol
  194. +#define kos32_bfd_reloc_type_lookup aout_32_reloc_type_lookup
  195. +#define kos32_bfd_reloc_name_lookup aout_32_reloc_name_lookup
  196. +
  197. +#define kos32_close_and_cleanup _bfd_generic_close_and_cleanup
  198. +#define kos32_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
  199. +#define kos32_new_section_hook _bfd_generic_new_section_hook
  200. +#define kos32_get_section_contents _bfd_generic_get_section_contents
  201. +#define kos32_get_section_contents_in_window \
  202. +  _bfd_generic_get_section_contents_in_window
  203. +#define kos32_bfd_get_relocated_section_contents \
  204. +  bfd_generic_get_relocated_section_contents
  205. +#define kos32_bfd_relax_section bfd_generic_relax_section
  206. +#define kos32_bfd_gc_sections bfd_generic_gc_sections
  207. +#define kos32_bfd_merge_sections bfd_generic_merge_sections
  208. +#define kos32_bfd_is_group_section bfd_generic_is_group_section
  209. +#define kos32_bfd_discard_group bfd_generic_discard_group
  210. +#define kos32_section_already_linked \
  211. +  _bfd_generic_section_already_linked
  212. +#define kos32_bfd_define_common_symbol bfd_generic_define_common_symbol
  213. +#define kos32_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
  214. +#define kos32_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
  215. +#define kos32_bfd_link_add_symbols _bfd_generic_link_add_symbols
  216. +#define kos32_bfd_link_just_syms _bfd_generic_link_just_syms
  217. +#define kos32_bfd_final_link _bfd_generic_final_link
  218. +#define kos32_bfd_link_split_section _bfd_generic_link_split_section
  219. +#define kos32_set_arch_mach _bfd_generic_set_arch_mach
  220. +
  221. +#define kos32_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
  222. +#define kos32_canonicalize_symtab _bfd_nosymbols_canonicalize_symtab
  223. +#define kos32_print_symbol _bfd_nosymbols_print_symbol
  224. +#define kos32_get_symbol_info _bfd_nosymbols_get_symbol_info
  225. +#define kos32_find_nearest_line _bfd_nosymbols_find_nearest_line
  226. +#define kos32_find_inliner_info _bfd_nosymbols_find_inliner_info
  227. +#define kos32_get_lineno _bfd_nosymbols_get_lineno
  228. +#define kos32_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
  229. +#define kos32_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
  230. +#define kos32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
  231. +#define kos32_read_minisymbols _bfd_nosymbols_read_minisymbols
  232. +#define kos32_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
  233. +
  234. +#define kos32_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
  235. +#define kos32_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
  236. +#define kos32_32_bfd_link_split_section  _bfd_generic_link_split_section
  237. +
  238. +const bfd_target kos32_vec =
  239. +  {
  240. +    "kos32",           /* name */
  241. +    bfd_target_msdos_flavour,
  242. +    BFD_ENDIAN_LITTLE,         /* target byte order */
  243. +    BFD_ENDIAN_LITTLE,         /* target headers byte order */
  244. +    (EXEC_P),                  /* object flags */
  245. +    (SEC_CODE | SEC_DATA | SEC_HAS_CONTENTS
  246. +     | SEC_ALLOC | SEC_LOAD),  /* section flags */
  247. +    0,                         /* leading underscore */
  248. +    ' ',                               /* ar_pad_char */
  249. +    16,                                /* ar_max_namelen */
  250. +    bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  251. +    bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  252. +    bfd_getl16, bfd_getl_signed_16, bfd_putl16,        /* data */
  253. +    bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  254. +    bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  255. +    bfd_getl16, bfd_getl_signed_16, bfd_putl16,        /* hdrs */
  256. +
  257. +    {
  258. +      _bfd_dummy_target,
  259. +      _bfd_dummy_target,               /* bfd_check_format */
  260. +      _bfd_dummy_target,
  261. +      _bfd_dummy_target,
  262. +    },
  263. +    {
  264. +      bfd_false,
  265. +      kos32_mkobject,
  266. +      _bfd_generic_mkarchive,
  267. +      bfd_false,
  268. +    },
  269. +    {                          /* bfd_write_contents */
  270. +      bfd_false,
  271. +      kos32_write_object_contents,
  272. +      _bfd_write_archive_contents,
  273. +      bfd_false,
  274. +    },
  275. +
  276. +    BFD_JUMP_TABLE_GENERIC (kos32),
  277. +    BFD_JUMP_TABLE_COPY (_bfd_generic),
  278. +    BFD_JUMP_TABLE_CORE (_bfd_nocore),
  279. +    BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
  280. +    BFD_JUMP_TABLE_SYMBOLS (kos32),
  281. +    BFD_JUMP_TABLE_RELOCS (kos32),
  282. +    BFD_JUMP_TABLE_WRITE (kos32),
  283. +    BFD_JUMP_TABLE_LINK (kos32),
  284. +    BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
  285. +
  286. +    NULL,
  287. +
  288. +    (PTR) 0
  289. +  };
  290. +
  291. +
  292. diff -u -r -N /d/ftp/binutils-2.20/bfd/targets.c binutils-2.20/bfd/targets.c
  293. --- /d/ftp/binutils-2.20/bfd/targets.c  2009-09-10 11:47:14 +0000
  294. +++ binutils-2.20/bfd/targets.c 2011-08-07 19:50:55 +0000
  295. @@ -737,6 +737,7 @@
  296.  extern const bfd_target icoff_big_vec;
  297.  extern const bfd_target icoff_little_vec;
  298.  extern const bfd_target ieee_vec;
  299. +extern const bfd_target kos32_vec;
  300.  extern const bfd_target m68k4knetbsd_vec;
  301.  extern const bfd_target m68kaux_coff_vec;
  302.  extern const bfd_target m68kcoff_vec;
  303. @@ -1103,6 +1104,7 @@
  304.         &icoff_big_vec,
  305.         &icoff_little_vec,
  306.         &ieee_vec,
  307. +    &kos32_vec,
  308.  #if 0
  309.         &m68k4knetbsd_vec,
  310.         &m68kaux_coff_vec,
  311. diff -u -r -N /d/ftp/binutils-2.20/config.sub binutils-2.20/config.sub
  312. --- /d/ftp/binutils-2.20/config.sub     2009-08-17 04:10:30 +0000
  313. +++ binutils-2.20/config.sub    2011-08-07 16:34:28 +0000
  314. @@ -1293,7 +1293,7 @@
  315.               | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
  316.               | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
  317.               | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
  318. -             | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
  319. +             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -kos32*)
  320.         # Remember, each alternative MUST END IN *, to match a version number.
  321.                 ;;
  322.         -qnx*)
  323. diff -u -r -N /d/ftp/binutils-2.20/gas/configure.tgt binutils-2.20/gas/configure.tgt
  324. --- /d/ftp/binutils-2.20/gas/configure.tgt      2009-09-09 08:13:28 +0000
  325. +++ binutils-2.20/gas/configure.tgt     2011-08-07 16:44:51 +0000
  326. @@ -226,6 +226,7 @@
  327.    i386-*-pe)                           fmt=coff em=pe ;;
  328.    i386-*-cygwin*)                      fmt=coff em=pe ;;
  329.    i386-*-interix*)                     fmt=coff em=interix ;;
  330. +  i386-*-kos32*)                       fmt=coff em=pe ;;
  331.    i386-*-mingw*)
  332.      case ${cpu} in
  333.        x86_64*)                         fmt=coff em=pep ;;
  334. diff -u -r -N /d/ftp/binutils-2.20/ld/Makefile.in binutils-2.20/ld/Makefile.in
  335. --- /d/ftp/binutils-2.20/ld/Makefile.in 2009-09-07 12:10:24 +0000
  336. +++ binutils-2.20/ld/Makefile.in        2011-08-07 19:00:16 +0000
  337. @@ -551,6 +551,7 @@
  338.         ei386pe.o \
  339.         ei386pe_posix.o \
  340.         ei386pep.o \
  341. +       ekos32.o \
  342.         elnk960.o \
  343.         em32relf.o \
  344.         em32rlelf.o \
  345. @@ -2628,6 +2629,9 @@
  346.  ei386pep.c: $(srcdir)/emulparams/i386pep.sh \
  347.    $(srcdir)/emultempl/pep.em $(srcdir)/scripttempl/pep.sc ${GEN_DEPENDS}
  348.         ${GENSCRIPTS} i386pep "$(tdir_i386pe)"
  349. +ekos32.c: $(srcdir)/emulparams/kos32.sh \
  350. +  $(srcdir)/emultempl/kos32.em $(srcdir)/scripttempl/kos32.sc ${GEN_DEPENDS}
  351. +       ${GENSCRIPTS} kos32 "$(tdir_kos32)"
  352.  elnk960.c: $(srcdir)/emulparams/lnk960.sh \
  353.    $(srcdir)/emultempl/lnk960.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS}
  354.         ${GENSCRIPTS} lnk960 "$(tdir_lnk960)"
  355. diff -u -r -N /d/ftp/binutils-2.20/ld/configure.tgt binutils-2.20/ld/configure.tgt
  356. --- /d/ftp/binutils-2.20/ld/configure.tgt       2009-08-06 17:38:04 +0000
  357. +++ binutils-2.20/ld/configure.tgt      2011-08-07 18:57:57 +0000
  358. @@ -155,7 +155,7 @@
  359.  frv-*-*linux*)         targ_emul=elf32frvfd ;;
  360.  frv-*-*)               targ_emul=elf32frv ; targ_extra_emuls="elf32frvfd"
  361.                         ;;
  362. -moxie-*-*)             targ_emul=elf32moxie
  363. +moxie-*-*)             targ_emul=elf32moxie
  364.                         ;;
  365.  h8300-*-hms* | h8300-*-coff* | h8300-*-rtemscoff*)
  366.                         targ_emul=h8300; targ_extra_emuls="h8300h h8300s h8300hn h8300sn h8300sx h8300sxn" ;;
  367. @@ -275,6 +275,7 @@
  368.                         targ_extra_ofiles="deffilep.o pe-dll.o" ;;
  369.  x86_64-*-mingw*)       targ_emul=i386pep ;
  370.                         targ_extra_ofiles="deffilep.o pep-dll.o" ;;
  371. +i[3-7]86-*-kos32*)      targ_emul=kos32 ;;
  372.  i[3-7]86-*-interix*)   targ_emul=i386pe_posix;
  373.                         targ_extra_ofiles="deffilep.o pe-dll.o" ;;
  374.  i[3-7]86-*-beospe*)    targ_emul=i386beos ;;
  375. @@ -307,7 +308,7 @@
  376.  iq2000-*-elf)           targ_emul=elf32iq2000 ; targ_extra_emuls="elf32iq10"
  377.                         ;;
  378.  lm32-*-*linux*)         targ_emul=elf32lm32fd ;;
  379. -lm32-*-*)               targ_emul=elf32lm32 ; targ_extra_emuls="elf32lm32fd"
  380. +lm32-*-*)               targ_emul=elf32lm32 ; targ_extra_emuls="elf32lm32fd"
  381.                          ;;
  382.  m32c-*-elf | m32c-*-rtems*)
  383.                         targ_emul=elf32m32c
  384. @@ -318,9 +319,9 @@
  385.  m32r*le-*-linux-*)      targ_emul=m32rlelf_linux ;;
  386.  m32r*-*-linux-*)        targ_emul=m32relf_linux
  387.                         ;;
  388. -m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
  389. +m68hc11-*-*|m6811-*-*) targ_emul=m68hc11elf
  390.                         targ_extra_emuls="m68hc11elfb m68hc12elf m68hc12elfb" ;;
  391. -m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
  392. +m68hc12-*-*|m6812-*-*) targ_emul=m68hc12elf
  393.                         targ_extra_emuls="m68hc12elfb m68hc11elf m68hc11elfb" ;;
  394.  m68*-sun-sunos[34]*)   targ_emul=sun3 ;;
  395.  m68*-wrs-vxworks*)     targ_emul=sun3 ;;
  396. @@ -635,7 +636,7 @@
  397.                         ;;
  398.  w65-*-*)               targ_emul=w65
  399.                         ;;
  400. -xc16x-*-elf)           targ_emul=elf32xc16x
  401. +xc16x-*-elf)           targ_emul=elf32xc16x
  402.                          targ_extra_emuls="elf32xc16xl elf32xc16xs"
  403.                          ;;
  404.  xstormy16-*-*)         targ_emul=elf32xstormy16
  405. diff -u -r -N /d/ftp/binutils-2.20/ld/emulparams/kos32.sh binutils-2.20/ld/emulparams/kos32.sh
  406. --- /d/ftp/binutils-2.20/ld/emulparams/kos32.sh 1970-01-01 00:00:00 +0000
  407. +++ binutils-2.20/ld/emulparams/kos32.sh        2011-08-07 19:42:30 +0000
  408. @@ -0,0 +1,8 @@
  409. +ARCH=i386
  410. +SCRIPT_NAME=kos32
  411. +OUTPUT_FORMAT="kos32"
  412. +TEMPLATE_NAME=kos32
  413. +ENTRY="__start"
  414. +INITIAL_SYMBOL_CHAR=\"_\"
  415. +NOP=0x90909090
  416. +TARGET_PAGE_SIZE=0x1000
  417. diff -u -r -N /d/ftp/binutils-2.20/ld/emultempl/kos32.em binutils-2.20/ld/emultempl/kos32.em
  418. --- /d/ftp/binutils-2.20/ld/emultempl/kos32.em  1970-01-01 00:00:00 +0000
  419. +++ binutils-2.20/ld/emultempl/kos32.em 2011-08-08 06:34:03 +0000
  420. @@ -0,0 +1,247 @@
  421. +# This shell script emits a C file. -*- C -*-
  422. +#   Copyright 2007 Free Software Foundation, Inc.
  423. +#
  424. +# This file is part of the GNU Binutils.
  425. +#
  426. +# This program is free software; you can redistribute it and/or modify
  427. +# it under the terms of the GNU General Public License as published by
  428. +# the Free Software Foundation; either version 3 of the License, or
  429. +# (at your option) any later version.
  430. +#
  431. +# This program is distributed in the hope that it will be useful,
  432. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  433. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  434. +# GNU General Public License for more details.
  435. +#
  436. +# You should have received a copy of the GNU General Public License
  437. +# along with this program; if not, write to the Free Software
  438. +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  439. +# MA 02110-1301, USA.
  440. +#
  441. +
  442. +fragment <<EOF
  443. +
  444. +#include "sysdep.h"
  445. +#include "bfd.h"
  446. +#include "bfdlink.h"
  447. +#include "getopt.h"
  448. +#include "libiberty.h"
  449. +#include "ld.h"
  450. +#include "ldmain.h"
  451. +#include "ldexp.h"
  452. +#include "ldlang.h"
  453. +#include "ldfile.h"
  454. +#include "ldemul.h"
  455. +#include <ldgram.h>
  456. +#include "ldlex.h"
  457. +#include "ldmisc.h"
  458. +#include "ldctor.h"
  459. +#include "coff/internal.h"
  460. +
  461. +/* FIXME: See bfd/peXXigen.c for why we include an architecture specific
  462. +   header in generic PE code.  */
  463. +#include "coff/i386.h"
  464. +#include "coff/pe.h"
  465. +
  466. +/* FIXME: This is a BFD internal header file, and we should not be
  467. +   using it here.  */
  468. +#include "../bfd/libcoff.h"
  469. +
  470. +#include "deffile.h"
  471. +#include "pe-dll.h"
  472. +#include "safe-ctype.h"
  473. +
  474. +static struct internal_extra_pe_aouthdr pe;
  475. +
  476. +static void
  477. +gld_${EMULATION_NAME}_before_parse (void)
  478. +{
  479. +  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
  480. +  config.dynamic_link = FALSE;
  481. +  config.has_shared = FALSE;
  482. +}
  483. +
  484. +
  485. +#define OPTION_STACK                   (300 + 1)
  486. +
  487. +static void
  488. +gld_${EMULATION_NAME}_add_options
  489. +  (int ns ATTRIBUTE_UNUSED,
  490. +   char **shortopts ATTRIBUTE_UNUSED,
  491. +   int nl,
  492. +   struct option **longopts,
  493. +   int nrl ATTRIBUTE_UNUSED,
  494. +   struct option **really_longopts ATTRIBUTE_UNUSED)
  495. +{
  496. +  static const struct option xtra_long[] = {
  497. +    /* KOS32 options */
  498. +    {"stack", required_argument, NULL, OPTION_STACK},
  499. +    {NULL, no_argument, NULL, 0}
  500. +  };
  501. +
  502. +  *longopts
  503. +    = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
  504. +  memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
  505. +}
  506. +
  507. +typedef struct
  508. +{
  509. +  void *ptr;
  510. +  int size;
  511. +  int value;
  512. +  char *symbol;
  513. +  int inited;
  514. +} definfo;
  515. +
  516. +#define D(field,symbol,def)  {&pe.field,sizeof(pe.field), def, symbol,0}
  517. +
  518. +
  519. +static definfo init[] =
  520. +{
  521. +  D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x200000),
  522. +  { NULL, 0, 0, NULL, 0 }
  523. +};
  524. +
  525. +static void
  526. +gld_${EMULATION_NAME}_list_options (FILE *file)
  527. +{
  528. +  fprintf (file, _("  --stack <size>                     Set size of the stack\n"));
  529. +}
  530. +
  531. +static void
  532. +set_pe_name (char *name, long val)
  533. +{
  534. +  int i;
  535. +
  536. +  /* Find the name and set it.  */
  537. +  for (i = 0; init[i].ptr; i++)
  538. +    {
  539. +      if (strcmp (name, init[i].symbol) == 0)
  540. +        {
  541. +          init[i].value = val;
  542. +          init[i].inited = 1;
  543. +          return;
  544. +        }
  545. +    }
  546. +  abort ();
  547. +}
  548. +
  549. +static void
  550. +set_pe_value (char *name)
  551. +{
  552. +  char *end;
  553. +
  554. +  set_pe_name (name,  strtoul (optarg, &end, 0));
  555. +
  556. +  if (end == optarg)
  557. +    einfo (_("%P%F: invalid hex number for KOS32 parameter '%s'\n"), optarg);
  558. +
  559. +  optarg = end;
  560. +}
  561. +
  562. +static void
  563. +gld_${EMULATION_NAME}_set_symbols (void)
  564. +{
  565. +  /* Run through and invent symbols for all the
  566. +     names and insert the defaults. */
  567. +  int j;
  568. +
  569. +  /* Glue the assignments into the abs section */
  570. +  push_stat_ptr (&abs_output_section->children);
  571. +
  572. +  for (j = 0; init[j].ptr; j++)
  573. +    {
  574. +      long val = init[j].value;
  575. +      lang_add_assignment (exp_assop ('=', init[j].symbol, exp_intop (val)));
  576. +      if (init[j].size == sizeof(short))
  577. +        *(short *)init[j].ptr = val;
  578. +      else if (init[j].size == sizeof(int))
  579. +        *(int *)init[j].ptr = val;
  580. +      else if (init[j].size == sizeof(long))
  581. +        *(long *)init[j].ptr = val;
  582. +      /* This might be a long long or other special type.  */
  583. +      else if (init[j].size == sizeof(bfd_vma))
  584. +        *(bfd_vma *)init[j].ptr = val;
  585. +      else      abort();
  586. +    }
  587. +  /* Restore the pointer. */
  588. +  pop_stat_ptr ();
  589. +}
  590. +
  591. +static bfd_boolean
  592. +gld_${EMULATION_NAME}_handle_option (int optc)
  593. +{
  594. +  switch (optc)
  595. +  {
  596. +    default:
  597. +      return FALSE;
  598. +
  599. +      /* PE options.  */
  600. +    case OPTION_STACK:
  601. +      set_pe_value ("__size_of_stack_reserve__");
  602. +      break;
  603. +  }
  604. +  return TRUE;
  605. +}
  606. +
  607. +static char *
  608. +gld_${EMULATION_NAME}_get_script (int *isfile)
  609. +EOF
  610. +# Scripts compiled in.
  611. +# sed commands to quote an ld script as a C string.
  612. +sc="-f stringify.sed"
  613. +
  614. +fragment <<EOF
  615. +{
  616. +  *isfile = 0;
  617. +
  618. +  if (link_info.relocatable && config.build_constructors)
  619. +    return
  620. +EOF
  621. +sed $sc ldscripts/${EMULATION_NAME}.xu                  >> e${EMULATION_NAME}.c
  622. +echo '  ; else if (link_info.relocatable) return'       >> e${EMULATION_NAME}.c
  623. +sed $sc ldscripts/${EMULATION_NAME}.xr                  >> e${EMULATION_NAME}.c
  624. +echo '  ; else if (!config.text_read_only) return'      >> e${EMULATION_NAME}.c
  625. +sed $sc ldscripts/${EMULATION_NAME}.xbn                 >> e${EMULATION_NAME}.c
  626. +echo '  ; else if (!config.magic_demand_paged) return'  >> e${EMULATION_NAME}.c
  627. +sed $sc ldscripts/${EMULATION_NAME}.xn                  >> e${EMULATION_NAME}.c
  628. +if test -n "$GENERATE_AUTO_IMPORT_SCRIPT" ; then
  629. +echo '  ; else if (link_info.pei386_auto_import == 1) return'   >> e${EMULATION_NAME}.c
  630. +sed $sc ldscripts/${EMULATION_NAME}.xa                  >> e${EMULATION_NAME}.c
  631. +fi
  632. +echo '  ; else return'                                  >> e${EMULATION_NAME}.c
  633. +sed $sc ldscripts/${EMULATION_NAME}.x                   >> e${EMULATION_NAME}.c
  634. +echo '; }'                                              >> e${EMULATION_NAME}.c
  635. +
  636. +fragment <<EOF
  637. +
  638. +
  639. +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
  640. +{
  641. +  gld_${EMULATION_NAME}_before_parse,
  642. +  syslib_default,
  643. +  hll_default,
  644. +  after_parse_default,
  645. +  after_open_default,
  646. +  after_allocation_default,
  647. +  set_output_arch_default,
  648. +  ldemul_default_target,
  649. +  before_allocation_default,
  650. +  gld_${EMULATION_NAME}_get_script,
  651. +  "${EMULATION_NAME}",
  652. +  "${OUTPUT_FORMAT}",
  653. +  finish_default,
  654. +  NULL, /* Create output section statements.  */
  655. +  NULL, /* open dynamic archive */
  656. +  NULL,
  657. +  gld_${EMULATION_NAME}_set_symbols,
  658. +  NULL, /* parse_args */
  659. +  gld_${EMULATION_NAME}_add_options,
  660. +  gld_${EMULATION_NAME}_handle_option,
  661. +  NULL,
  662. +  gld_${EMULATION_NAME}_list_options,
  663. +  NULL,
  664. +  NULL, /* find_potential_libraries */
  665. +  NULL  /* new_vers_pattern.  */
  666. +};
  667. +EOF
  668. diff -u -r -N /d/ftp/binutils-2.20/ld/scripttempl/kos32.sc binutils-2.20/ld/scripttempl/kos32.sc
  669. --- /d/ftp/binutils-2.20/ld/scripttempl/kos32.sc        1970-01-01 00:00:00 +0000
  670. +++ binutils-2.20/ld/scripttempl/kos32.sc       2011-08-08 05:44:09 +0000
  671. @@ -0,0 +1,117 @@
  672. +cat <<EOF
  673. +OUTPUT_FORMAT("${OUTPUT_FORMAT}")
  674. +OUTPUT_ARCH("${OUTPUT_ARCH}")
  675. +ENTRY(__start)
  676. +SECTIONS
  677. +{
  678. +    .text 0x000000:
  679. +    {
  680. +        LONG(0x554e454D);
  681. +        LONG(0x32305445);
  682. +        LONG(1);
  683. +        LONG(__start);
  684. +        LONG(___iend);
  685. +        LONG(___memsize);
  686. +        LONG(___stacktop);
  687. +        LONG(___cmdline);
  688. +        LONG(___pgmname);     /*  full path    */
  689. +        LONG(0);              /*FIXME tls data */
  690. +
  691. +        *(.init)
  692. +        *(.text)
  693. +        *(SORT(.text$*))
  694. +        *(.text.*)
  695. +        *(.glue_7t)
  696. +        *(.glue_7)
  697. +        ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
  698. +                        LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*));  LONG (0);
  699. +        ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
  700. +                        LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*));  LONG (0);
  701. +        *(.fini)
  702. +    /* ??? Why is .gcc_exc here?  */
  703. +        *(.gcc_exc)
  704. +        PROVIDE (etext = .);
  705. +        *(.gcc_except_table)
  706. +    }
  707. +
  708. +    .rdata ALIGN(16) :
  709. +    {
  710. +        *(.rdata)
  711. +        *(SORT(.rdata$*))
  712. +        ___RUNTIME_PSEUDO_RELOC_LIST__ = .;
  713. +        __RUNTIME_PSEUDO_RELOC_LIST__ = .;
  714. +        *(.rdata_runtime_pseudo_reloc)
  715. +        ___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
  716. +        __RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
  717. +    }
  718. +    .CRT ALIGN(16) :
  719. +    {
  720. +         ___crt_xc_start__ = . ;
  721. +        *(SORT(.CRT$XC*))  /* C initialization */
  722. +        ___crt_xc_end__ = . ;
  723. +        ___crt_xi_start__ = . ;
  724. +        *(SORT(.CRT$XI*))  /* C++ initialization */
  725. +        ___crt_xi_end__ = . ;
  726. +        ___crt_xl_start__ = . ;
  727. +        *(SORT(.CRT$XL*))  /* TLS callbacks */
  728. +    /* ___crt_xl_end__ is defined in the TLS Directory support code */
  729. +        ___crt_xp_start__ = . ;
  730. +        *(SORT(.CRT$XP*))  /* Pre-termination */
  731. +        ___crt_xp_end__ = . ;
  732. +        ___crt_xt_start__ = . ;
  733. +        *(SORT(.CRT$XT*))  /* Termination */
  734. +        ___crt_xt_end__ = . ;
  735. +    }
  736. +
  737. +    .data ALIGN(16) :
  738. +    {
  739. +        __data_start__ = . ;
  740. +        *(.data)
  741. +        *(.data2)
  742. +        *(SORT(.data$*))
  743. +        *(.jcr)
  744. +        __CRT_MT = .;
  745. +        LONG(0);
  746. +        __data_end__ = . ;
  747. +        *(.data_cygwin_nocopy)
  748. +    }
  749. +
  750. +    .eh_frame ALIGN(16) :
  751. +    {
  752. +        *(.eh_frame)
  753. +        ___iend = . ;
  754. +    }
  755. +
  756. +    bss ALIGN(16):
  757. +    {
  758. +        *(.bss)
  759. +        *(COMMON)
  760. +        . = ALIGN(16);
  761. +        ___cmdline = .;
  762. +        . = . + 256;
  763. +        ___pgmname = .;
  764. +        . = . + 1024 + 16;
  765. +        ___stacktop = .;
  766. +        ___memsize = . ;
  767. +    }
  768. +
  769. +  /DISCARD/ :
  770. +  {
  771. +    *(.debug$S)
  772. +    *(.debug$T)
  773. +    *(.debug$F)
  774. +    *(.drectve)
  775. +    *(.note.GNU-stack)
  776. +    *(.comment)
  777. +    *(.debug_abbrev)
  778. +    *(.debug_info)
  779. +    *(.debug_line)
  780. +    *(.debug_frame)
  781. +    *(.debug_loc)
  782. +    *(.debug_pubnames)
  783. +    *(.debug_aranges)
  784. +    *(.debug_ranges)
  785. +  }
  786. +
  787. +}
  788. +EOF
  789.