home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / binutils-1.8.x-diffs.lha / GNU / diffs / binutils-1.8.x.diffs
Encoding:
Text File  |  1995-04-14  |  130.8 KB  |  4,702 lines

  1. diff -rc --new-file binutils-1.8.x-base/Makefile binutils-1.8.x/Makefile
  2. *** binutils-1.8.x-base/Makefile    Wed Nov 27 22:48:58 1991
  3. --- binutils-1.8.x/Makefile    Thu Jan  1 00:00:00 1970
  4. ***************
  5. *** 1,150 ****
  6. - # Makefile for GNU binary-file utilities
  7. - # select a set of CFLAGS and PROGS, below, depending on the system type
  8. - # Copyright (C) 1989, Free Software Foundation, Inc.
  9. - #
  10. - # This file is part of the GNU binutils.
  11. - # 
  12. - # The GNU binutils are free software; you can redistribute them and/or modify
  13. - # them under the terms of the GNU General Public License as published by
  14. - # the Free Software Foundation; either version 1, or (at your option)
  15. - # any later version.
  16. - # 
  17. - # The GNU binutils are distributed in the hope that they will be useful,
  18. - # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. - # GNU General Public License for more details.
  21. - # 
  22. - # You should have received a copy of the GNU General Public License
  23. - # along with the GNU binutils; see the file COPYING.  If not, write to
  24. - # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25. - GNUCC = gcc -O
  26. - #CC = gcc -O
  27. - bindir=/usr/local/bin
  28. - # for BSD systems
  29. - #CFLAGS = -g
  30. - # Don't add robotussin; it won't compile on BSD or GNU systems.
  31. - # objdump is not here because it (at least used to) not compile
  32. - # on most systems (trouble with N_DATADDR).  I've fixed some of
  33. - # those problems, though.
  34. - PROGS = $(archpfx)gprof $(archpfx)ld $(archpfx)size \
  35. -         $(archpfx)nm $(archpfx)strip $(archpfx)ar $(archpfx)ranlib
  36. - # for USG systems using COFF_ENCAPSULATE
  37. - # also, you will want to make the target libc.a (but it takes a long time)
  38. - # Note that you should leave a copy of `ar' in this directory
  39. - # after you install it, since `ranlib' will try to run it from here.
  40. - CFLAGS = -DWYSE -DUSG -DCOFF_ENCAPSULATE -DPORTAR -DNON_NATIVE -DPIGNAL_MISSING
  41. - PROGS = ld size nm strip ar robotussin objdump ranlib gprof
  42. - SIGNAME = signame.o
  43. - # On ALTOS systems, add -DALTOS to CFLAGS.
  44. - #it's better to move a copy of alloca into your libc than to risk getting some
  45. - #incompatiable functions from -lPW (like index()), but if you
  46. - #want to be lazy, uncomment this line
  47. - ALLOCALIBS = -lPW
  48. - # For HP-UX systems
  49. - # Don't add robotussin; use hpxt instead.
  50. - # Note that you should leave a copy of `ar' in this directory
  51. - # after you install it, since `ranlib' will try to run it from here.
  52. - #CFLAGS = -g -Ihp-include -DUSG -DNON_NATIVE
  53. - #PROGS = ld size nm strip ar ranlib
  54. - #ALLOCALIBS = alloca.o
  55. - # For the NeXT:
  56. - # Set GNUCC = cc
  57. - # Add -DHAVE_VPRINTF -DMACH_O to CFLAGS.
  58. - # Comment out MALLOC below to use the system's malloc().
  59. - # Sun386:
  60. - # After applying these diffs, compile with -DPORTAR -DCOFF_ENCAPSULATE
  61. - # Depending on how you configure gcc, you might also want -Dnounderscore,
  62. - # though I did not wind up using it.
  63. - # If you run out of stack space while running GNU ar or GNU ld (this
  64. - # manifests itself as a segment violation), you should link in alloca.c
  65. - # from the gcc sources, and get rid of the "#define alloca" in ar.c and
  66. - # ld.c; or you could try to get Sun to fix this annoying "feature".
  67. - #CFLAGS = -g -DCOFF_ENCAPSULATE -DPORTAR
  68. - #PROGS = ld size nm strip ar robotussin objdump ranlib gprof
  69. - # nm tries to malloc enough space for the string table.  The old GNU malloc
  70. - # rounds this up to a power of two (e.g. 5M becomes 8M), and so it might 
  71. - # fail unnecessarily.  I've also seen some unix malloc's fail, even when
  72. - # there is enough memory.  So use the new GNU malloc.
  73. - #MALLOC = $(archpfx)gmalloc.o
  74. - GNU_GETOPT = $(archpfx)getopt.o
  75. - GNU_GETOPT_LONG = $(archpfx)getopt.o $(archpfx)getopt1.o
  76. - # C++ demangler
  77. - CPLUS_DEM = $(archpfx)cplus-dem.o
  78. - LIBS=$(MALLOC) $(ALLOCALIBS) $(SIGNAME)
  79. - all: $(PROGS)
  80. - $(archpfx)ld: $(archpfx)ld.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
  81. - # LIBS is used here since ld needs to use alloca.
  82. - # Alternatively, compile it with GNU C--then the compiler handles alloca.
  83. -     $(CC) $(CFLAGS) -o $(archpfx)ld $(archpfx)ld.o $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(LIBS)
  84. - $(archpfx)size: $(archpfx)size.o
  85. -     $(CC) $(CFLAGS) -o $(archpfx)size $(archpfx)size.o
  86. - $(archpfx)nm: $(archpfx)nm.o $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(MALLOC)
  87. -     $(CC) $(CFLAGS) -o $(archpfx)nm $(archpfx)nm.o \
  88. -         $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(LIBS) $(MALLOC)
  89. - $(archpfx)strip: $(archpfx)strip.o $(GNU_GETOPT_LONG)
  90. -     $(CC) $(CFLAGS) -o $(archpfx)strip $(archpfx)strip.o $(GNU_GETOPT_LONG) $(LIBS)
  91. - $(archpfx)ar: $(archpfx)ar.o
  92. -     $(CC) $(CFLAGS) -o $(archpfx)ar $(archpfx)ar.o $(LIBS)
  93. - $(archpfx)gprof: $(archpfx)gprof.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
  94. -     $(GNUCC) $(CFLAGS) -o $(archpfx)gprof $(archpfx)gprof.o \
  95. -         $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(LIBS)
  96. - $(archpfx)gprof.o: gprof.c gmon.h 
  97. -     $(GNUCC) $(CFLAGS) -c gprof.c $(OUTPUT_OPTION)
  98. - $(archpfx)ranlib: $(archpfx)ranlib.o $(GNU_GETOPT_LONG)
  99. -     $(CC) $(CFLAGS) -o $(archpfx)ranlib $(archpfx)ranlib.o $(GNU_GETOPT_LONG) $(LIBS)
  100. - $(archpfx)ranlib.o: ranlib.c
  101. -     $(CC) -c $(CFLAGS) -DAR_PROG=\"/usr/local/gnu/binutils/ar\" ranlib.c $(OUTPUT_OPTION)
  102. - $(archpfx)objdump: $(archpfx)objdump.o $(GNU_GETOPT_LONG) a.out.gnu.h
  103. -     $(CC) $(CFLAGS) -o $(archpfx)objdump $(archpfx)objdump.o \
  104. -         $(GNU_GETOPT_LONG) $(LIBS)
  105. - # Robotussin is NOT part of `all'.
  106. - $(archpfx)robotussin: $(archpfx)robotussin.o
  107. -     $(CC) $(CFLAGS) -o $(archpfx)robotussin $(archpfx)robotussin.o
  108. - libc.a: $(archpfx)robotussin libconvert $(archpfx)ar
  109. -     libconvert /lib/libc.a libc.a
  110. - # usg-gnulib is the file gcc makes using the usg compiler
  111. - gnulib: $(archpfx)robotussin libconvert usg-gnulib $(archpfx)ar
  112. -     libconvert usg-gnulib gnulib
  113. - clean:
  114. -     -rm -f *.o core
  115. -     -rm -f $(archpfx)*.o
  116. -     -rm -f $(PROGS)
  117. - dist: binutils.tar.Z
  118. - # Requires GNU tar.
  119. - binutils.tar.Z:
  120. -     cd ..; tar -cohz -f binutils/binutils.tar.Z -T binutils/ARCHLIST
  121. - .PHONY: install
  122. - install: $(PROGS)
  123. -     for file in $(PROGS); do \
  124. -     cp $$file $(bindir)/$${file}.new; \
  125. -     mv $(bindir)/$${file}.new $(bindir)/$$file; \
  126. -     done
  127. --- 0 ----
  128. diff -rc --new-file binutils-1.8.x-base/Makefile.in binutils-1.8.x/Makefile.in
  129. *** binutils-1.8.x-base/Makefile.in    Thu Jan  1 00:00:00 1970
  130. --- binutils-1.8.x/Makefile.in    Wed Nov 16 07:04:04 1994
  131. ***************
  132. *** 0 ****
  133. --- 1,138 ----
  134. + # Makefile for GNU binary-file utilities
  135. + # Copyright (C) 1989, Free Software Foundation, Inc.
  136. + #
  137. + # This file is part of the GNU binutils.
  138. + # 
  139. + # The GNU binutils are free software; you can redistribute them and/or modify
  140. + # them under the terms of the GNU General Public License as published by
  141. + # the Free Software Foundation; either version 1, or (at your option)
  142. + # any later version.
  143. + # 
  144. + # The GNU binutils are distributed in the hope that they will be useful,
  145. + # but WITHOUT ANY WARRANTY; without even the implied warranty of
  146. + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  147. + # GNU General Public License for more details.
  148. + # 
  149. + # You should have received a copy of the GNU General Public License
  150. + # along with the GNU binutils; see the file COPYING.  If not, write to
  151. + # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  152. + #### Start of system configuration section. ####
  153. + VPATH = @srcdir@
  154. + srcdir = @srcdir@
  155. + # Common prefix for machine-independent installed files.
  156. + prefix = /gnu
  157. + # Common prefix for machine-dependent installed files.
  158. + exec_prefix = $(prefix)
  159. + # Directory to install executables in.
  160. + bindir = $(exec_prefix)/bin
  161. + # Directory to install libraries in.
  162. + libdir = $(exec_prefix)/lib
  163. + # Directory to install the Info files in.
  164. + infodir = $(prefix)/info
  165. + # Directory to install the man page in.
  166. + mandir = $(prefix)/man/man$(manext)
  167. + # Number to put on the man page filename.
  168. + manext = 1
  169. + # Program to install executables.
  170. + INSTALL_PROGRAM = @INSTALL_PROGRAM@
  171. + # Program to install data like man pages.
  172. + INSTALL_DATA = @INSTALL_DATA@
  173. + # Generic install program.
  174. + INSTALL = @INSTALL@
  175. + CC = @CC@
  176. + CFLAGS = @CFLAGS@
  177. + DEFS = @DEFS@
  178. + LDFLAGS = @LDFLAGS@
  179. + LIBS = @LIBS@
  180. + #### End of system configuration section. ####
  181. + # -I. is needed to find config.h in the build directory.
  182. + .c.o:
  183. +     $(CC) -c -I. -I$(srcdir) $(CFLAGS) $< $(OUTPUT_OPTION)
  184. + #Don't include gprof.
  185. + PROGS = $(archpfx)ld $(archpfx)size \
  186. +         $(archpfx)nm $(archpfx)strip $(archpfx)ar $(archpfx)ranlib
  187. + GNU_GETOPT = $(archpfx)getopt.o
  188. + GNU_GETOPT_LONG = $(archpfx)getopt.o $(archpfx)getopt1.o
  189. + # C++ demangler
  190. + CPLUS_DEM = $(archpfx)cplus-dem.o
  191. + all: $(PROGS)
  192. + $(archpfx)ld: $(archpfx)ld.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
  193. +     $(CC) $(LDFLAGS) -o $(archpfx)ld $(archpfx)ld.o \
  194. +         $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(LIBS)
  195. + $(archpfx)size: $(archpfx)size.o
  196. +     $(CC) $(LDFLAGS) -o $(archpfx)size $(archpfx)size.o $(LIBS)
  197. + $(archpfx)nm: $(archpfx)nm.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
  198. +     $(CC) $(LDFLAGS) -o $(archpfx)nm $(archpfx)nm.o \
  199. +         $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(LIBS)
  200. + $(archpfx)strip: $(archpfx)strip.o $(GNU_GETOPT_LONG)
  201. +     $(CC) $(LDFLAGS) -o $(archpfx)strip $(archpfx)strip.o \
  202. +         $(GNU_GETOPT_LONG) $(LIBS)
  203. + $(archpfx)ar: $(archpfx)ar.o
  204. +     $(CC) $(LDFLAGS) -o $(archpfx)ar $(archpfx)ar.o $(LIBS)
  205. + $(archpfx)gprof: $(archpfx)gprof.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
  206. +     $(CC) $(LDFLAGS) -o $(archpfx)gprof $(archpfx)gprof.o \
  207. +         $(GNU_GETOPT_LONG) $(CPLUS_DEM) $(LIBS)
  208. + $(archpfx)gprof.o: gprof.c gmon.h 
  209. +     $(CC) $(CFLAGS) -c gprof.c $(OUTPUT_OPTION)
  210. + $(archpfx)ranlib: $(archpfx)ranlib.o $(GNU_GETOPT_LONG)
  211. +     $(CC) $(LDFLAGS) -o $(archpfx)ranlib $(archpfx)ranlib.o \
  212. +         $(GNU_GETOPT_LONG) $(LIBS)
  213. + $(archpfx)ranlib.o: ranlib.c
  214. +     $(CC) $(CFLAGS) -c -I. -I$(srcdir) \
  215. +         -DAR_PROG=\"$(bindir)/ar\" $(srcdir)/ranlib.c $(OUTPUT_OPTION)
  216. + $(archpfx)objdump: $(archpfx)objdump.o $(GNU_GETOPT_LONG) a.out.gnu.h
  217. +     $(CC) $(LDFLAGS) -o $(archpfx)objdump $(archpfx)objdump.o \
  218. +         $(GNU_GETOPT_LONG) $(LIBS)
  219. + Makefile: config.status $(srcdir)/Makefile.in
  220. +     $(SHELL) config.status
  221. + # Robotussin is NOT part of `all'.
  222. + $(archpfx)robotussin: $(archpfx)robotussin.o
  223. +     $(CC) $(LDFLAGS) -o $(archpfx)robotussin $(archpfx)robotussin.o
  224. + libc.a: $(archpfx)robotussin libconvert $(archpfx)ar
  225. +     libconvert /lib/libc.a libc.a
  226. + # usg-gnulib is the file gcc makes using the usg compiler
  227. + gnulib: $(archpfx)robotussin libconvert usg-gnulib $(archpfx)ar
  228. +     libconvert usg-gnulib gnulib
  229. + clean:
  230. +     -rm -f *.o core
  231. +     -rm -f $(archpfx)*.o
  232. +     -rm -f $(PROGS)
  233. + dist: binutils.tar.Z
  234. + # Requires GNU tar.
  235. + binutils.tar.Z:
  236. +     cd ..; tar -cohz -f binutils/binutils.tar.Z -T binutils/ARCHLIST
  237. + .PHONY: install
  238. + install: $(PROGS)
  239. +     for file in $(PROGS); do \
  240. +     $(INSTALL_PROGRAM) $${file} $(bindir)/$${file}; \
  241. +     done
  242. diff -rc --new-file binutils-1.8.x-base/Product-Info binutils-1.8.x/Product-Info
  243. *** binutils-1.8.x-base/Product-Info    Thu Jan  1 00:00:00 1970
  244. --- binutils-1.8.x/Product-Info    Mon Jul 11 23:11:22 1994
  245. ***************
  246. *** 0 ****
  247. --- 1,21 ----
  248. + .name
  249. + binutils
  250. + .fullname
  251. + GNU binary file utilities
  252. + .type
  253. + Programmer Tool
  254. + .short
  255. + GNU binary file utilities.
  256. + .description
  257. + Various tools for operating on object and executable files.  Includes "ld",
  258. + "size", "nm", "strip", "ar", "objdump", and "ranlib".
  259. + .version
  260. + 1.8.x
  261. + .author
  262. + Free Software Foundation
  263. + .requirements
  264. + Binary versions require ixemul.library.
  265. + .distribution
  266. + GNU Public License
  267. + .described-by
  268. + Fred Fish (fnf@amigalib.com)
  269. diff -rc --new-file binutils-1.8.x-base/ar.c binutils-1.8.x/ar.c
  270. *** binutils-1.8.x-base/ar.c    Wed Jun 13 05:47:50 1990
  271. --- binutils-1.8.x/ar.c    Sun Mar  5 15:26:32 1995
  272. ***************
  273. *** 736,741 ****
  274. --- 736,742 ----
  275.       {
  276.         if (tail->info.name == 0)
  277.       continue;
  278. + #if 0
  279.         if (!strncmp (tail->info.name, name, 13))
  280.       {
  281.         unsigned int eltlen = strlen (tail->info.name);
  282. ***************
  283. *** 751,756 ****
  284. --- 752,764 ----
  285.           return tail;
  286.           }
  287.       }
  288. + #else
  289. +       /* Don't consider length, the name is shortened later if needed. */
  290. +       if (strcmp (tail->info.name, name) == 0)
  291. +     {
  292. +       return (tail);
  293. +     }
  294. + #endif
  295.       }
  296.   
  297.     return 0;
  298. ***************
  299. *** 992,1002 ****
  300. --- 1000,1020 ----
  301.   #endif
  302.     close (outdesc);
  303.   
  304. + #ifndef amigados
  305.     if (!appendflag)
  306.       if (rename (tempname, archive))
  307.         pfatal_with_name (tempname);
  308.   
  309.     close_archive ();
  310. + #else
  311. +   /* we *have* to close the file before we rename it, because otherwise
  312. +    * AmigaDOS will just abort with OBJECT_IN_USE_ERROR */
  313. +   close_archive ();
  314. +   if (!appendflag)
  315. +     if (rename (tempname, archive))
  316. +       pfatal_with_name (tempname);
  317. + #endif
  318.   }
  319.   
  320.   void
  321. ***************
  322. *** 1005,1029 ****
  323.        struct mapelt *mapelt;
  324.   {
  325.     unsigned int namelen;
  326.   
  327.     /* Zero the header, then store in the data as text.  */
  328.     bzero ((char *) header, sizeof (*header));
  329.   
  330. !   strncpy (header->ar_name, mapelt->info.name, sizeof (header->ar_name));
  331. !   namelen = strlen (mapelt->info.name);
  332.     if (namelen >= sizeof (header->ar_name))
  333.       {
  334. !       if (mapelt->info.name[namelen - 2] == '.' &&
  335. !       mapelt->info.name[namelen - 1] == 'o')
  336.       {
  337.         header->ar_name[sizeof (header->ar_name) - 3] = '.';
  338.         header->ar_name[sizeof (header->ar_name) - 2] = 'o';
  339.       }
  340.         header->ar_name[sizeof (header->ar_name) - 1] = '\0';
  341.         error ("member name `%s' truncated to `%s'",
  342.            mapelt->info.name, header->ar_name);
  343.       }
  344.     sprintf (header->ar_date, "%ld", mapelt->info.date);
  345.     sprintf (header->ar_size, "%d", mapelt->info.size);
  346.     sprintf (header->ar_uid, "%d", mapelt->info.uid);
  347. --- 1023,1063 ----
  348.        struct mapelt *mapelt;
  349.   {
  350.     unsigned int namelen;
  351. +   char *ar_name, *tmp;
  352. +   extern char *strchr ();
  353.   
  354.     /* Zero the header, then store in the data as text.  */
  355.     bzero ((char *) header, sizeof (*header));
  356.   
  357. !   /* Strip off leading directory components of the full pathname
  358. !      until the name either fits, or there are no more components.
  359. !      If the name is still to large, it is truncated from the right
  360. !      end later on. */
  361. !   ar_name = mapelt->info.name;
  362. !   while (((namelen = strlen (ar_name)) >= sizeof (header->ar_name)) &&
  363. !      ((tmp = strchr (ar_name, '/')) != NULL))
  364. !     {
  365. !       ar_name = tmp + 1;
  366. !     }
  367. !   strncpy (header->ar_name, ar_name, sizeof (header->ar_name));
  368. !   namelen = strlen (ar_name);
  369.     if (namelen >= sizeof (header->ar_name))
  370.       {
  371. !       if (ar_name[namelen - 2] == '.' &&
  372. !       ar_name[namelen - 1] == 'o')
  373.       {
  374.         header->ar_name[sizeof (header->ar_name) - 3] = '.';
  375.         header->ar_name[sizeof (header->ar_name) - 2] = 'o';
  376.       }
  377.         header->ar_name[sizeof (header->ar_name) - 1] = '\0';
  378. +     }
  379. +   if (strncmp (header->ar_name, mapelt->info.name, sizeof (header->ar_name)) != 0)
  380. +     {
  381.         error ("member name `%s' truncated to `%s'",
  382.            mapelt->info.name, header->ar_name);
  383.       }
  384.     sprintf (header->ar_date, "%ld", mapelt->info.date);
  385.     sprintf (header->ar_size, "%d", mapelt->info.size);
  386.     sprintf (header->ar_uid, "%d", mapelt->info.uid);
  387. ***************
  388. *** 1957,1962 ****
  389. --- 1991,1997 ----
  390.        unsigned int size;
  391.   {
  392.     extern char *malloc ();
  393.     char *result = malloc (size);
  394.     if (result == 0)
  395.       fatal ("virtual memory exhausted", 0);
  396. ***************
  397. *** 1969,1974 ****
  398. --- 2004,2010 ----
  399.        unsigned int size;
  400.   {
  401.     extern char *realloc ();
  402.     char *result = realloc (ptr, size);
  403.     if (result == 0)
  404.       fatal ("virtual memory exhausted");
  405. diff -rc --new-file binutils-1.8.x-base/configure binutils-1.8.x/configure
  406. *** binutils-1.8.x-base/configure    Thu Jan  1 00:00:00 1970
  407. --- binutils-1.8.x/configure    Tue Jun 21 22:39:22 1994
  408. ***************
  409. *** 0 ****
  410. --- 1,637 ----
  411. + #!/bin/sh
  412. + # Guess values for system-dependent variables and create Makefiles.
  413. + # Generated automatically using autoconf version 1.11 
  414. + # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  415. + # This configure script is free software; you can redistribute it and/or
  416. + # modify it under the terms of the GNU General Public License as published
  417. + # by the Free Software Foundation; either version 2, or (at your option)
  418. + # any later version.
  419. + # This script is distributed in the hope that it will be useful, but
  420. + # WITHOUT ANY WARRANTY; without even the implied warranty of
  421. + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
  422. + # Public License for more details.
  423. + # You should have received a copy of the GNU General Public License
  424. + # along with this program; if not, write to the Free Software
  425. + # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  426. + # Save the original args to write them into config.status later.
  427. + configure_args="$*"
  428. + # Only options that might do something get documented.
  429. + ac_usage="Usage: configure [options] [host]
  430. + Options: [defaults in brackets after descriptions]
  431. + --build=BUILD        configure for building on BUILD [BUILD=HOST]
  432. + --disable-FEATURE    do not include FEATURE (same as --enable-FEATURE=no)
  433. + --enable-FEATURE[=ARG]    include FEATURE [ARG=yes]
  434. + --exec-prefix=PREFIX    install host dependent files in PREFIX [/usr/local]
  435. + --help            print this message
  436. + --host=HOST        configure for HOST [guessed]
  437. + --prefix=PREFIX        install host independent files in PREFIX [/usr/local]
  438. + --quiet, --silent    do not print \`checking for...' messages
  439. + --srcdir=DIR        find the sources in DIR [configure dir or ..]
  440. + --target=TARGET        configure for TARGET [TARGET=HOST]
  441. + --verbose        print results of checks
  442. + --version        print the version of autoconf that created configure
  443. + --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  444. + --without-PACKAGE    do not use PACKAGE (same as --with-PACKAGE=no)
  445. + --x-includes=DIR    X include files are in DIR
  446. + --x-libraries=DIR    X library files are in DIR"
  447. + # Initialize some variables set by options.
  448. + # The variables have the same names as the options, with
  449. + # dashes changed to underlines.
  450. + build=NONE
  451. + exec_prefix=
  452. + host=NONE
  453. + no_create=
  454. + nonopt=NONE
  455. + norecursion=
  456. + prefix=
  457. + program_prefix=
  458. + program_suffix=
  459. + program_transform_name=
  460. + silent=
  461. + srcdir=
  462. + target=NONE
  463. + verbose=
  464. + x_includes=
  465. + x_libraries=
  466. + ac_prev=
  467. + for ac_option
  468. + do
  469. +   # If the previous option needs an argument, assign it.
  470. +   if test -n "$ac_prev"; then
  471. +     eval "$ac_prev=\$ac_option"
  472. +     ac_prev=
  473. +     continue
  474. +   fi
  475. +   # Accept (but ignore some of) the important Cygnus configure
  476. +   # options, so we can diagnose typos.
  477. +   case "$ac_option" in
  478. +   -*=*) ac_optarg=`/bin/echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  479. +   *) ac_optarg= ;;
  480. +   esac
  481. +   case "$ac_option" in
  482. +   -build | --build | --buil | --bui | --bu | --b)
  483. +     ac_prev=build ;;
  484. +   -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*)
  485. +     build="$ac_optarg" ;;
  486. +   -disable-* | --disable-*)
  487. +     ac_feature=`/bin/echo $ac_option|sed -e 's/-*disable-//'`
  488. +     # Reject names that aren't valid shell variable names.
  489. +     if test -n "`/bin/echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
  490. +       /bin/echo "configure: $ac_feature: invalid feature name" >&2; exit 1
  491. +     fi
  492. +     ac_feature=`/bin/echo $ac_feature| sed 's/-/_/g'`
  493. +     eval "enable_${ac_feature}=no" ;;
  494. +   -enable-* | --enable-*)
  495. +     ac_feature=`/bin/echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
  496. +     # Reject names that aren't valid shell variable names.
  497. +     if test -n "`/bin/echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
  498. +       /bin/echo "configure: $ac_feature: invalid feature name" >&2; exit 1
  499. +     fi
  500. +     ac_feature=`/bin/echo $ac_feature| sed 's/-/_/g'`
  501. +     case "$ac_option" in
  502. +       *=*) ;;
  503. +       *) ac_optarg=yes ;;
  504. +     esac
  505. +     eval "enable_${ac_feature}='$ac_optarg'" ;;
  506. +   # For backward compatibility, recognize -exec-prefix and --exec_prefix.
  507. +   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  508. +   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  509. +   | --exec | --exe | --ex)
  510. +     ac_prev=exec_prefix ;;
  511. +   -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  512. +   | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  513. +   | --exec=* | --exe=* | --ex=*)
  514. +     exec_prefix="$ac_optarg" ;;
  515. +   -gas | --gas | --ga | --g)
  516. +     with_gas=yes ;; # Obsolete; use --with-gas.
  517. +   -help | --help | --hel | --he)
  518. +     cat << EOF
  519. + $ac_usage
  520. + EOF
  521. +     exit 0 ;;
  522. +   -host | --host | --hos | --ho)
  523. +     ac_prev=host ;;
  524. +   -host=* | --host=* | --hos=* | --ho=*)
  525. +     host="$ac_optarg" ;;
  526. +   -nfp | --nfp | --nf)
  527. +     with_fp=no ;; # Obsolete; use --without-fp.
  528. +   -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  529. +   | --no-cr | --no-c)
  530. +     no_create=yes ;;
  531. +   -norecursion | --norecursion | --norecursio | --norecursi \
  532. +   | --norecurs | --norecur | --norecu | --norec | --nore | --nor)
  533. +     norecursion=yes ;;
  534. +   -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  535. +     ac_prev=prefix ;;
  536. +   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  537. +     prefix="$ac_optarg" ;;
  538. +   -program-prefix | --program-prefix | --program-prefi | --program-pref \
  539. +   | --program-pre | --program-pr | --program-p)
  540. +     ac_prev=program_prefix ;;
  541. +   -program-prefix=* | --program-prefix=* | --program-prefi=* \
  542. +   | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
  543. +     program_prefix="$ac_optarg" ;;
  544. +   -program-suffix | --program-suffix | --program-suffi | --program-suff \
  545. +   | --program-suf | --program-su | --program-s)
  546. +     ac_prev=program_suffix ;;
  547. +   -program-suffix=* | --program-suffix=* | --program-suffi=* \
  548. +   | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
  549. +     program_suffix="$ac_optarg" ;;
  550. +   -program-transform-name | --program-transform-name \
  551. +   | --program-transform-nam | --program-transform-na \
  552. +   | --program-transform-n | --program-transform- \
  553. +   | --program-transform | --program-transfor \
  554. +   | --program-transfo | --program-transf \
  555. +   | --program-trans | --program-tran \
  556. +   | --progr-tra | --program-tr | --program-t)
  557. +     ac_prev=program_transform_name ;;
  558. +   -program-transform-name=* | --program-transform-name=* \
  559. +   | --program-transform-nam=* | --program-transform-na=* \
  560. +   | --program-transform-n=* | --program-transform-=* \
  561. +   | --program-transform=* | --program-transfor=* \
  562. +   | --program-transfo=* | --program-transf=* \
  563. +   | --program-trans=* | --program-tran=* \
  564. +   | --progr-tra=* | --program-tr=* | --program-t=*)
  565. +     program_transform_name="$ac_optarg" ;;
  566. +   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  567. +   | -silent | --silent | --silen | --sile | --sil)
  568. +     silent=yes ;;
  569. +   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  570. +     ac_prev=srcdir ;;
  571. +   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  572. +     srcdir="$ac_optarg" ;;
  573. +   -target | --target | --targe | --targ | --tar | --ta | --t)
  574. +     ac_prev=target ;;
  575. +   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
  576. +     target="$ac_optarg" ;;
  577. +   -v | -verbose | --verbose | --verbos | --verbo | --verb)
  578. +     verbose=yes ;;
  579. +   -version | --version | --versio | --versi | --vers)
  580. +     /bin/echo "configure generated by autoconf version 1.11"
  581. +     exit 0 ;;
  582. +   -with-* | --with-*)
  583. +     ac_package=`/bin/echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
  584. +     # Reject names that aren't valid shell variable names.
  585. +     if test -n "`/bin/echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
  586. +       /bin/echo "configure: $ac_package: invalid package name" >&2; exit 1
  587. +     fi
  588. +     ac_package=`/bin/echo $ac_package| sed 's/-/_/g'`
  589. +     case "$ac_option" in
  590. +       *=*) ;;
  591. +       *) ac_optarg=yes ;;
  592. +     esac
  593. +     eval "with_${ac_package}='$ac_optarg'" ;;
  594. +   -without-* | --without-*)
  595. +     ac_package=`/bin/echo $ac_option|sed -e 's/-*without-//'`
  596. +     # Reject names that aren't valid shell variable names.
  597. +     if test -n "`/bin/echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
  598. +       /bin/echo "configure: $ac_package: invalid package name" >&2; exit 1
  599. +     fi
  600. +     ac_package=`/bin/echo $ac_package| sed 's/-/_/g'`
  601. +     eval "with_${ac_package}=no" ;;
  602. +   --x) with_x=yes ;; # Obsolete; use --with-x.
  603. +   -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
  604. +   | --x-incl | --x-inc | --x-in | --x-i)
  605. +     ac_prev=x_includes ;;
  606. +   -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
  607. +   | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
  608. +     x_includes="$ac_optarg" ;;
  609. +   -x-libraries | --x-libraries | --x-librarie | --x-librari \
  610. +   | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
  611. +     ac_prev=x_libraries ;;
  612. +   -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
  613. +   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
  614. +     x_libraries="$ac_optarg" ;;
  615. +   -*) /bin/echo "configure: $ac_option: invalid option; use --help to show usage" >&2; exit 1
  616. +     ;;
  617. +   *) 
  618. +     if test -n "`/bin/echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
  619. +       /bin/echo "configure: warning: $ac_option: invalid host type" >&2
  620. +     fi
  621. +     if test "x$nonopt" != xNONE; then
  622. +       /bin/echo "configure: can only configure for one host and one target at a time" >&2; exit 1
  623. +     fi
  624. +     nonopt="$ac_option"
  625. +     ;;
  626. +   esac
  627. + done
  628. + if test -n "$ac_prev"; then
  629. +   /bin/echo "configure: missing argument to --`/bin/echo $ac_prev | sed 's/_/-/g'`" >&2; exit 1
  630. + fi
  631. + trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15
  632. + trap 'rm -fr confdefs* $ac_clean_files' 0
  633. + # Save the original args if we used an alternate arg parser.
  634. + ac_configure_temp="${configure_args-$*}"
  635. + # Strip out --no-create and --norecursion so they don't pile up.
  636. + configure_args=
  637. + for ac_arg in $ac_configure_temp; do
  638. +   case "$ac_arg" in
  639. +   -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  640. +   | --no-cr | --no-c) ;;
  641. +   -norecursion | --norecursion | --norecursio | --norecursi \
  642. +   | --norecurs | --norecur | --norecu | --norec | --nore | --nor) ;;
  643. +   *) configure_args="$configure_args $ac_arg" ;;
  644. +   esac
  645. + done
  646. + # NLS nuisances.
  647. + # These must not be set unconditionally because not all systems understand
  648. + # e.g. LANG=C (notably SCO).
  649. + if test "${LC_ALL+set}" = 'set'; then LC_ALL=C; export LC_ALL; fi
  650. + if test "${LANG+set}"   = 'set'; then LANG=C;   export LANG;   fi
  651. + # confdefs.h avoids OS command line length limits that DEFS can exceed.
  652. + rm -rf conftest* confdefs.h
  653. + # AIX cpp loses on an empty file, so make sure it contains at least a newline.
  654. + /bin/echo > confdefs.h
  655. + # A filename unique to this package, relative to the directory that
  656. + # configure is in, which we can look for to find out if srcdir is correct.
  657. + ac_unique_file=ld.c
  658. + # Find the source files, if location was not specified.
  659. + if test -z "$srcdir"; then
  660. +   ac_srcdir_defaulted=yes
  661. +   # Try the directory containing this script, then `..'.
  662. +   ac_prog=$0
  663. +   ac_confdir=`/bin/echo $ac_prog|sed 's%/[^/][^/]*$%%'`
  664. +   test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
  665. +   srcdir=$ac_confdir
  666. +   if test ! -r $srcdir/$ac_unique_file; then
  667. +     srcdir=..
  668. +   fi
  669. + fi
  670. + if test ! -r $srcdir/$ac_unique_file; then
  671. +   if test x$ac_srcdir_defaulted = xyes; then
  672. +     /bin/echo "configure: can not find sources in ${ac_confdir} or .." >&2; exit 1
  673. +   else
  674. +     /bin/echo "configure: can not find sources in ${srcdir}" >&2; exit 1
  675. +   fi
  676. + fi
  677. + ac_ext=c
  678. + # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
  679. + ac_cpp='${CPP}'
  680. + ac_compile='${CC-cc} $CFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS >/dev/null 2>&1'
  681. + # We want these before the checks, so the checks can modify their values.
  682. + test -z "$CFLAGS" && CFLAGS= auto_cflags=1
  683. + test -z "$LDFLAGS" && LDFLAGS=
  684. + if test -z "$CC"; then
  685. +   # Extract the first word of `gcc', so it can be a program name with args.
  686. +   set ac_dummy gcc; ac_word=$2
  687. +   test -n "$silent" || /bin/echo "checking for $ac_word"
  688. +   IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  689. +   for ac_dir in $PATH; do
  690. +     test -z "$ac_dir" && ac_dir=.
  691. +     if test -f $ac_dir/$ac_word; then
  692. +       CC="gcc"
  693. +       break
  694. +     fi
  695. +   done
  696. +   IFS="$ac_save_ifs"
  697. + fi
  698. + test -z "$CC" && CC="cc"
  699. + test -n "$CC" && test -n "$verbose" && /bin/echo "    setting CC to $CC"
  700. + # Find out if we are using GNU C, under whatever name.
  701. + cat > conftest.c <<EOF
  702. + #ifdef __GNUC__
  703. +   yes
  704. + #endif
  705. + EOF
  706. + ${CC-cc} -E conftest.c > conftest.out 2>&1
  707. + if egrep yes conftest.out >/dev/null 2>&1; then
  708. +   GCC=1 # For later tests.
  709. + fi
  710. + rm -f conftest*
  711. + # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
  712. + test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
  713. + test -n "$silent" || /bin/echo "checking how to run the C preprocessor"
  714. + if test -z "$CPP"; then
  715. +   # This must be in double quotes, not single quotes, because CPP may get
  716. +   # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  717. +   # make.  It must be expanded now.
  718. +   CPP="${CC-cc} -E"
  719. +   cat > conftest.${ac_ext} <<EOF
  720. + #include "confdefs.h"
  721. + #include <stdio.h>
  722. + Syntax Error
  723. + EOF
  724. + # Some shells (Coherent) do redirections in the wrong order, so need
  725. + # the parens.
  726. + ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  727. + if test -z "$ac_err"; then
  728. +   :
  729. + else
  730. +   rm -rf conftest*
  731. +   CPP="${CC-cc} -E -traditional-cpp"
  732. +   cat > conftest.${ac_ext} <<EOF
  733. + #include "confdefs.h"
  734. + #include <stdio.h>
  735. + Syntax Error
  736. + EOF
  737. + # Some shells (Coherent) do redirections in the wrong order, so need
  738. + # the parens.
  739. + ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"`
  740. + if test -z "$ac_err"; then
  741. +   :
  742. + else
  743. +   rm -rf conftest*
  744. +   CPP=/lib/cpp
  745. + fi
  746. + rm -f conftest*
  747. + fi
  748. + rm -f conftest*
  749. + fi
  750. + test -n "$verbose" && /bin/echo "    setting CPP to $CPP"
  751. + if test -n "$GCC"; then
  752. +   test -n "$silent" || /bin/echo "checking whether -traditional is needed"
  753. +   ac_pattern="Autoconf.*'x'"
  754. +   ac_prog='#include <sgtty.h>
  755. + Autoconf TIOCGETP'
  756. +   cat > conftest.${ac_ext} <<EOF
  757. + #include "confdefs.h"
  758. + $ac_prog
  759. + EOF
  760. + eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1"
  761. + if egrep "$ac_pattern" conftest.out >/dev/null 2>&1; then
  762. +   rm -rf conftest*
  763. +   ac_need_trad=1
  764. + fi
  765. + rm -f conftest*
  766. +   if test -z "$ac_need_trad"; then
  767. +     ac_prog='#include <termio.h>
  768. + Autoconf TCGETA'
  769. +     cat > conftest.${ac_ext} <<EOF
  770. + #include "confdefs.h"
  771. + $ac_prog
  772. + EOF
  773. + eval "$ac_cpp conftest.${ac_ext} > conftest.out 2>&1"
  774. + if egrep "$ac_pattern" conftest.out >/dev/null 2>&1; then
  775. +   rm -rf conftest*
  776. +   ac_need_trad=1
  777. + fi
  778. + rm -f conftest*
  779. +   fi
  780. +   test -n "$ac_need_trad" && CC="$CC -traditional"
  781. + fi
  782. + # Make sure to not get the incompatible SysV /etc/install and
  783. + # /usr/sbin/install, which might be in PATH before a BSD-like install,
  784. + # or the SunOS /usr/etc/install directory, or the AIX /bin/install,
  785. + # or the AFS install, which mishandles nonexistent args, or
  786. + # /usr/ucb/install on SVR4, which tries to use the nonexistent group
  787. + # `staff', or /sbin/install on IRIX which has incompatible command-line
  788. + # syntax.  Sigh.
  789. + #
  790. + #     On most BSDish systems install is in /usr/bin, not /usr/ucb
  791. + #     anyway.
  792. + # This turns out not to be true, so the mere pathname isn't an indication
  793. + # of whether the program works.  What we really need is a set of tests for
  794. + # the install program to see if it actually works in all the required ways.
  795. + #
  796. + # Avoid using ./install, which might have been erroneously created
  797. + # by make from ./install.sh.
  798. + if test -z "${INSTALL}"; then
  799. +   test -n "$silent" || /bin/echo "checking for a BSD compatible install"
  800. +   IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  801. +   for ac_dir in $PATH; do
  802. +     case "$ac_dir" in
  803. +     ''|.|/gnu/etc|/sbin|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
  804. +     *)
  805. +       # OSF1 and SCO ODT 3.0 have their own names for install.
  806. +       for ac_prog in installbsd scoinst install; do
  807. +         if test -f $ac_dir/$ac_prog; then
  808. +       if test $ac_prog = install &&
  809. +             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  810. +         # AIX install.  It has an incompatible calling convention.
  811. +         # OSF/1 installbsd also uses dspmsg, but is usable.
  812. +         :
  813. +       else
  814. +         INSTALL="$ac_dir/$ac_prog -c"
  815. +         break 2
  816. +       fi
  817. +     fi
  818. +       done
  819. +       ;;
  820. +     esac
  821. +   done
  822. +   IFS="$ac_save_ifs"
  823. + fi
  824. + if test -z "$INSTALL"; then
  825. +   # As a last resort, use the slow shell script.
  826. +   for ac_dir in ${srcdir} ${srcdir}/.. ${srcdir}/../..; do
  827. +     if test -f $ac_dir/install.sh; then
  828. +       INSTALL="$ac_dir/install.sh -c"; break
  829. +     fi
  830. +   done
  831. + fi
  832. + if test -z "$INSTALL"; then
  833. +   /bin/echo "configure: can not find install.sh in ${srcdir} or ${srcdir}/.. or ${srcdir}/../.." >&2; exit 1
  834. + fi
  835. + test -n "$verbose" && /bin/echo "    setting INSTALL to $INSTALL"
  836. + # Use test -z because SunOS4 sh mishandles ${INSTALL_PROGRAM-'${INSTALL}'}.
  837. + # It thinks the first close brace ends the variable substitution.
  838. + test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  839. + test -n "$verbose" && /bin/echo "    setting INSTALL_PROGRAM to $INSTALL_PROGRAM"
  840. + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  841. + test -n "$verbose" && /bin/echo "    setting INSTALL_DATA to $INSTALL_DATA"
  842. + # The preferred way to propogate these variables is regular @ substitutions.
  843. + if test -n "$prefix"; then
  844. +   ac_prsub="s%^prefix\\([     ]*\\)=\\([     ]*\\).*$%prefix\\1=\\2$prefix%"
  845. + else
  846. +   prefix=/usr/local
  847. + fi
  848. + if test -n "$exec_prefix"; then
  849. +   ac_prsub="$ac_prsub
  850. + s%^exec_prefix\\([     ]*\\)=\\([     ]*\\).*$%exec_prefix\\1=\\2$exec_prefix%"
  851. + else
  852. +   exec_prefix='${prefix}' # Let make expand it.
  853. + fi
  854. + # Any assignment to VPATH causes Sun make to only execute
  855. + # the first set of double-colon rules, so remove it if not needed.
  856. + # If there is a colon in the path, we need to keep it.
  857. + if test "x$srcdir" = x.; then
  858. +   ac_vpsub='/^[     ]*VPATH[     ]*=[^:]*$/d'
  859. + fi
  860. + # Quote sed substitution magic chars in DEFS.
  861. + cat >conftest.def <<EOF
  862. + $DEFS
  863. + EOF
  864. + ac_escape_ampersand_and_backslash='s%[&\\]%\\&%g'
  865. + DEFS=`sed "$ac_escape_ampersand_and_backslash" <conftest.def`
  866. + rm -f conftest.def
  867. + # Substitute for predefined variables.
  868. + trap 'rm -f config.status; exit 1' 1 2 15
  869. + /bin/echo creating config.status
  870. + # Some systems, like AmigaDOS, won't allow you to remove a script that is
  871. + # being executed, so just move it out of the way instead.
  872. + if test -f config.status; then mv config.status config.status.old; else true; fi
  873. + cat > config.status <<EOF
  874. + #!/bin/sh
  875. + # Generated automatically by configure.
  876. + # Run this file to recreate the current configuration.
  877. + # This directory was configured as follows,
  878. + # on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
  879. + #
  880. + # $0 $configure_args
  881. + ac_cs_usage="Usage: config.status [--recheck] [--version] [--help]"
  882. + for ac_option
  883. + do
  884. +   case "\$ac_option" in
  885. +   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
  886. +     /bin/echo running \${CONFIG_SHELL-/bin/sh} $0 $configure_args --no-create
  887. +     exec \${CONFIG_SHELL-/bin/sh} $0 $configure_args --no-create ;;
  888. +   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
  889. +     /bin/echo "config.status generated by autoconf version 1.11"
  890. +     exit 0 ;;
  891. +   -help | --help | --hel | --he | --h)
  892. +     /bin/echo "\$ac_cs_usage"; exit 0 ;;
  893. +   *) /bin/echo "\$ac_cs_usage"; exit 1 ;;
  894. +   esac
  895. + done
  896. + trap 'rm -f Makefile; exit 1' 1 2 15
  897. + CC='$CC'
  898. + CFLAGS='$CFLAGS'
  899. + LDFLAGS='$LDFLAGS'
  900. + CPP='$CPP'
  901. + INSTALL='$INSTALL'
  902. + INSTALL_PROGRAM='$INSTALL_PROGRAM'
  903. + INSTALL_DATA='$INSTALL_DATA'
  904. + LIBS='$LIBS'
  905. + srcdir='$srcdir'
  906. + top_srcdir='$top_srcdir'
  907. + prefix='$prefix'
  908. + exec_prefix='$exec_prefix'
  909. + DEFS='$DEFS'
  910. + ac_prsub='$ac_prsub'
  911. + ac_vpsub='$ac_vpsub'
  912. + extrasub='$extrasub'
  913. + EOF
  914. + cat >> config.status <<\EOF
  915. + ac_given_srcdir=$srcdir
  916. + CONFIG_FILES=${CONFIG_FILES-"Makefile"}
  917. + for ac_file in .. ${CONFIG_FILES}; do if test "x$ac_file" != x..; then
  918. +   # Remove last slash and all that follows it.  Not all systems have dirname.
  919. +   ac_dir=`/bin/echo $ac_file|sed 's%/[^/][^/]*$%%'`
  920. +   if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
  921. +     # The file is in a subdirectory.
  922. +     test ! -d "$ac_dir" && mkdir "$ac_dir"
  923. +     ac_dir_suffix="/$ac_dir"
  924. +   else
  925. +     ac_dir_suffix=
  926. +   fi
  927. +   # A "../" for each directory in $ac_dir_suffix.
  928. +   ac_dots=`/bin/echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
  929. +   case "$ac_given_srcdir" in
  930. +   .)  srcdir=.
  931. +       if test -z "$ac_dir_suffix"; then top_srcdir=.
  932. +       else top_srcdir=`/bin/echo $ac_dots|sed 's%/$%%'`; fi ;;
  933. +   /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
  934. +   *) # Relative path.
  935. +     srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
  936. +     top_srcdir="$ac_dots$ac_given_srcdir" ;;
  937. +   esac
  938. +   /bin/echo creating "$ac_file"
  939. +   rm -f "$ac_file"
  940. +   comment_str="Generated automatically from `/bin/echo $ac_file|sed 's|.*/||'`.in by configure."
  941. +   case "$ac_file" in
  942. +     *.c | *.h | *.C | *.cc | *.m )  /bin/echo "/* $comment_str */" > "$ac_file" ;;
  943. +     * )          /bin/echo "# $comment_str"     > "$ac_file" ;;
  944. +   esac
  945. +   sed -e "
  946. + $ac_prsub
  947. + $ac_vpsub
  948. + $extrasub
  949. + s%@CC@%$CC%g
  950. + s%@CFLAGS@%$CFLAGS%g
  951. + s%@LDFLAGS@%$LDFLAGS%g
  952. + s%@CPP@%$CPP%g
  953. + s%@INSTALL@%$INSTALL%g
  954. + s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
  955. + s%@INSTALL_DATA@%$INSTALL_DATA%g
  956. + s%@LIBS@%$LIBS%g
  957. + s%@srcdir@%$srcdir%g
  958. + s%@top_srcdir@%$top_srcdir%g
  959. + s%@prefix@%$prefix%g
  960. + s%@exec_prefix@%$exec_prefix%g
  961. + s%@DEFS@%$DEFS%
  962. + " $ac_given_srcdir/${ac_file}.in >> $ac_file
  963. + fi; done
  964. + exit 0
  965. + EOF
  966. + chmod +x config.status
  967. + # Some shells look in PATH for config.status without the "./".
  968. + test -n "$no_create" || ${CONFIG_SHELL-/bin/sh} ./config.status
  969. diff -rc --new-file binutils-1.8.x-base/configure.in binutils-1.8.x/configure.in
  970. *** binutils-1.8.x-base/configure.in    Thu Jan  1 00:00:00 1970
  971. --- binutils-1.8.x/configure.in    Sat Apr 30 17:42:42 1994
  972. ***************
  973. *** 0 ****
  974. --- 1,20 ----
  975. + dnl Process this file with autoconf to produce a configure script.
  976. + AC_INIT(ld.c)
  977. + # We want these before the checks, so the checks can modify their values.
  978. + test -z "$CFLAGS" && CFLAGS= auto_cflags=1
  979. + test -z "$LDFLAGS" && LDFLAGS=
  980. + AC_PROG_CC
  981. + # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
  982. + test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O2"
  983. + AC_SUBST(CFLAGS)dnl
  984. + AC_SUBST(LDFLAGS)dnl
  985. + AC_PROG_CPP
  986. + AC_GCC_TRADITIONAL
  987. + AC_PROG_INSTALL
  988. + AC_OUTPUT(Makefile)
  989. diff -rc --new-file binutils-1.8.x-base/cplus-dem.c binutils-1.8.x/cplus-dem.c
  990. *** binutils-1.8.x-base/cplus-dem.c    Wed Jun 13 05:42:34 1990
  991. --- binutils-1.8.x/cplus-dem.c    Wed Sep 22 12:45:32 1993
  992. ***************
  993. *** 48,54 ****
  994.   #include <ctype.h>
  995.   
  996.   #if !defined(sequent) && !defined(NeXT)
  997. ! #include <memory.h>
  998.   #else
  999.   #define memcpy(s1, s2, n) strncpy(s1, s2, n) 
  1000.   #define memcmp(s1, s2, n) strncmp(s1, s2, n)
  1001. --- 48,54 ----
  1002.   #include <ctype.h>
  1003.   
  1004.   #if !defined(sequent) && !defined(NeXT)
  1005. ! /* #include <memory.h> */
  1006.   #else
  1007.   #define memcpy(s1, s2, n) strncpy(s1, s2, n) 
  1008.   #define memcmp(s1, s2, n) strncmp(s1, s2, n)
  1009. diff -rc --new-file binutils-1.8.x-base/ld.c binutils-1.8.x/ld.c
  1010. *** binutils-1.8.x-base/ld.c    Wed Nov 27 22:04:14 1991
  1011. --- binutils-1.8.x/ld.c    Thu Mar 23 23:30:14 1995
  1012. ***************
  1013. *** 16,24 ****
  1014.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  1015.   
  1016.   /* Written by Richard Stallman with some help from Eric Albert.
  1017. !    Set, indirect, and warning symbol features added by Randy Smith.  */
  1018.   
  1019.   #include <ar.h>
  1020.   #include <stdio.h>
  1021.   #include <sys/types.h>
  1022.   #include <sys/stat.h>
  1023. --- 16,39 ----
  1024.      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  1025.   
  1026.   /* Written by Richard Stallman with some help from Eric Albert.
  1027. !    Set, indirect, and warning symbol features added by Randy Smith.
  1028. !    Support for generation of Amiga load files added by Markus Wild.
  1029. !    Flavor extension by Fred Fish
  1030. !    Modified for AmigaDOS cross-linker by Philippe Brand
  1031. !    Bug fixes by Matthias Fleischer
  1032. !    Additional work by Gunther Nikl */
  1033.   
  1034. + #ifdef amigados
  1035. + #ifndef STANDARD_SEARCH_DIRS
  1036. + #define STANDARD_SEARCH_DIRS "local:lib","local:os-lib","gnu:lib","gnu:os-lib"
  1037. + #endif
  1038. + #endif
  1039. + #if defined(amigados) && defined(CROSS_LINKER)
  1040. + #include </usr/local/amigados/include/ar.h>
  1041. + #else
  1042.   #include <ar.h>
  1043. + #endif
  1044.   #include <stdio.h>
  1045.   #include <sys/types.h>
  1046.   #include <sys/stat.h>
  1047. ***************
  1048. *** 30,35 ****
  1049. --- 45,52 ----
  1050.   #ifndef sony_news
  1051.   #include <fcntl.h>
  1052.   #endif
  1053. + /* JPB, 7 Jun 1992: MAXNAMLEN required for long name hack. */
  1054. + #include <dirent.h>
  1055.   
  1056.   #if !defined(A_OUT) && !defined(MACH_O)
  1057.   #define A_OUT
  1058. ***************
  1059. *** 39,47 ****
  1060. --- 56,99 ----
  1061.   #ifdef COFF_ENCAPSULATE
  1062.   #include "a.out.encap.h"
  1063.   #else
  1064. + #if defined(amigados) && defined(CROSS_LINKER)
  1065. + # include </usr/local/amigados/include/a.out.h>
  1066. + #else
  1067.   #include <a.out.h>
  1068.   #endif
  1069.   #endif
  1070. + #endif
  1071. + #ifdef MCH_AMIGA
  1072. + #define HUNK_INSTEAD_OF_A_OUT
  1073. + int number_of_code_hunk,
  1074. +     code_mem_type,
  1075. +     number_of_data_hunk,
  1076. +     data_mem_type,
  1077. +     number_of_bss_hunk,
  1078. +     bss_mem_type,
  1079. +     number_of_debug_hunk,
  1080. +     current_hunk = 0,
  1081. +     offset_of_debug_hunk,
  1082. +     amiga_symbols_only,
  1083. +     long_data_hunk = 1,
  1084. +     databss_together = 0,
  1085. +     numdatadata_relocs = 0,
  1086. +     output_datadata_relocs = 0,
  1087. +     datadata_relocs_offset = 0;
  1088. + #define LONGSIZE(l) ((((l) + 3) & ~3) >> 2)
  1089. + /* this is the private format of the debug-hunk: */
  1090. +    struct debug_hunk {
  1091. +      unsigned long  id;  /* Filesystem-imposed: HUNK_DEBUG (0x3f1) */
  1092. +      unsigned long  len; /* "" : length in longs -> LONGSIZE(real_lenght) */
  1093. +      /* the following part is somehow a truncated exec-struct: */
  1094. +      unsigned long  magic; /* should be ZMAGIC (just for fun:-)), to be recognised
  1095. +                 * by the other tools as this special frame */
  1096. +      unsigned long  syms;  /* size of symbol-table */
  1097. +      unsigned long  strs;  /* size of string table */
  1098. +      /* here follows the actual data */
  1099. +    } dh;
  1100. + #endif
  1101.   
  1102.   #ifdef MACH_O
  1103.   #ifndef A_OUT
  1104. ***************
  1105. *** 104,110 ****
  1106.   /* Name this program was invoked by.  */
  1107.   
  1108.   char *progname;
  1109.   /* System dependencies */
  1110.   
  1111.   /* Define this if names etext, edata and end should not start with `_'.  */
  1112. --- 156,162 ----
  1113.   /* Name this program was invoked by.  */
  1114.   
  1115.   char *progname;
  1116.   /* System dependencies */
  1117.   
  1118.   /* Define this if names etext, edata and end should not start with `_'.  */
  1119. ***************
  1120. *** 190,195 ****
  1121. --- 242,263 ----
  1122.   #endif /* mc68000.  */
  1123.   #endif /* Sun.  */
  1124.   
  1125. + #ifdef amigados
  1126. + /* same trick as with sun[23] */
  1127. + /* Set the machine type according to the machine type of the .o files.
  1128. +    If they are all sun2 (68010), then the type of the executable is sun2.
  1129. +    If any is sun3 (68020), then the type of the executable is sun3.
  1130. +    This is consistent with the Sun loader and more useful than having
  1131. +    it depend on which machine you are on when you run ld.  */
  1132. + static int amiga_machtype = MID_SUN010;
  1133. + #define INITIALIZE_HEADER outheader.a_machtype = amiga_machtype
  1134. + #define READ_HEADER_HOOK(machtype) \
  1135. +   if (machtype == MID_SUN020)        \
  1136. +     {                     \
  1137. +       amiga_machtype = MID_SUN020;   \
  1138. +     }
  1139. + #endif
  1140.   #ifdef ALTOS
  1141.   #define INITIALIZE_HEADER N_SET_MACHTYPE (outheader, M_68020)
  1142.   #endif
  1143. ***************
  1144. *** 229,234 ****
  1145. --- 297,306 ----
  1146.   #ifndef SEEK_CUR
  1147.   #define SEEK_CUR 1
  1148.   #endif
  1149. + /* Phil.B: 1-Apr-94: same trick for SEEK_END */
  1150. + #ifndef SEEK_END
  1151. + #define SEEK_END L_XTND
  1152. + #endif
  1153.   
  1154.   /*
  1155.    * Ok.  Following are the relocation information macros.  If your
  1156. ***************
  1157. *** 368,373 ****
  1158. --- 440,446 ----
  1159.   #define RELOC_MEMORY_ADD_P(r)    1
  1160.   #undef RELOC_ADD_EXTRA
  1161.   #define RELOC_PCREL_P(r)        ((r)->r_pcrel)
  1162. + #define RELOC_BASEREL_P(r)        ((r)->r_baserel)
  1163.   #define RELOC_VALUE_RIGHTSHIFT(r)    0
  1164.   #define RELOC_TARGET_SIZE(r)        ((r)->r_length)
  1165.   #define RELOC_TARGET_BITPOS(r)    0
  1166. ***************
  1167. *** 384,390 ****
  1168.   #define LPREFIX 'L'
  1169.   #endif
  1170.   
  1171.   /* Special global symbol types understood by GNU LD.  */
  1172.   
  1173.   /* The following type indicates the definition of a symbol as being
  1174. --- 457,463 ----
  1175.   #define LPREFIX 'L'
  1176.   #endif
  1177.   
  1178.   /* Special global symbol types understood by GNU LD.  */
  1179.   
  1180.   /* The following type indicates the definition of a symbol as being
  1181. ***************
  1182. *** 531,537 ****
  1183.   #endif
  1184.   
  1185.   #endif /* not __GNU_STAB__ */
  1186.   /* Symbol table */
  1187.   
  1188.   /* Global symbol data is recorded in these structures,
  1189. --- 604,610 ----
  1190.   #endif
  1191.   
  1192.   #endif /* not __GNU_STAB__ */
  1193.   /* Symbol table */
  1194.   
  1195.   /* Global symbol data is recorded in these structures,
  1196. ***************
  1197. *** 684,690 ****
  1198.   symbol *edata_symbol_alt;
  1199.   symbol *etext_symbol_alt;
  1200.   symbol *end_symbol_alt;
  1201.   /* Kinds of files potentially understood by the linker. */
  1202.   
  1203.   enum file_type { IS_UNKNOWN, IS_ARCHIVE, IS_A_OUT, IS_MACH_O };
  1204. --- 757,771 ----
  1205.   symbol *edata_symbol_alt;
  1206.   symbol *etext_symbol_alt;
  1207.   symbol *end_symbol_alt;
  1208. ! #ifdef amigados
  1209. ! symbol *sdata_symbol;    /* the symbol __sdata */
  1210. ! symbol *text_size_symbol;
  1211. ! symbol *data_size_symbol;
  1212. ! symbol *bss_size_symbol;
  1213. ! symbol *datadata_reloc_symbol = 0;
  1214. ! #endif
  1215.   /* Kinds of files potentially understood by the linker. */
  1216.   
  1217.   enum file_type { IS_UNKNOWN, IS_ARCHIVE, IS_A_OUT, IS_MACH_O };
  1218. ***************
  1219. *** 820,826 ****
  1220.   
  1221.   /* Length of that vector.  */
  1222.   int number_of_files;
  1223.   /* When loading the text and data, we can avoid doing a close
  1224.      and another open between members of the same library.
  1225.   
  1226. --- 901,907 ----
  1227.   
  1228.   /* Length of that vector.  */
  1229.   int number_of_files;
  1230.   /* When loading the text and data, we can avoid doing a close
  1231.      and another open between members of the same library.
  1232.   
  1233. ***************
  1234. *** 867,875 ****
  1235. --- 948,961 ----
  1236.   #define DEFAULT_OUTPUT_STYLE OUTPUT_DEMAND_PAGED
  1237.   #endif
  1238.   
  1239. + #if 0
  1240.   /* Descriptor for writing that file with `mywrite'.  */
  1241.   
  1242.   int outdesc;
  1243. + #endif
  1244. + /* use outstream instead of outdesc thru the whole file, it's MUCH faster.. */
  1245. + FILE *outstream = (FILE *) 0;
  1246.   
  1247.   /* The following are computed by `digest_symbols'.  */
  1248.   
  1249. ***************
  1250. *** 909,914 ****
  1251. --- 995,1004 ----
  1252.   /* Pointer for in core storage for the above vectors, before they are
  1253.      written. */
  1254.   unsigned long *set_vectors;
  1255. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1256. + /* which vector entry has to be relocated? */
  1257. + unsigned char *rel_vectors;
  1258. + #endif
  1259.   
  1260.   /* Amount of cleared space to leave at the end of the text segment.  */
  1261.   
  1262. ***************
  1263. *** 929,935 ****
  1264.     int symbol_name_string_index;
  1265.     int library_member_offset;
  1266.   };
  1267.   /* Record most of the command options.  */
  1268.   
  1269.   /* Address we assume the text section will be loaded at.
  1270. --- 1019,1025 ----
  1271.     int symbol_name_string_index;
  1272.     int library_member_offset;
  1273.   };
  1274.   /* Record most of the command options.  */
  1275.   
  1276.   /* Address we assume the text section will be loaded at.
  1277. ***************
  1278. *** 993,998 ****
  1279. --- 1083,1092 ----
  1280.   /* Length of the vector `search_dirs'.  */
  1281.   int n_search_dirs;
  1282.   
  1283. + /* Vector of flavors to search for. */
  1284. + char **flavors;
  1285. + int n_flavors;
  1286.   /* Non zero means to create the output executable.
  1287.      Cleared by nonfatal errors.  */
  1288.   int make_executable;
  1289. ***************
  1290. *** 1007,1018 ****
  1291. --- 1101,1118 ----
  1292.   struct glosym **cmdline_references;
  1293.   int cl_refs_allocated;
  1294.   
  1295. + /* JPB, 7 Jun 1992: Global variable needed for long name hack. */
  1296. + static int ar_hdr_size;
  1297.   #ifndef bcopy
  1298.   void bcopy (), bzero ();
  1299.   #endif
  1300. + #ifndef __STDC__
  1301.   char *malloc (), *realloc ();
  1302.   void free ();
  1303. + #endif
  1304.   
  1305. + char *getenv ();
  1306.   char *xmalloc ();
  1307.   char *xrealloc ();
  1308.   void usage ();
  1309. ***************
  1310. *** 1034,1039 ****
  1311. --- 1134,1154 ----
  1312.   void write_output ();
  1313.   void write_header ();
  1314.   void write_text ();
  1315. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1316. + void write_datadata_relocs ();
  1317. + void write_hunk_header ();
  1318. + void conditionally_rewrite_headers ();
  1319. + void write_bss ();
  1320. + void init_reloc_hunk ();
  1321. + void add_to_reloc_hunk ();
  1322. + void write_reloc_hunk ();
  1323. + void init_symbol_hunks ();
  1324. + void add_to_symbol_hunk ();
  1325. + void write_symbol_hunk ();
  1326. + void look_for_symbols ();
  1327. + void look_for_file_symbols ();
  1328. + void relocate_set_vectors ();
  1329. + #endif
  1330.   void read_file_relocation ();
  1331.   void write_data ();
  1332.   void write_rel ();
  1333. ***************
  1334. *** 1045,1060 ****
  1335.   char *concat ();
  1336.   char *get_file_name ();
  1337.   symbol *getsym (), *getsym_soft ();
  1338.   int
  1339.   main (argc, argv)
  1340.        char **argv;
  1341.        int argc;
  1342.   {
  1343.     page_size = getpagesize ();
  1344.     progname = argv[0];
  1345.   
  1346. ! #ifdef RLIMIT_STACK
  1347.     /* Avoid dumping core on large .o files.  */
  1348.     {
  1349.       struct rlimit rl;
  1350. --- 1160,1187 ----
  1351.   char *concat ();
  1352.   char *get_file_name ();
  1353.   symbol *getsym (), *getsym_soft ();
  1354. ! int compare_longs (), compare_strings ();
  1355.   int
  1356.   main (argc, argv)
  1357.        char **argv;
  1358.        int argc;
  1359.   {
  1360. + /* Phil.B 09-Jul-94: use 4KB as page size in order to be compatible with Gigamem
  1361. +    although getpagesize() is present in ixemul.library, we want to compile
  1362. +    without it */
  1363. + #ifdef amigados
  1364. +   page_size = 4096;
  1365. + #else
  1366.     page_size = getpagesize ();
  1367. + #endif
  1368.     progname = argv[0];
  1369.   
  1370. ! /* Phil.B 09-Jul-94: amigados doesn't have stack growing so this is not
  1371. !    necessary and more than that disable ld to be compiled using libnix
  1372. !    BTW as for now those functions returns 0 in  ixemul.library.
  1373. !    That's emulation! ;-) */
  1374. ! #if defined(RLIMIT_STACK) && !defined(amigados)
  1375.     /* Avoid dumping core on large .o files.  */
  1376.     {
  1377.       struct rlimit rl;
  1378. ***************
  1379. *** 1090,1095 ****
  1380. --- 1217,1225 ----
  1381.     make_executable = 1;
  1382.     force_executable = 0;
  1383.     set_element_prefixes = 0;
  1384. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1385. +   amiga_symbols_only = 1;
  1386. + #endif
  1387.   
  1388.     /* Initialize the cumulative counts of symbols.  */
  1389.   
  1390. ***************
  1391. *** 1148,1158 ****
  1392.   
  1393.     exit (!make_executable);
  1394.   }
  1395.   void add_cmdline_ref ();
  1396.   
  1397.   static struct option longopts[] =
  1398.   {
  1399.     {"d", 0, 0, 'd'},
  1400.     {"dc", 0, 0, 'd'},        /* For Sun compatibility. */
  1401.     {"dp", 0, 0, 'd'},        /* For Sun compatibility. */
  1402. --- 1278,1318 ----
  1403.   
  1404.     exit (!make_executable);
  1405.   }
  1406. ! #ifdef amigados
  1407. ! /* support hunk loading to a chip or fast memory */
  1408. ! void set_mem_type(char *argstr, int memtype)
  1409. ! {
  1410. !    static char memstr[]="cdb";
  1411. !    if (!argstr)
  1412. !      argstr=memstr;
  1413. !    if (strchr(argstr,'c')||strchr(argstr,'t'))
  1414. !      code_mem_type=memtype;
  1415. !    if (strchr(argstr,'d'))
  1416. !      data_mem_type=memtype;
  1417. !    if (strchr(argstr,'b'))
  1418. !      bss_mem_type=memtype;
  1419. ! }
  1420. ! #endif
  1421.   void add_cmdline_ref ();
  1422.   
  1423.   static struct option longopts[] =
  1424.   {
  1425. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1426. +   {"amiga-debug-hunk", 0, 0, 'a'},
  1427. +   {"databss-together", 0, 0, 'b'},
  1428. +   {"datadata-reloc", 0, 0, 'c'},
  1429. +   {"msmall-code", 0, 0, 129},        /* ignore.. */
  1430. +   {"flavor", 1, 0, 'f'},
  1431. +   {"chip",2, 0, 'g'},
  1432. +   {"fast",2, 0, 'h'},
  1433. +   {"shortdata", 0, 0, 'm'},
  1434. + #endif
  1435.     {"d", 0, 0, 'd'},
  1436.     {"dc", 0, 0, 'd'},        /* For Sun compatibility. */
  1437.     {"dp", 0, 0, 'd'},        /* For Sun compatibility. */
  1438. ***************
  1439. *** 1207,1212 ****
  1440. --- 1367,1385 ----
  1441.     /* First compute number_of_files so we know how long to make file_table.
  1442.        Also process most options completely.  */
  1443.   
  1444. + #ifdef amigados
  1445. +   /* Phil.B: 27-Feb-94 default is to strip all symbols if LDSTRIP is set */
  1446. +   if (getenv("LDSTRIP"))
  1447. +     strip_symbols = STRIP_ALL;
  1448. +   /* G.Nikl: 10-Jun-94 if LDSHORTDATA is found a "short" data hunk will be
  1449. +      created. bss will be allocated via the hunk header. default is to dump
  1450. +      the bss part in the data area as zeros */
  1451. +   if (getenv("LDSHORTDATA"))
  1452. +     long_data_hunk = 0;
  1453. + #endif /* amigados */
  1454.     while ((optc = getopt_long_only (argc, argv, SHORTOPTS, longopts, &longind))
  1455.        != EOF)
  1456.       {
  1457. ***************
  1458. *** 1224,1229 ****
  1459. --- 1397,1416 ----
  1460.         number_of_files++;
  1461.         break;
  1462.   
  1463. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1464. +     case 'a':
  1465. +       amiga_symbols_only = 0;
  1466. +       break;
  1467. +     case 'b':
  1468. +       databss_together = 1;
  1469. +       break;
  1470. +     case 'c':
  1471. +       output_datadata_relocs = 1;
  1472. +       break;
  1473. + #endif
  1474.       case 'd':
  1475.         force_common_definition = 1;
  1476.         break;
  1477. ***************
  1478. *** 1236,1245 ****
  1479. --- 1423,1451 ----
  1480.         add_cmdline_ref (entry_symbol);
  1481.         break;
  1482.   
  1483. +     case 'f':
  1484. +       n_flavors++;
  1485. +       flavors = (char **) xrealloc (flavors, n_flavors * sizeof (char *));
  1486. +       flavors[n_flavors - 1] = optarg;
  1487. +       break;
  1488. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1489. +     case 'g':
  1490. +       set_mem_type(optarg,1<<30);
  1491. +       break;
  1492. +     case 'h':
  1493. +       set_mem_type(optarg,2<<30);
  1494. +       break;
  1495. + #endif
  1496.       case 'l':
  1497.         number_of_files++;
  1498.         break;
  1499.   
  1500. +     case 'm':
  1501. +       long_data_hunk = 0;
  1502. +       break;
  1503.       case 'n':
  1504.         if (output_style && output_style != OUTPUT_READONLY_TEXT)
  1505.           fatal ("illegal combination of -n with -N, -r, or -z", (char *) 0);
  1506. ***************
  1507. *** 1363,1368 ****
  1508. --- 1569,1584 ----
  1509.       }
  1510.       }
  1511.   
  1512. +   if (n_flavors > 1)
  1513. +     {
  1514. +       register int i;
  1515. +       if (trace_files)
  1516. +         for (i=0; i<n_flavors; i++)
  1517. +       fprintf (stderr, "Flavor #%d : %s\n", i, flavors[i]);
  1518. +       qsort (flavors, n_flavors, sizeof (char *), compare_strings);
  1519. +     }
  1520.     if (!number_of_files)
  1521.       usage ("no input files", 0);
  1522.   
  1523. ***************
  1524. *** 1433,1439 ****
  1525.            n * sizeof (char *));
  1526.       }
  1527.   }
  1528.   
  1529.   void
  1530.   add_cmdline_ref (sp)
  1531. --- 1649,1655 ----
  1532.            n * sizeof (char *));
  1533.       }
  1534.   }
  1535.   
  1536.   void
  1537.   add_cmdline_ref (sp)
  1538. ***************
  1539. *** 1478,1484 ****
  1540.       }
  1541.     return 0;
  1542.   }
  1543.   /* Convenient functions for operating on one or all files being
  1544.      loaded.  */
  1545.   void print_file_name ();
  1546. --- 1694,1700 ----
  1547.       }
  1548.     return 0;
  1549.   }
  1550.   /* Convenient functions for operating on one or all files being
  1551.      loaded.  */
  1552.   void print_file_name ();
  1553. ***************
  1554. *** 1602,1609 ****
  1555.   
  1556.         for (i = 0; i < n_search_dirs; i++)
  1557.       {
  1558. !       register char *string
  1559. !         = concat (search_dirs[i], "/", entry->filename);
  1560.         desc = open (string, O_RDONLY, 0);
  1561.         if (desc > 0)
  1562.           {
  1563. --- 1818,1836 ----
  1564.   
  1565.         for (i = 0; i < n_search_dirs; i++)
  1566.       {
  1567. !       register char *string;
  1568. !       string = search_dirs[i];
  1569. !       if (n_flavors > 0)
  1570. !         {
  1571. !           int count;
  1572. !           for (count = 0; count < n_flavors; count++)
  1573. !         {
  1574. !           string = concat (string, "/", flavors[count]);
  1575. !         }
  1576. !         }
  1577. !       string = concat (string, "/", entry->filename);
  1578. !       if (trace_files) fprintf (stderr, "Look for %s\n", string);
  1579.         desc = open (string, O_RDONLY, 0);
  1580.         if (desc > 0)
  1581.           {
  1582. ***************
  1583. *** 1613,1618 ****
  1584. --- 1840,1880 ----
  1585.           }
  1586.         free (string);
  1587.       }
  1588. +       /* Phil.B 30-Jul-94 if we couldn't find file using serch_dirs
  1589. +      then we try removing trailing path one by one */
  1590. +       if ((desc <= 0) && (n_flavors > 0))
  1591. +     {
  1592. +           if (trace_files) fprintf (stderr, "Climbing into flavors\n");
  1593. +           for (i = 0; i < n_search_dirs; i++)
  1594. +         {
  1595. +           register int j;
  1596. +           register char *string;
  1597. +           for (j = n_flavors; j >= 0; j--)
  1598. +                 {
  1599. +                   int count;
  1600. +               string = search_dirs[i];
  1601. +           /* Phil.B 29-Jul-94 Special condition is made so that
  1602. +              if j = 0 we don't copy flavor because we want to test
  1603. +              search path without any flavor added. */
  1604. +               for (count = 1; count <= j ; count++)
  1605. +             {
  1606. +               string = concat (string, "/", flavors[count-1]);
  1607. +             }
  1608. +               string = concat (string, "/", entry->filename);
  1609. +               if (trace_files) fprintf (stderr, "Look for %s\n", string);
  1610. +               desc = open (string, O_RDONLY, 0);
  1611. +               if (desc > 0)
  1612. +                 {
  1613. +                   entry->filename = string;
  1614. +                   entry->search_dirs_flag = 0;
  1615. +                   break;
  1616. +                 }
  1617. +               free (string);
  1618. +                 }
  1619. +           if (desc > 0) break;
  1620. +         }
  1621. +         }
  1622.       }
  1623.     else
  1624.       desc = open (entry->filename, O_RDONLY, 0);
  1625. ***************
  1626. *** 1678,1684 ****
  1627.       }
  1628.     return result;
  1629.   }
  1630.   /* Medium-level input routines for rel files.  */
  1631.   
  1632.   /* Determine whether the given ENTRY is an archive, a BSD a.out file,
  1633. --- 1940,1946 ----
  1634.       }
  1635.     return result;
  1636.   }
  1637.   /* Medium-level input routines for rel files.  */
  1638.   
  1639.   /* Determine whether the given ENTRY is an archive, a BSD a.out file,
  1640. ***************
  1641. *** 2044,2050 ****
  1642.     if (entry->strs_size != read (desc, entry->strings, entry->strs_size))
  1643.       fatal_with_file ("premature end of file in strings of ", entry);
  1644.   }
  1645.   /* Read in the symbols of all input files.  */
  1646.   
  1647.   void read_file_symbols (), read_entry_symbols (), read_entry_strings ();
  1648. --- 2306,2312 ----
  1649.     if (entry->strs_size != read (desc, entry->strings, entry->strs_size))
  1650.       fatal_with_file ("premature end of file in strings of ", entry);
  1651.   }
  1652.   /* Read in the symbols of all input files.  */
  1653.   
  1654.   void read_file_symbols (), read_entry_symbols (), read_entry_strings ();
  1655. ***************
  1656. *** 2097,2103 ****
  1657.   
  1658.     file_close ();
  1659.   }
  1660.   /* Enter the external symbol defs and refs of ENTRY in the hash table.  */
  1661.   
  1662.   void
  1663. --- 2359,2365 ----
  1664.   
  1665.     file_close ();
  1666.   }
  1667.   /* Enter the external symbol defs and refs of ENTRY in the hash table.  */
  1668.   
  1669.   void
  1670. ***************
  1671. *** 2120,2125 ****
  1672. --- 2382,2397 ----
  1673.         if (SET_ELEMENT_P (p->n_type))
  1674.       {
  1675.         set_symbol_count++;
  1676. + /* Matthias Fleischer 25-Apr-94: fix bug in ld that prevents
  1677. +    symboltables for objects in the data hunk from working. */
  1678. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1679. +         /* Count pointers in the symbol table, too */
  1680. +       if ((p->n_type&~N_EXT)==N_SETD||
  1681. +               (p->n_type&~N_EXT)==N_SETB)
  1682. +         numdatadata_relocs++;
  1683. + #endif
  1684.         if (output_style != OUTPUT_RELOCATABLE)
  1685.           enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
  1686.       }
  1687. ***************
  1688. *** 2165,2170 ****
  1689. --- 2437,2448 ----
  1690.   
  1691.     local_sym_count++;
  1692.     non_L_local_sym_count++;
  1693. + #if 0
  1694. +   if (trace_files)
  1695. +     fprintf (stderr, "%d local syms, %d debug syms, %d gbl refs, %d gbl defs\n",
  1696. +          local_sym_count, debugger_sym_count, undefined_global_sym_count,
  1697. +          defined_global_sym_count);
  1698. + #endif
  1699.   }
  1700.   
  1701.   /* Enter one global symbol in the hash table.
  1702. ***************
  1703. *** 2375,2381 ****
  1704.     return 0;
  1705.   }
  1706.   
  1707.   /* Searching libraries */
  1708.   
  1709.   struct file_entry *decode_library_subfile ();
  1710. --- 2653,2659 ----
  1711.     return 0;
  1712.   }
  1713.   
  1714.   /* Searching libraries */
  1715.   
  1716.   struct file_entry *decode_library_subfile ();
  1717. ***************
  1718. *** 2452,2459 ****
  1719. --- 2730,2762 ----
  1720.          && hdr1.ar_name[namelen] != '/';
  1721.          namelen++);
  1722.   
  1723. + /* JPB, 7 Jun 1992: Support for long file names. Set the global variable
  1724. +                     ar_hdr_size to the real length of the header.
  1725. +                     The code for extracting the long name is pretty much stolen
  1726. +                     from the BSD ar (archive.c, version 5.7).
  1727. +                     This is a *really* ugly hack!
  1728. + */
  1729. + #if 1
  1730. +   ar_hdr_size = sizeof(struct ar_hdr);
  1731. +   if (!bcmp(hdr1.ar_name,AR_EFMT1,sizeof(AR_EFMT1) -1))
  1732. +   {
  1733. +     namelen = atoi(hdr1.ar_name + sizeof(AR_EFMT1) -1);
  1734. +     if (namelen <= 0 || namelen > MAXNAMLEN)
  1735. +       fatal_with_file("malformatted long name of archive member in ",library_entry);
  1736. +     ar_hdr_size += namelen;
  1737. +     name = (char *) xmalloc (namelen+1);
  1738. +     if (read(desc,name,namelen) != namelen)
  1739. +       fatal_with_file("malformatted long name of archive member in ",library_entry);
  1740. +   }
  1741. +   else
  1742. +   {
  1743. +     name = (char *) xmalloc (namelen+1);
  1744. +     strncpy (name, hdr1.ar_name, namelen);
  1745. +   }
  1746. + #else
  1747.     name = (char *) xmalloc (namelen+1);
  1748.     strncpy (name, hdr1.ar_name, namelen);
  1749. + #endif
  1750.     name[namelen] = 0;
  1751.   
  1752.     subentry->filename = name;
  1753. ***************
  1754. *** 2461,2467 ****
  1755. --- 2764,2774 ----
  1756.     subentry->symbols = 0;
  1757.     subentry->strings = 0;
  1758.     subentry->subfiles = 0;
  1759. + #if 1
  1760. +   subentry->starting_offset = subfile_offset + ar_hdr_size;
  1761. + #else
  1762.     subentry->starting_offset = subfile_offset + sizeof hdr1;
  1763. + #endif
  1764.     subentry->superfile = library_entry;
  1765.     subentry->library_flag = 0;
  1766.     subentry->header_read_flag = 0;
  1767. ***************
  1768. *** 2473,2479 ****
  1769.   
  1770.     return subentry;
  1771.   }
  1772.   int subfile_wanted_p ();
  1773.   
  1774.   /* Search a library that has a __.SYMDEF member.
  1775. --- 2780,2786 ----
  1776.   
  1777.     return subentry;
  1778.   }
  1779.   int subfile_wanted_p ();
  1780.   
  1781.   /* Search a library that has a __.SYMDEF member.
  1782. ***************
  1783. *** 2622,2628 ****
  1784.   
  1785.     free (symdef_data);
  1786.   }
  1787.   
  1788.   /* Handle a subentry for a file with no __.SYMDEF. */
  1789.   
  1790. --- 2929,2935 ----
  1791.   
  1792.     free (symdef_data);
  1793.   }
  1794.   
  1795.   /* Handle a subentry for a file with no __.SYMDEF. */
  1796.   
  1797. ***************
  1798. *** 2675,2685 ****
  1799.         if (!subentry) return;
  1800.   
  1801.         process_subentry (desc, subentry, entry, &prev);
  1802.         this_subfile_offset += member_length + sizeof (struct ar_hdr);
  1803.         if (this_subfile_offset & 1) this_subfile_offset++;
  1804.       }
  1805.   }
  1806.   /* ENTRY is an entry for a library member.
  1807.      Its symbols have been read into core, but not entered.
  1808.      Return nonzero if we ought to load this member.  */
  1809. --- 2982,3000 ----
  1810.         if (!subentry) return;
  1811.   
  1812.         process_subentry (desc, subentry, entry, &prev);
  1813. + #if 1
  1814. + /* JPB, 7 Jun 1992: Can't count on sizeof(ar_hdr) to be the size of the entire
  1815. +                     header: Long names extends the header. This is a *really*
  1816. +                     ugly hack, using a global variable! */
  1817. +       this_subfile_offset += member_length + ar_hdr_size;
  1818. + #else
  1819.         this_subfile_offset += member_length + sizeof (struct ar_hdr);
  1820. + #endif
  1821.         if (this_subfile_offset & 1) this_subfile_offset++;
  1822.       }
  1823.   }
  1824.   /* ENTRY is an entry for a library member.
  1825.      Its symbols have been read into core, but not entered.
  1826.      Return nonzero if we ought to load this member.  */
  1827. ***************
  1828. *** 2777,2783 ****
  1829.   
  1830.     return 0;
  1831.   }
  1832.   void consider_file_section_lengths (), relocate_file_addresses ();
  1833.   
  1834.   /* Having entered all the global symbols and found the sizes of sections
  1835. --- 3092,3098 ----
  1836.   
  1837.     return 0;
  1838.   }
  1839.   void consider_file_section_lengths (), relocate_file_addresses ();
  1840.   
  1841.   /* Having entered all the global symbols and found the sizes of sections
  1842. ***************
  1843. *** 2800,2806 ****
  1844. --- 3115,3125 ----
  1845.   
  1846.     initialize_text_start ();
  1847.   
  1848. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1849. +   text_size = 0;
  1850. + #else
  1851.     text_size = text_header_size;
  1852. + #endif
  1853.   
  1854.     /* Compute total size of sections */
  1855.   
  1856. ***************
  1857. *** 2809,2825 ****
  1858. --- 3128,3164 ----
  1859.     /* If necessary, pad text section to full page in the file.
  1860.        Include the padding in the text segment size.  */
  1861.   
  1862. + #ifndef HUNK_INSTEAD_OF_A_OUT
  1863.     if (output_style == OUTPUT_READONLY_TEXT || output_style == OUTPUT_DEMAND_PAGED)
  1864.       {
  1865.         text_pad = ((text_size + page_size - 1) & (- page_size)) - text_size;
  1866.         text_size += text_pad;
  1867.       }
  1868. + #endif
  1869. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1870. +   /* they go into text if they are required */
  1871. +   if (output_datadata_relocs && numdatadata_relocs)
  1872. +     {
  1873. +       if (datadata_reloc_symbol)
  1874. +         datadata_reloc_symbol->value = text_size;
  1875. +       
  1876. +       /* 1 long for the size, then the vector */
  1877. +       text_size += (1 + numdatadata_relocs) * 4;
  1878. +     }
  1879. + #endif
  1880.   
  1881.     /* Now that the text_size is known, initialize the data start address;
  1882.        this depends on text_size as well as the output file format.  */
  1883.   
  1884.     initialize_data_start ();
  1885.   
  1886. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1887. +   data_pad = 0;
  1888. + #endif
  1889. + #ifndef HUNK_INSTEAD_OF_A_OUT
  1890.     /* Make sure bss starts out aligned as much as anyone can want.  */
  1891.     {
  1892.       int new_data_size = (data_size + sizeof(double) - 1) & ~(sizeof(double)-1);
  1893. ***************
  1894. *** 2827,2832 ****
  1895. --- 3166,3172 ----
  1896.       data_pad += new_data_size - data_size;
  1897.       data_size = new_data_size;
  1898.     }
  1899. + #endif
  1900.   
  1901.     /* Set up the set element vector */
  1902.   
  1903. ***************
  1904. *** 2836,2846 ****
  1905. --- 3176,3196 ----
  1906.            for each symbol for the length word at the beginning of the
  1907.        vector, plus a word for each symbol for a zero at the end of
  1908.        the vector (for incremental linking).  */
  1909. + #if 0
  1910. +       /* I think this is the other way round !? ### mw */
  1911.         set_sect_size
  1912.       = (2 * set_symbol_count + set_vector_count) * sizeof (unsigned long);
  1913. + #else
  1914. +       set_sect_size
  1915. +     = (2 * set_vector_count + set_symbol_count) * sizeof (unsigned long);
  1916. + #endif
  1917.         set_sect_start = data_start + data_size;
  1918.         data_size += set_sect_size;
  1919.         set_vectors = (unsigned long *) xmalloc (set_sect_size);
  1920. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1921. +       rel_vectors = (unsigned char *) xmalloc (set_sect_size/sizeof(unsigned long));
  1922. + #endif
  1923.         setv_fill_count = 0;
  1924.       }
  1925.   
  1926. ***************
  1927. *** 2888,2894 ****
  1928. --- 3238,3260 ----
  1929.                 sp->multiply_defined = 1;
  1930.                 multiple_def_count++;
  1931.               }
  1932. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1933. +           /* don't relocate absolute symbols in sets */
  1934. +           rel_vectors[setv_fill_count] = ( ((type & ~N_EXT) != N_SETA) );
  1935. +           /* Matthias Fleischer 25-Apr-94: fix bug in ld that prevents
  1936. +              symboltables for objects in the data hunk from working. */
  1937. +           /* This is some kind of hack, but doing this cleaner would be 
  1938. +              much more complicated */
  1939. +           set_vectors[setv_fill_count++] = p->n_value
  1940. +             +( (type & ~N_EXT) == N_SETD ? text_size : 0 )
  1941. +             +( (type & ~N_EXT) == N_SETB ? data_size : 0 );
  1942. + #else          
  1943.             set_vectors[setv_fill_count++] = p->n_value;
  1944. + #endif
  1945.           }
  1946.             else if ((type & N_EXT) && type != (N_UNDF | N_EXT))
  1947.           {
  1948. ***************
  1949. *** 2931,2937 ****
  1950. --- 3297,3309 ----
  1951.                     + (align - 1)) & (- align))
  1952.                     - data_size - data_start);
  1953.   
  1954. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1955. +           sp->value = bss_size;
  1956. +           if (databss_together)
  1957. +             sp->value += data_start + data_size;
  1958. + #else
  1959.             sp->value = data_start + data_size + bss_size;
  1960. + #endif
  1961.             sp->defined = N_BSS | N_EXT;
  1962.             bss_size += com;
  1963.             if (write_map)
  1964. ***************
  1965. *** 2951,2956 ****
  1966. --- 3323,3329 ----
  1967.             unsigned long length_word_index
  1968.           = (sp->value - set_sect_start) / sizeof (unsigned long);
  1969.             unsigned long i, tmp;
  1970. +           unsigned char tmp2;
  1971.   
  1972.             set_vectors[length_word_index]
  1973.           = setv_fill_count - 1 - length_word_index;
  1974. ***************
  1975. *** 2964,2969 ****
  1976. --- 3337,3349 ----
  1977.             set_vectors[length_word_index + i]
  1978.               = set_vectors[setv_fill_count - i];
  1979.             set_vectors[setv_fill_count - i] = tmp;
  1980. + #ifdef HUNK_INSTEAD_OF_A_OUT
  1981. +           /* reverse relocation vector too! */
  1982. +           tmp2 = rel_vectors[length_word_index + i];
  1983. +           rel_vectors[length_word_index + i]
  1984. +             = rel_vectors[setv_fill_count - i];
  1985. +           rel_vectors[setv_fill_count - i] = tmp2;
  1986. + #endif
  1987.           }
  1988.   
  1989.             set_vectors[setv_fill_count++] = 0;
  1990. ***************
  1991. *** 2994,2999 ****
  1992. --- 3374,3392 ----
  1993.         etext_symbol_alt->value = etext_value;
  1994.     }
  1995.   
  1996. + #ifdef amigados
  1997. +   {
  1998. +     if (sdata_symbol)
  1999. +       sdata_symbol->value = data_start;
  2000. +     if (text_size_symbol)
  2001. +       text_size_symbol->value = text_size;
  2002. +     if (data_size_symbol)
  2003. +       data_size_symbol->value = data_size;
  2004. +     if (bss_size_symbol)
  2005. +       bss_size_symbol->value  = bss_size;
  2006. +   }
  2007. + #endif
  2008.     {
  2009.       int edata_value = data_start + data_size;
  2010.       if (edata_symbol)
  2011. ***************
  2012. *** 3013,3021 ****
  2013. --- 3406,3416 ----
  2014.       if (specified_data_size && specified_data_size > data_size)
  2015.         data_pad_additional = specified_data_size - data_size;
  2016.   
  2017. + #ifndef HUNK_INSTEAD_OF_A_OUT
  2018.       if (output_style == OUTPUT_DEMAND_PAGED)
  2019.         data_pad_additional =
  2020.       ((data_pad_additional + data_size + page_size - 1) & (- page_size)) - data_size;
  2021. + #endif
  2022.   
  2023.       bss_size -= data_pad_additional;
  2024.       if (bss_size < 0) bss_size = 0;
  2025. ***************
  2026. *** 3024,3031 ****
  2027.   
  2028.       data_pad += data_pad_additional;
  2029.     }
  2030.   }
  2031.   /* Accumulate the section sizes of input file ENTRY
  2032.      into the section sizes of the output file.  */
  2033.   
  2034. --- 3419,3462 ----
  2035.   
  2036.       data_pad += data_pad_additional;
  2037.     }
  2038. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2039. +   /* if there is some code, assign it next hunk_number */
  2040. +   if (text_size)
  2041. +      number_of_code_hunk = current_hunk++;
  2042. +   else
  2043. +      number_of_code_hunk = -1;
  2044. +   if (data_size)
  2045. +      number_of_data_hunk = current_hunk++;
  2046. +   else
  2047. +      number_of_data_hunk = -1;
  2048. +   if (bss_size)
  2049. +      number_of_bss_hunk  = current_hunk++;
  2050. +   else
  2051. +      number_of_bss_hunk  = -1;
  2052. +   if (databss_together)
  2053. +     {
  2054. +       if (data_size && bss_size)
  2055. +     {
  2056. +       current_hunk --;
  2057. +       number_of_bss_hunk = number_of_data_hunk;
  2058. +     }
  2059. +     }
  2060. +   if (strip_symbols != STRIP_ALL && !amiga_symbols_only)
  2061. +      number_of_debug_hunk = current_hunk++;
  2062. +   else
  2063. +      number_of_debug_hunk = -1;
  2064. +   if (trace_files)
  2065. +     fprintf (stderr, "text hunk %d, data hunk %d, bss hunk %d, debug hunk %d\n",
  2066. +          number_of_code_hunk, number_of_data_hunk, number_of_bss_hunk,
  2067. +          number_of_debug_hunk);
  2068. + #endif
  2069.   }
  2070.   /* Accumulate the section sizes of input file ENTRY
  2071.      into the section sizes of the output file.  */
  2072.   
  2073. ***************
  2074. *** 3046,3051 ****
  2075. --- 3477,3506 ----
  2076.   
  2077.     text_reloc_size += entry->text_reloc_size;
  2078.     data_reloc_size += entry->data_reloc_size;
  2079. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2080. +   if (! output_datadata_relocs)
  2081. +     return;
  2082. +   /* have to guess at how many datadata-relocs we might have. This number
  2083. +      is larger than the real thing, because I have to include the references
  2084. +      to UNDF symbols as well. */
  2085. +   {
  2086. +     struct relocation_info *r, *re, *reloc;
  2087. +     int desc = file_open (entry);
  2088. +     reloc = (struct relocation_info *) alloca (entry->data_reloc_size);
  2089. +     lseek (desc, entry->starting_offset + entry->data_reloc_offset, L_SET);
  2090. +     if (entry->data_reloc_size != read (desc, reloc, entry->data_reloc_size))
  2091. +       fatal_with_file ("premature eof in data relocation of ", entry);
  2092. +     
  2093. +     for (r = reloc, re = reloc + entry->data_reloc_size/sizeof(*re); r < re; r++)
  2094. +       if (RELOC_EXTERN_P (r) || ((RELOC_TYPE (r) & N_TYPE) != N_TEXT))
  2095. +     numdatadata_relocs ++;
  2096. +     file_close ();
  2097. +   }
  2098. + #endif
  2099.   }
  2100.   
  2101.   /* Determine where the sections of ENTRY go into the output file,
  2102. ***************
  2103. *** 3062,3068 ****
  2104.        for the portion of data_pad which overlaps with bss.  If they had
  2105.        been, we would get the wrong results here.  */
  2106.     entry->data_start_address += data_start;
  2107. !   entry->bss_start_address += data_start + data_size;
  2108.   
  2109.     {
  2110.       register struct nlist *p;
  2111. --- 3517,3528 ----
  2112.        for the portion of data_pad which overlaps with bss.  If they had
  2113.        been, we would get the wrong results here.  */
  2114.     entry->data_start_address += data_start;
  2115. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2116. !   if (databss_together)
  2117. ! #endif
  2118. !     entry->bss_start_address += data_start + data_size;
  2119.   
  2120.     {
  2121.       register struct nlist *p;
  2122. ***************
  2123. *** 3080,3087 ****
  2124.         case N_SETT:
  2125.           p->n_value += entry->text_start_address - entry->orig_text_address;
  2126.           break;
  2127. -       case N_DATA:
  2128.         case N_SETV:
  2129.         case N_SETD:
  2130.           /* Data segment symbol.  Subtract the address of the
  2131.              data segment in the input file, and add the address
  2132. --- 3540,3547 ----
  2133.         case N_SETT:
  2134.           p->n_value += entry->text_start_address - entry->orig_text_address;
  2135.           break;
  2136.         case N_SETV:
  2137. +       case N_DATA:
  2138.         case N_SETD:
  2139.           /* Data segment symbol.  Subtract the address of the
  2140.              data segment in the input file, and add the address
  2141. ***************
  2142. *** 3098,3104 ****
  2143.         }
  2144.     }
  2145.   }
  2146.   void describe_file_sections (), list_file_locals ();
  2147.   
  2148.   /* Print a complete or partial map of the output file.  */
  2149. --- 3558,3564 ----
  2150.         }
  2151.     }
  2152.   }
  2153.   void describe_file_sections (), list_file_locals ();
  2154.   
  2155.   /* Print a complete or partial map of the output file.  */
  2156. ***************
  2157. *** 3174,3180 ****
  2158.     entry->strings = 0;        /* All done with them.  */
  2159.   }
  2160.   
  2161.   /* Static vars for do_warnings and subroutines of it */
  2162.   int list_unresolved_refs;    /* List unresolved refs */
  2163.   int list_warning_symbols;    /* List warning syms */
  2164. --- 3634,3640 ----
  2165.     entry->strings = 0;        /* All done with them.  */
  2166.   }
  2167.   
  2168.   /* Static vars for do_warnings and subroutines of it */
  2169.   int list_unresolved_refs;    /* List unresolved refs */
  2170.   int list_warning_symbols;    /* List warning syms */
  2171. ***************
  2172. *** 3192,3198 ****
  2173.     struct nlist *sym;
  2174.   };
  2175.   
  2176. - void qsort ();
  2177.   /*
  2178.    * Helper routines for do_file_warnings.
  2179.    */
  2180. --- 3652,3657 ----
  2181. ***************
  2182. *** 3672,3678 ****
  2183.     free (data_scan);
  2184.     entry->strings = 0;        /* Since it will dissapear anyway.  */
  2185.   }
  2186.   do_warnings (outfile)
  2187.        FILE *outfile;
  2188.   {
  2189. --- 4131,4137 ----
  2190.     free (data_scan);
  2191.     entry->strings = 0;        /* Since it will dissapear anyway.  */
  2192.   }
  2193.   do_warnings (outfile)
  2194.        FILE *outfile;
  2195.   {
  2196. ***************
  2197. *** 3691,3697 ****
  2198.     if (list_unresolved_refs || list_multiple_defs)
  2199.       make_executable = 0;
  2200.   }
  2201.   #ifdef A_OUT
  2202.   
  2203.   /* Stuff pertaining to creating a.out files. */
  2204. --- 4150,4156 ----
  2205.     if (list_unresolved_refs || list_multiple_defs)
  2206.       make_executable = 0;
  2207.   }
  2208.   #ifdef A_OUT
  2209.   
  2210.   /* Stuff pertaining to creating a.out files. */
  2211. ***************
  2212. *** 3712,3717 ****
  2213. --- 4171,4181 ----
  2214.   {
  2215.     int magic;
  2216.   
  2217. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2218. +   text_start = 0;
  2219. +   return;
  2220. + #endif
  2221.     switch (output_style)
  2222.       {
  2223.       case OUTPUT_RELOCATABLE:
  2224. ***************
  2225. *** 3770,3775 ****
  2226. --- 4234,4244 ----
  2227.   void
  2228.   initialize_a_out_data_start ()
  2229.   {
  2230. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2231. +   data_start = 0;
  2232. +   return;
  2233. + #endif
  2234.     outheader.a_text = text_size;
  2235.   #ifdef sequent
  2236.     outheader.a_text += N_ADDRADJ (outheader);
  2237. ***************
  2238. *** 3923,3947 ****
  2239.   void
  2240.   write_a_out_header ()
  2241.   {
  2242. !   lseek (outdesc, 0L, 0);
  2243.   
  2244.   #ifdef COFF_ENCAPSULATE
  2245.     if (need_coff_header)
  2246. !     mywrite (&coffheader, sizeof coffheader, 1, outdesc);
  2247.   #endif
  2248.   
  2249. !   mywrite (&outheader, sizeof (struct exec), 1, outdesc);
  2250.   
  2251.     /* Output whatever padding is required in the executable file
  2252.        between the header and the start of the text.  */
  2253.   
  2254.   #ifndef COFF_ENCAPSULATE
  2255. !   padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc);
  2256.   #endif
  2257.   }
  2258.   
  2259.   #endif
  2260.   #ifdef MACH_O
  2261.   
  2262.   /* Stuff pertaining to creating Mach-O files. */
  2263. --- 4392,4416 ----
  2264.   void
  2265.   write_a_out_header ()
  2266.   {
  2267. !   fseek (outstream, 0L, 0);
  2268.   
  2269.   #ifdef COFF_ENCAPSULATE
  2270.     if (need_coff_header)
  2271. !     mywrite (&coffheader, sizeof coffheader, 1, outstream);
  2272.   #endif
  2273.   
  2274. !   mywrite (&outheader, sizeof (struct exec), 1, outstream);
  2275.   
  2276.     /* Output whatever padding is required in the executable file
  2277.        between the header and the start of the text.  */
  2278.   
  2279.   #ifndef COFF_ENCAPSULATE
  2280. !   padfile (N_TXTOFF (outheader) - sizeof outheader, outstream);
  2281.   #endif
  2282.   }
  2283.   
  2284.   #endif
  2285.   #ifdef MACH_O
  2286.   
  2287.   /* Stuff pertaining to creating Mach-O files. */
  2288. ***************
  2289. *** 4145,4151 ****
  2290.   #endif
  2291.     thread_state state;
  2292.   
  2293. !   lseek (outdesc, 0L, 0);
  2294.   
  2295.   
  2296.     header.magic = MH_MAGIC;
  2297. --- 4614,4620 ----
  2298.   #endif
  2299.     thread_state state;
  2300.   
  2301. !   fseek (outstream, 0L, 0);
  2302.   
  2303.   
  2304.     header.magic = MH_MAGIC;
  2305. ***************
  2306. *** 4251,4257 ****
  2307.   #ifdef LC_SYMSEG
  2308.         m_object.symseg = symseg;
  2309.   #endif
  2310. !       mywrite((char *) &m_object, 1, sizeof m_object, outdesc);
  2311.         break;
  2312.   
  2313.       default:
  2314. --- 4720,4726 ----
  2315.   #ifdef LC_SYMSEG
  2316.         m_object.symseg = symseg;
  2317.   #endif
  2318. !       mywrite((char *) &m_object, 1, sizeof m_object, outstream);
  2319.         break;
  2320.   
  2321.       default:
  2322. ***************
  2323. *** 4305,4311 ****
  2324.   #ifdef LC_SYMSEG
  2325.         m_exec.symseg = symseg;
  2326.   #endif
  2327. !       mywrite((char *) &m_exec, 1, sizeof m_exec, outdesc);
  2328.         break;
  2329.       }
  2330.   }
  2331. --- 4774,4780 ----
  2332.   #ifdef LC_SYMSEG
  2333.         m_exec.symseg = symseg;
  2334.   #endif
  2335. !       mywrite((char *) &m_exec, 1, sizeof m_exec, outstream);
  2336.         break;
  2337.       }
  2338.   }
  2339. ***************
  2340. *** 4386,4392 ****
  2341.   }
  2342.   
  2343.   #endif
  2344.   /* The following functions are simple switches according to the
  2345.      output style.  */
  2346.   
  2347. --- 4855,4861 ----
  2348.   }
  2349.   
  2350.   #endif
  2351.   /* The following functions are simple switches according to the
  2352.      output style.  */
  2353.   
  2354. ***************
  2355. *** 4484,4489 ****
  2356. --- 4953,4962 ----
  2357.   void
  2358.   write_header ()
  2359.   {
  2360. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2361. +   conditionally_rewrite_headers ();
  2362. +   return;
  2363. + #else
  2364.   #ifdef A_OUT
  2365.     if (output_file_type == IS_A_OUT)
  2366.       {
  2367. ***************
  2368. *** 4498,4506 ****
  2369.         return;
  2370.       }
  2371.   #endif
  2372.     fatal ("unknown output file type (enum file_type)", (char *) 0);
  2373.   }
  2374.   /* Write the output file */
  2375.   
  2376.   void
  2377. --- 4971,4980 ----
  2378.         return;
  2379.       }
  2380.   #endif
  2381. + #endif
  2382.     fatal ("unknown output file type (enum file_type)", (char *) 0);
  2383.   }
  2384.   /* Write the output file */
  2385.   
  2386.   void
  2387. ***************
  2388. *** 4519,4540 ****
  2389.        the way Unix ld works; I'm going to consider it a feature.  */
  2390.     (void) unlink (output_filename);
  2391.     
  2392. !   outdesc = open (output_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
  2393. !   if (outdesc < 0) perror_name (output_filename);
  2394.   
  2395. !   if (fstat (outdesc, &statbuf) < 0)
  2396.       perror_name (output_filename);
  2397.   
  2398.     filemode = statbuf.st_mode;
  2399.   
  2400.     chmod (output_filename, filemode & ~0111);
  2401.   
  2402.     /* Calculate the offsets of the various pieces of the output file.  */
  2403.     compute_section_offsets ();
  2404.   
  2405.     /* Output the text and data segments, relocating as we go.  */
  2406.     write_text ();
  2407.     write_data ();
  2408.   
  2409.     /* Output the merged relocation info, if requested with `-r'.  */
  2410.     if (output_style == OUTPUT_RELOCATABLE)
  2411. --- 4993,5061 ----
  2412.        the way Unix ld works; I'm going to consider it a feature.  */
  2413.     (void) unlink (output_filename);
  2414.     
  2415. !   outstream = fopen (output_filename, "w");
  2416. !   if (outstream == 0) perror_name (output_filename);
  2417.   
  2418. ! #ifndef MCH_AMIGA
  2419. !   if (fstat (fileno (outstream), &statbuf) < 0)
  2420.       perror_name (output_filename);
  2421.   
  2422.     filemode = statbuf.st_mode;
  2423.   
  2424. +   /* this wouldn't work anyway, "file in use, error"... */
  2425.     chmod (output_filename, filemode & ~0111);
  2426. + #endif
  2427. +   /* on the Amiga, the following call DOES set the symbol offset, but
  2428. +    * it does it wrong, we'll be able to do it right, as soon as all the
  2429. +    * other data has been written.. */
  2430.   
  2431.     /* Calculate the offsets of the various pieces of the output file.  */
  2432.     compute_section_offsets ();
  2433.   
  2434. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2435. +   /* get ready to collect information where all symbols
  2436. +    * go. Since this has to be done only once, we'll later be able to 
  2437. +    * output the right symbol-hunk after the right (code/data/bss-)hunk. */
  2438. +   init_symbol_hunks ();
  2439. +   look_for_symbols ();
  2440. + #endif
  2441.     /* Output the text and data segments, relocating as we go.  */
  2442.     write_text ();
  2443.     write_data ();
  2444. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2445. +   if (datadata_relocs_offset)
  2446. +     write_datadata_relocs ();
  2447. +   write_bss ();
  2448. +   if (number_of_debug_hunk != -1)
  2449. +     {
  2450. +       /* ok, lets output the start of the debug hunk */
  2451. +       fseek (outstream, 0L, SEEK_END);
  2452. +       offset_of_debug_hunk = ftell (outstream);
  2453. +       if (trace_files)
  2454. +     fprintf (stderr, "Write debug hunk at 0x%x\n", offset_of_debug_hunk);
  2455. +       dh.id = 0x3f1;     /* HUNK_DEBUG */
  2456. +       dh.len = 0;        /* we'll fill this in later */
  2457. +       dh.magic = ZMAGIC; /* when wishes came true... */
  2458. +       dh.syms = outheader.a_syms;
  2459. +       mywrite(&dh, sizeof dh, 1, outstream);
  2460. +       output_syms_offset   = ftell (outstream);
  2461. +       output_strs_offset   = output_syms_offset + dh.syms;
  2462. +       /* since we later will seek forward and backward to fill in each files
  2463. +        * symbol- and string-table, we have to create the needed space, that
  2464. +        * will be seeked over, since on an empty file, lseek(fd, 10, 0) will 
  2465. +        * position to byte 10 on Unix, but will just generate an error under
  2466. +        * AmigaDOS and stay at position 0. */
  2467. +       /* this will just write garbage, but thats enough:-)) */
  2468. +       mywrite(&output_strs_offset, dh.syms+4, 1, outstream);
  2469. +       fseek (outstream, output_syms_offset, 0);
  2470. +     }
  2471. + #endif
  2472.   
  2473.     /* Output the merged relocation info, if requested with `-r'.  */
  2474.     if (output_style == OUTPUT_RELOCATABLE)
  2475. ***************
  2476. *** 4547,4568 ****
  2477.        are finalized.  */
  2478.     compute_more_section_offsets ();
  2479.   
  2480.     /* Copy any GDB symbol segments from input files.  */
  2481.     write_symsegs ();
  2482.   
  2483.     /* Now that everything is known about the output file, write its header.  */
  2484.     write_header ();
  2485.   
  2486. !   close (outdesc);
  2487.   
  2488.     mask = umask (0);
  2489.     umask (mask);
  2490.   
  2491.     if (chmod (output_filename, filemode | (0111 & ~mask)) == -1)
  2492.       perror_name (output_filename);
  2493.   }
  2494.   void modify_location (), perform_relocation (), copy_text (), copy_data ();
  2495.   
  2496.   /* Relocate the text segment of each input file
  2497.      and write to the output file.  */
  2498. --- 5068,5101 ----
  2499.        are finalized.  */
  2500.     compute_more_section_offsets ();
  2501.   
  2502. + #ifndef HUNK_INSTEAD_OF_A_OUT
  2503. +   /* I don't support GDB-symbol segments, they aren't used anymore by
  2504. +    * the newer versions of gdb, BUT of course, if somebody needs them..
  2505. +    * that's exactly why I introduced the "dh.strs" Parameter, so that
  2506. +    * you could - as in Unix - append these segments at the end of the file */
  2507.     /* Copy any GDB symbol segments from input files.  */
  2508.     write_symsegs ();
  2509. + #endif
  2510.   
  2511.     /* Now that everything is known about the output file, write its header.  */
  2512.     write_header ();
  2513.   
  2514. !   fclose (outstream);
  2515.   
  2516. + #ifndef HUNK_INSTEAD_OF_A_OUT
  2517.     mask = umask (0);
  2518.     umask (mask);
  2519.   
  2520.     if (chmod (output_filename, filemode | (0111 & ~mask)) == -1)
  2521.       perror_name (output_filename);
  2522. + #endif
  2523.   }
  2524.   void modify_location (), perform_relocation (), copy_text (), copy_data ();
  2525. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2526. + void write_hunk_header();
  2527. + #endif
  2528.   
  2529.   /* Relocate the text segment of each input file
  2530.      and write to the output file.  */
  2531. ***************
  2532. *** 4571,4587 ****
  2533.   write_text ()
  2534.   {
  2535.     if (trace_files)
  2536. !     fprintf (stderr, "Copying and relocating text:\n\n");
  2537.   
  2538. !   lseek (outdesc, output_text_offset + text_header_size, 0);
  2539.   
  2540.     each_full_file (copy_text, 0);
  2541.     file_close ();
  2542.   
  2543.     if (trace_files)
  2544.       fprintf (stderr, "\n");
  2545.   
  2546. !   padfile (text_pad, outdesc);
  2547.   }
  2548.   
  2549.   /* Read in all of the relocation information */
  2550. --- 5104,5161 ----
  2551.   write_text ()
  2552.   {
  2553.     if (trace_files)
  2554. !     fprintf (stderr, "Copying and relocating text at 0x%x:\n\n",
  2555. !          ftell (outstream));
  2556.   
  2557. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2558. !   /* this is a definitive write, we don't need to rewrite this out, since
  2559. !    * the yet undefined sizes of the reloc-hunks don't go into the 
  2560. !    * header-hunk */
  2561. !   write_hunk_header(outstream);
  2562. !   init_reloc_hunk();
  2563. !   /* and if there's no code-hunk, we can return here.. no sense in
  2564. !    * complicately doing just nothing... */
  2565. !   if (number_of_code_hunk == -1) return;
  2566. !   /* else start the code-hunk */
  2567. !   {
  2568. !      long code_header[2];
  2569. !      code_header[0] = 0x3e9;
  2570. !      code_header[1] = LONGSIZE(text_size);
  2571. !      mywrite(code_header, 1, sizeof code_header, outstream);
  2572. !   }
  2573. ! #else
  2574. !   fseek (outstream, output_text_offset + text_header_size, 0);
  2575. ! #endif
  2576.   
  2577.     each_full_file (copy_text, 0);
  2578. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2579. +   if (output_datadata_relocs && numdatadata_relocs)
  2580. +     {
  2581. +       int i, zero = 0;
  2582. +       /* include the size-field, -> <= . The `real' values come later */
  2583. +       datadata_relocs_offset = ftell (outstream);
  2584. +       for (i = 0; i <= numdatadata_relocs; i ++)
  2585. +         mywrite (&zero, 1, sizeof (long), outstream);
  2586. +     }
  2587. + #endif
  2588.     file_close ();
  2589.   
  2590.     if (trace_files)
  2591.       fprintf (stderr, "\n");
  2592.   
  2593. !   padfile (text_pad, outstream);
  2594. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2595. !   write_reloc_hunk();
  2596. !   write_symbol_hunk(number_of_code_hunk);
  2597. !   {
  2598. !     long hunk_end = 0x3f2;
  2599. !     mywrite(&hunk_end, 1, sizeof(long), outstream);
  2600. !   }
  2601. ! #endif
  2602.   }
  2603.   
  2604.   /* Read in all of the relocation information */
  2605. ***************
  2606. *** 4686,4700 ****
  2607.       fatal_with_file ("premature eof in text section of ", entry);
  2608.   
  2609.     /* Relocate the text according to the text relocation.  */
  2610.     perform_relocation (bytes, entry->text_start_address - entry->orig_text_address,
  2611.                 entry->text_size, reloc, entry->text_reloc_size, entry);
  2612.   
  2613.     /* Write the relocated text to the output file.  */
  2614.   
  2615. !   mywrite (bytes, 1, entry->text_size, outdesc);
  2616.   }
  2617.   /* Relocate the data segment of each input file
  2618.      and write to the output file.  */
  2619.   
  2620. --- 5260,5273 ----
  2621.       fatal_with_file ("premature eof in text section of ", entry);
  2622.   
  2623.     /* Relocate the text according to the text relocation.  */
  2624.     perform_relocation (bytes, entry->text_start_address - entry->orig_text_address,
  2625.                 entry->text_size, reloc, entry->text_reloc_size, entry);
  2626.   
  2627.     /* Write the relocated text to the output file.  */
  2628.   
  2629. !   mywrite (bytes, 1, entry->text_size, outstream);
  2630.   }
  2631.   /* Relocate the data segment of each input file
  2632.      and write to the output file.  */
  2633.   
  2634. ***************
  2635. *** 4702,4710 ****
  2636.   write_data ()
  2637.   {
  2638.     if (trace_files)
  2639. !     fprintf (stderr, "Copying and relocating data:\n\n");
  2640.   
  2641. !   lseek (outdesc, output_data_offset, 0);
  2642.   
  2643.     each_full_file (copy_data, 0);
  2644.     file_close ();
  2645. --- 5275,5304 ----
  2646.   write_data ()
  2647.   {
  2648.     if (trace_files)
  2649. !     fprintf (stderr, "Copying and relocating data at 0x%x:\n\n",
  2650. !          ftell (outstream));
  2651. ! #ifndef HUNK_INSTEAD_OF_A_OUT
  2652. !   fseek (outstream, output_data_offset, 0);
  2653. ! #else
  2654. !   /* just have to hope that the file is positioned correctly.. */
  2655. !   init_reloc_hunk();
  2656. !   /* start a data-hunk, if there is data to be output */
  2657. !   if (number_of_data_hunk == -1) return;
  2658.   
  2659. !   {
  2660. !     long data_header[2];
  2661. !     int size;
  2662. !     data_header[0] = 0x3ea;
  2663. !     size = LONGSIZE(data_size);
  2664. !     /* create long data hunk? */
  2665. !     if (long_data_hunk && databss_together)
  2666. !       size=LONGSIZE(data_size+bss_size);
  2667. !     data_header[1] = size;
  2668. !       
  2669. !     mywrite(data_header, 1, sizeof data_header, outstream);
  2670. !   }
  2671. ! #endif
  2672.   
  2673.     each_full_file (copy_data, 0);
  2674.     file_close ();
  2675. ***************
  2676. *** 4713,4725 ****
  2677.        description of length of the set vector section.  */
  2678.   
  2679.     if (set_vector_count)
  2680. !     mywrite (set_vectors, 2 * set_symbol_count + set_vector_count,
  2681. !          sizeof (unsigned long), outdesc);
  2682.   
  2683.     if (trace_files)
  2684.       fprintf (stderr, "\n");
  2685.   
  2686. !   padfile (data_pad, outdesc);
  2687.   }
  2688.   
  2689.   /* Read the data segment contents of ENTRY, relocate them,
  2690. --- 5307,5351 ----
  2691.        description of length of the set vector section.  */
  2692.   
  2693.     if (set_vector_count)
  2694. !     {
  2695. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2696. !      /* this and mywrite later: inverted set_symbol_count and 
  2697. !       * set_vector_count, guess they were mixed up before   ### mw */
  2698. !       relocate_set_vectors (set_vectors, rel_vectors,
  2699. !                 2 * set_vector_count + set_symbol_count);
  2700. ! #endif
  2701. ! #if 0
  2702. !       mywrite (set_vectors, 2 * set_symbol_count + set_vector_count,
  2703. !            sizeof (unsigned long), outstream);
  2704. ! #else
  2705. !       mywrite (set_vectors, 2 * set_vector_count + set_symbol_count,
  2706. !            sizeof (unsigned long), outstream);
  2707. ! #endif
  2708. !     }
  2709.   
  2710.     if (trace_files)
  2711.       fprintf (stderr, "\n");
  2712.   
  2713. !   padfile (data_pad, outstream);
  2714. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2715. !   if (long_data_hunk && databss_together && bss_size)
  2716. !     {
  2717. !       /* dump zeros */
  2718. !       int i, zero = 0;
  2719. !       for (i = 0; i < LONGSIZE(bss_size); i++)
  2720. !     mywrite (&zero, 1, sizeof (long), outstream);
  2721. !     }
  2722. !   write_reloc_hunk();
  2723. !   write_symbol_hunk(number_of_data_hunk);
  2724. !   {
  2725. !     long hunk_end = 0x3f2;
  2726. !     mywrite(&hunk_end, 1, sizeof(long), outstream);
  2727. !   }
  2728. ! #endif
  2729.   }
  2730.   
  2731.   /* Read the data segment contents of ENTRY, relocate them,
  2732. ***************
  2733. *** 4765,4776 ****
  2734.     if (entry->data_size != read (desc, bytes, entry->data_size))
  2735.       fatal_with_file ("premature eof in data section of ", entry);
  2736.   
  2737. !   perform_relocation (bytes, entry->data_start_address - entry->orig_data_address,
  2738. !               entry->data_size, reloc, entry->data_reloc_size, entry);
  2739.   
  2740. !   mywrite (bytes, 1, entry->data_size, outdesc);
  2741.   }
  2742.   /* Relocate ENTRY's text or data section contents.
  2743.      DATA is the address of the contents, in core.
  2744.      DATA_SIZE is the length of the contents.
  2745. --- 5391,5406 ----
  2746.     if (entry->data_size != read (desc, bytes, entry->data_size))
  2747.       fatal_with_file ("premature eof in data section of ", entry);
  2748.   
  2749. !   perform_relocation (bytes, entry->data_start_address 
  2750. ! #ifndef HUNK_INSTEAD_OF_A_OUT
  2751. !                         - entry->orig_data_address
  2752. ! #endif
  2753. !                                     ,
  2754. !                 entry->data_size, reloc, entry->data_reloc_size, entry);
  2755.   
  2756. !   mywrite (bytes, 1, entry->data_size, outstream);
  2757.   }
  2758.   /* Relocate ENTRY's text or data section contents.
  2759.      DATA is the address of the contents, in core.
  2760.      DATA_SIZE is the length of the contents.
  2761. ***************
  2762. *** 4796,4806 ****
  2763. --- 5426,5445 ----
  2764.     int data_relocation = entry->data_start_address - entry->orig_data_address;
  2765.     int bss_relocation = entry->bss_start_address - entry->orig_bss_address;
  2766.   
  2767. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2768. +   int this_hunk;
  2769. + #endif
  2770.     for (; p < end; p++)
  2771.       {
  2772.         register int relocation = 0;
  2773.         register int addr = RELOC_ADDRESS(p);
  2774.         register unsigned int mask = 0;
  2775. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2776. +       int ext_abs;
  2777. +       
  2778. +       ext_abs = 0;
  2779. + #endif
  2780.   
  2781.         if (addr >= data_size)
  2782.       fatal_with_file ("relocation address out of range in ", entry);
  2783. ***************
  2784. *** 4827,4848 ****
  2785.           relocation = 0;
  2786.         else
  2787.           relocation = sp->value;
  2788.       }
  2789.         else switch (RELOC_TYPE(p))
  2790.       {
  2791.       case N_TEXT:
  2792.       case N_TEXT | N_EXT:
  2793. !       relocation = text_relocation;
  2794.         break;
  2795.   
  2796.       case N_DATA:
  2797.       case N_DATA | N_EXT:
  2798. !       relocation = data_relocation;
  2799.         break;
  2800.   
  2801.       case N_BSS:
  2802.       case N_BSS | N_EXT:
  2803. !       relocation = bss_relocation;
  2804.         break;
  2805.   
  2806.       case N_ABS:
  2807. --- 5466,5545 ----
  2808.           relocation = 0;
  2809.         else
  2810.           relocation = sp->value;
  2811. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2812. +       if ((sp->defined & ~N_EXT) == N_ABS)
  2813. +         /* sort of a kludge.. the only external symbol (not pcrelative)
  2814. +              * we can really resolve.. */
  2815. +         ext_abs = 1;
  2816. +       else if ((sp->defined & ~N_EXT) == N_TEXT ||
  2817. +           (sp->defined & ~N_EXT) == N_SETT)
  2818. +         {
  2819. +           this_hunk = number_of_code_hunk;
  2820. +           if (RELOC_BASEREL_P (p))
  2821. +             {
  2822. +               fprintf (stderr, "symn = $%x, extern = %d, addr = $%lx.\n",
  2823. +                          p->r_symbolnum, p->r_extern, p->r_address);
  2824. +           fatal_with_file ("base relative text relocation in ", entry);
  2825. +         }
  2826. +         }
  2827. +       else if ((sp->defined & ~N_EXT) == N_DATA ||
  2828. +                (sp->defined & ~N_EXT) == N_SETD ||
  2829. +            (sp->defined & ~N_EXT) == N_SETV)
  2830. +         {
  2831. +           this_hunk = number_of_data_hunk;
  2832. +         }
  2833. +       else if ((sp->defined & ~N_EXT) == N_BSS ||
  2834. +            (sp->defined & ~N_EXT) == N_UNDF ||
  2835. +                (sp->defined & ~N_EXT) == N_SETB)
  2836. +         {
  2837. +           this_hunk = number_of_bss_hunk;
  2838. +         }
  2839. +       else    
  2840. +         fatal_with_file ("external symbol with unknown type $%x in ", entry, sp->defined);
  2841. + #endif
  2842.       }
  2843.         else switch (RELOC_TYPE(p))
  2844.       {
  2845.       case N_TEXT:
  2846.       case N_TEXT | N_EXT:
  2847. !       if (RELOC_BASEREL_P (p))
  2848. !         {
  2849. !           fprintf (stderr, "symn = $%x, extern = %d, addr = $%lx.\n",
  2850. !                      p->r_symbolnum, p->r_extern, p->r_address);
  2851. !           fatal_with_file ("base relative text relocation in ", entry);
  2852. !         }
  2853. !       else
  2854. !         relocation = text_relocation;
  2855. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2856. !       this_hunk = number_of_code_hunk;
  2857. ! #endif
  2858.         break;
  2859.   
  2860.       case N_DATA:
  2861.       case N_DATA | N_EXT:
  2862. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2863. !       if (RELOC_BASEREL_P (p))
  2864. !         relocation = entry->data_start_address;
  2865. !       else
  2866. ! #endif
  2867. !         relocation = data_relocation;
  2868. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2869. !       this_hunk = number_of_data_hunk;
  2870. ! #endif
  2871.         break;
  2872.   
  2873.       case N_BSS:
  2874.       case N_BSS | N_EXT:
  2875. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2876. !       if (RELOC_BASEREL_P (p))
  2877. !         relocation = entry->bss_start_address - entry->data_size;
  2878. !       else
  2879. ! #endif
  2880. !         relocation = bss_relocation;
  2881. ! #ifdef HUNK_INSTEAD_OF_A_OUT
  2882. !       this_hunk = number_of_bss_hunk;
  2883. ! #endif
  2884.         break;
  2885.   
  2886.       case N_ABS:
  2887. ***************
  2888. *** 4854,4864 ****
  2889.         fatal_with_file ("nonexternal relocation code invalid in ", entry);
  2890.       }
  2891.   
  2892.         if (RELOC_PCREL_P(p))
  2893.       relocation -= pc_relocation;
  2894.   
  2895. ! #ifdef RELOC_ADD_EXTRA
  2896. !       relocation += RELOC_ADD_EXTRA(p);
  2897.         if (output_style == OUTPUT_RELOCATABLE)
  2898.       {
  2899.         /* If this RELOC_ADD_EXTRA is 0, it means that the
  2900. --- 5551,5586 ----
  2901.         fatal_with_file ("nonexternal relocation code invalid in ", entry);
  2902.       }
  2903.   
  2904. + #ifdef HUNK_INSTEAD_OF_A_OUT
  2905. +       /* in this case, ONLY relocate those pc-relative 32bit jumps, that
  2906. +        * gas generates, since they are position independent, this gives
  2907. +        * a HUGE.. 'if' inside of '#ifdef' oh well... */
  2908. +       if (RELOC_PCREL_P(p) || RELOC_BASEREL_P(p) || ext_abs) {
  2909. +       
  2910. +       /* VERY BIG KLUDGE AHEAD! Since this amiga hunk format is really
  2911. +        * limited, 8bit and 16bit references are always defined to be
  2912. +        * pc-relative (according to the AmigaDOS RM 2nd ed). BUT if such
  2913. +        * a symbol is resolved by an absolute symbol then it's not considered
  2914. +        * to be pc-relative any more. This is nowhere documented, but you
  2915. +        * couldn't get
  2916. +        *   jsr _LVOOpen(a6)
  2917. +        * to work if you wouldn't do it this way. */
  2918. +        if (ext_abs) RELOC_PCREL_P(p) = 0;
  2919. +       
  2920. + #endif
  2921.         if (RELOC_PCREL_P(p))
  2922.       relocation -= pc_relocation;
  2923.   
  2924. !       /* if base relative, subtract 64k/2, so we get a larger range */
  2925. !       if (RELOC_BASEREL_P(p))
  2926. !     {
  2927. !       if (! databss_together)
  2928. !         fatal_with_file ("Reloc is base relative. Specify -databss-together in ", entry);
  2929. !       relocation -= 0x7ffe;
  2930. !     }
  2931. ! #ifdef RELOC_ADD_EXTRA
  2932. !       relocation += RELOC_ADD_EXTRA(p);
  2933.         if (output_style == OUTPUT_RELOCATABLE)
  2934.       {
  2935.         /* If this RELOC_ADD_EXTRA is 0, it means that the
  2936. ***************
  2937. *** 4895,4901 ****
  2938.         /* Shift everything up to where it's going to be used */
  2939.         relocation <<= RELOC_TARGET_BITPOS(p);
  2940.         mask <<= RELOC_TARGET_BITPOS(p);
  2941.         switch (RELOC_TARGET_SIZE(p))
  2942.       {
  2943.       case 0:
  2944. --- 5617,5622 ----
  2945. ***************
  2946. *** 4903,4920 ****
  2947. --- 5624,5662 ----
  2948.           relocation -= mask & *(char *) (data + addr);
  2949.         else if (RELOC_MEMORY_ADD_P(p))
  2950.           relocation += mask & *(char *) (data + addr);
  2951. +       if (relocation < -128 || relocation > 127)
  2952. +         fatal_with_file ("Byte reloc overflow in ", entry);
  2953.         *(char *) (data + addr) &= ~mask;
  2954.         *(char *) (data + addr) |= relocation;
  2955.         break;
  2956.   
  2957.       case 1:
  2958. +       {
  2959. +       int r=relocation;
  2960.         if (RELOC_MEMORY_SUB_P(p))
  2961.           relocation -= mask & *(short *) (data + addr);
  2962.         else if (RELOC_MEMORY_ADD_P(p))
  2963.           relocation += mask & *(short *) (data + addr);
  2964. +       if (relocation < -32768 || relocation > 32767)
  2965. +         {
  2966. +           fprintf (stderr, "relocation = $%lx, bsr = %d, pcr = %d, r= $%lx\n",
  2967. +                      relocation, RELOC_BASEREL_P(p), RELOC_PCREL_P (p), r);
  2968. +           fprintf (stderr, "textr = $%x, datar = $%x, bssr = $%x\n",
  2969. +                      text_relocation, data_relocation, bss_relocation);
  2970. +           fprintf (stderr, "symn = $%x, extern = %d, addr = $%lx.\n",
  2971. +                      p->r_symbolnum, p->r_extern, p->r_address);
  2972. +           fprintf (stderr, "data_size = %d, bss_size = %d.\n",
  2973. +                data_size, bss_size);
  2974. +           fatal_with_file ("Word reloc overflow in ", entry);
  2975. +         }
  2976.         *(short *) (data + addr) &= ~mask;
  2977.         *(short *) (data + addr) |= relocation;
  2978.         break;
  2979. +       }
  2980.   
  2981.       case 2:
  2982.   #ifdef CROSS_LINKER
  2983. ***************
  2984. *** 4937,4942 ****
  2985. --- 5679,5685 ----
  2986.           relocation -= mask & *(long *) (data + addr);
  2987.         else if (RELOC_MEMORY_ADD_P(p))
  2988.           relocation += mask & *(long *) (data + addr);
  2989.         *(long *) (data + addr) &= ~mask;
  2990.         *(long *) (data + addr) |= relocation;
  2991.   #endif /* not CROSS_LINKER */
  2992. ***************
  2993. *** 4945,4953 ****
  2994.       default:
  2995.         fatal_with_file ("Unimplemented relocation field length in ", entry);
  2996.       }
  2997.       }
  2998.   }
  2999.   /* For OUTPUT_RELOCATABLE only: write out the relocation,
  3000.      relocating the addresses-to-be-relocated.  */
  3001.   
  3002. --- 5688,5727 ----
  3003.       default:
  3004.         fatal_with_file ("Unimplemented relocation field length in ", entry);
  3005.       }
  3006. + #ifdef HUNK_INSTEAD_OF_A_OUT
  3007. +     /* now finish this huge 'if' .. */
  3008. +     }
  3009. +     else
  3010. +       {
  3011. +         /* this only deals with 32bit relocs, the Amiga-loader
  3012. +          * doesn't support 1 or 2 byte relocs, they are only defined
  3013. +          * inside program-units (commonly known as object-files:-)) */
  3014. +         if (RELOC_TARGET_SIZE(p) != 2)
  3015. +           fatal_with_file ("unsupported reloc-size in ", entry);
  3016. + /* Phil.B: 06-Apr-94 same kludge as above for host with stricter alignment
  3017. +    than the taget. */
  3018. + #ifdef CROSS_LINKER
  3019. +       {
  3020. +         /* Thing to relocate.  */
  3021. +         long thing;
  3022. +         bcopy (data + addr, &thing, sizeof (thing));
  3023. +         thing += relocation;
  3024. +         bcopy (&thing, data + addr, sizeof (thing));
  3025. +       }
  3026. + #else
  3027. +         *(long *) (data + addr) += relocation;
  3028. + #endif /* CROSS_LINKER */
  3029. +         addr += pc_relocation;
  3030. +             add_to_reloc_hunk(this_hunk, addr);
  3031. +       }
  3032. + #endif
  3033.       }
  3034.   }
  3035.   /* For OUTPUT_RELOCATABLE only: write out the relocation,
  3036.      relocating the addresses-to-be-relocated.  */
  3037.   
  3038. ***************
  3039. *** 4995,5007 ****
  3040.   
  3041.     /* Write out the relocations of all files, remembered from copy_text.  */
  3042.   
  3043. !   lseek (outdesc, output_trel_offset, 0);
  3044.     each_full_file (coptxtrel, 0);
  3045.   
  3046.     if (trace_files)
  3047.       fprintf (stderr, "\nWriting data relocation:\n\n");
  3048.   
  3049. !   lseek (outdesc, output_drel_offset, 0);
  3050.     each_full_file (copdatrel, 0);
  3051.   
  3052.     if (trace_files)
  3053. --- 5769,5781 ----
  3054.   
  3055.     /* Write out the relocations of all files, remembered from copy_text.  */
  3056.   
  3057. !   fseek (outstream, output_trel_offset, 0);
  3058.     each_full_file (coptxtrel, 0);
  3059.   
  3060.     if (trace_files)
  3061.       fprintf (stderr, "\nWriting data relocation:\n\n");
  3062.   
  3063. !   fseek (outstream, output_drel_offset, 0);
  3064.     each_full_file (copdatrel, 0);
  3065.   
  3066.     if (trace_files)
  3067. ***************
  3068. *** 5076,5082 ****
  3069.                   entry->text_reloc_size / sizeof (struct relocation_info));
  3070.   #endif
  3071.   
  3072. !   mywrite (entry->textrel, 1, entry->text_reloc_size, outdesc);
  3073.   }
  3074.   
  3075.   void
  3076. --- 5850,5856 ----
  3077.                   entry->text_reloc_size / sizeof (struct relocation_info));
  3078.   #endif
  3079.   
  3080. !   mywrite (entry->textrel, 1, entry->text_reloc_size, outstream);
  3081.   }
  3082.   
  3083.   void
  3084. ***************
  3085. *** 5155,5163 ****
  3086.                   entry->data_reloc_size / sizeof (struct relocation_info));
  3087.   #endif
  3088.   
  3089. !   mywrite (entry->datarel, 1, entry->data_reloc_size, outdesc);
  3090.   }
  3091.   void write_file_syms ();
  3092.   void write_string_table ();
  3093.   
  3094. --- 5929,5937 ----
  3095.                   entry->data_reloc_size / sizeof (struct relocation_info));
  3096.   #endif
  3097.   
  3098. !   mywrite (entry->datarel, 1, entry->data_reloc_size, outstream);
  3099.   }
  3100.   void write_file_syms ();
  3101.   void write_string_table ();
  3102.   
  3103. ***************
  3104. *** 5192,5199 ****
  3105.     return index;
  3106.   }
  3107.   
  3108. - FILE *outstream = (FILE *) 0;
  3109.   /* Write the contents of `strtab_vector' into the string table.
  3110.      This is done once for each file's local&debugger symbols
  3111.      and once for the global symbols.  */
  3112. --- 5966,5971 ----
  3113. ***************
  3114. *** 5203,5212 ****
  3115.   {
  3116.     register int i;
  3117.   
  3118. !   lseek (outdesc, output_strs_offset + output_strs_size, 0);
  3119.   
  3120.     if (!outstream)
  3121.       outstream = fdopen (outdesc, "w");
  3122.   
  3123.     for (i = 0; i < strtab_index; i++)
  3124.       {
  3125. --- 5975,5986 ----
  3126.   {
  3127.     register int i;
  3128.   
  3129. !   fseek (outstream, output_strs_offset + output_strs_size, 0);
  3130.   
  3131. + #if 0
  3132.     if (!outstream)
  3133.       outstream = fdopen (outdesc, "w");
  3134. + #endif
  3135.   
  3136.     for (i = 0; i < strtab_index; i++)
  3137.       {
  3138. ***************
  3139. *** 5220,5226 ****
  3140.     if (ferror (outstream))
  3141.       perror_name (output_filename);
  3142.   }
  3143.   /* Write the symbol table and string table of the output file.  */
  3144.   
  3145.   void
  3146. --- 5994,6000 ----
  3147.     if (ferror (outstream))
  3148.       perror_name (output_filename);
  3149.   }
  3150.   /* Write the symbol table and string table of the output file.  */
  3151.   
  3152.   void
  3153. ***************
  3154. *** 5248,5253 ****
  3155. --- 6022,6033 ----
  3156.     /* Pointer for storing into BUF.  */
  3157.     register struct nlist *bufp = buf;
  3158.   
  3159. + #ifdef HUNK_INSTEAD_OF_A_OUT
  3160. +   /* this enables us to output "regular" amiga symbols without
  3161. +    * the BSD-like debug-hunk */
  3162. +   if (number_of_debug_hunk == -1) return;
  3163. + #endif
  3164.     /* Size of string table includes the bytes that store the size.  */
  3165.     strtab_size = sizeof strtab_size;
  3166.   
  3167. ***************
  3168. *** 5370,5377 ****
  3169.   
  3170.     /* Output the buffer full of `struct nlist's.  */
  3171.   
  3172. !   lseek (outdesc, output_syms_offset + output_syms_size, 0);
  3173. !   mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc);
  3174.     output_syms_size += sizeof (struct nlist) * (bufp - buf);
  3175.   
  3176.     if (syms_written != nsyms)
  3177. --- 6150,6157 ----
  3178.   
  3179.     /* Output the buffer full of `struct nlist's.  */
  3180.   
  3181. !   fseek (outstream, output_syms_offset + output_syms_size, 0);
  3182. !   mywrite (buf, sizeof (struct nlist), bufp - buf, outstream);
  3183.     output_syms_size += sizeof (struct nlist) * (bufp - buf);
  3184.   
  3185.     if (syms_written != nsyms)
  3186. ***************
  3187. *** 5380,5393 ****
  3188.     /* Now the total string table size is known, so write it into the
  3189.        first word of the string table.  */
  3190.   
  3191. !   lseek (outdesc, output_strs_offset, 0);
  3192. !   mywrite (&strtab_size, sizeof (int), 1, outdesc);
  3193.   
  3194.     /* Write the strings for the global symbols.  */
  3195.   
  3196.     write_string_table ();
  3197.   }
  3198.   /* Write the local and debugger symbols of file ENTRY.
  3199.      Increment *SYMS_WRITTEN_ADDR for each symbol that is written.  */
  3200.   
  3201. --- 6160,6173 ----
  3202.     /* Now the total string table size is known, so write it into the
  3203.        first word of the string table.  */
  3204.   
  3205. !   fseek (outstream, output_strs_offset, 0);
  3206. !   mywrite (&strtab_size, sizeof (int), 1, outstream);
  3207.   
  3208.     /* Write the strings for the global symbols.  */
  3209.   
  3210.     write_string_table ();
  3211.   }
  3212.   /* Write the local and debugger symbols of file ENTRY.
  3213.      Increment *SYMS_WRITTEN_ADDR for each symbol that is written.  */
  3214.   
  3215. ***************
  3216. *** 5489,5496 ****
  3217.   
  3218.     /* All the symbols are now in BUF; write them.  */
  3219.   
  3220. !   lseek (outdesc, output_syms_offset + output_syms_size, 0);
  3221. !   mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc);
  3222.     output_syms_size += sizeof (struct nlist) * (bufp - buf);
  3223.   
  3224.     /* Write the string-table data for the symbols just written,
  3225. --- 6269,6276 ----
  3226.   
  3227.     /* All the symbols are now in BUF; write them.  */
  3228.   
  3229. !   fseek (outstream, output_syms_offset + output_syms_size, 0);
  3230. !   mywrite (buf, sizeof (struct nlist), bufp - buf, outstream);
  3231.     output_syms_size += sizeof (struct nlist) * (bufp - buf);
  3232.   
  3233.     /* Write the string-table data for the symbols just written,
  3234. ***************
  3235. *** 5499,5505 ****
  3236.     write_string_table ();
  3237.     entry->strings = 0;        /* Since it will dissapear anyway.  */
  3238.   }
  3239.   /* Copy any GDB symbol segments from the input files to the output file.
  3240.      The contents of the symbol segment is copied without change
  3241.      except that we store some information into the beginning of it.  */
  3242. --- 6279,6285 ----
  3243.     write_string_table ();
  3244.     entry->strings = 0;        /* Since it will dissapear anyway.  */
  3245.   }
  3246.   /* Copy any GDB symbol segments from the input files to the output file.
  3247.      The contents of the symbol segment is copied without change
  3248.      except that we store some information into the beginning of it.  */
  3249. ***************
  3250. *** 5509,5515 ****
  3251.   void
  3252.   write_symsegs ()
  3253.   {
  3254. !   lseek (outdesc, output_symseg_offset, 0);
  3255.     each_file (write_file_symseg, 0);
  3256.   }
  3257.   
  3258. --- 6289,6295 ----
  3259.   void
  3260.   write_symsegs ()
  3261.   {
  3262. !   fseek (outstream, output_symseg_offset, 0);
  3263.     each_file (write_file_symseg, 0);
  3264.   }
  3265.   
  3266. ***************
  3267. *** 5544,5550 ****
  3268.   
  3269.     /* Write the modified root into the output file.  */
  3270.   
  3271. !   mywrite (&root, sizeof root, 1, outdesc);
  3272.   
  3273.     /* Copy the rest of the symbol segment unchanged.  */
  3274.   
  3275. --- 6324,6330 ----
  3276.   
  3277.     /* Write the modified root into the output file.  */
  3278.   
  3279. !   mywrite (&root, sizeof root, 1, outstream);
  3280.   
  3281.     /* Copy the rest of the symbol segment unchanged.  */
  3282.   
  3283. ***************
  3284. *** 5557,5568 ****
  3285.         if (len != min (sizeof buffer, total))
  3286.       fatal_with_file ("premature end of file in symbol segment of ", entry);
  3287.         total -= len;
  3288. !       mywrite (buffer, len, 1, outdesc);
  3289.       }
  3290.   
  3291.     file_close ();
  3292.   }
  3293.   /* Define a special symbol (etext, edata, or end).  NAME is the
  3294.      name of the symbol, with a leading underscore (whether or not this
  3295.      system uses such underscores).  TYPE is its type (e.g. N_DATA | N_EXT).
  3296. --- 6337,6348 ----
  3297.         if (len != min (sizeof buffer, total))
  3298.       fatal_with_file ("premature end of file in symbol segment of ", entry);
  3299.         total -= len;
  3300. !       mywrite (buffer, len, 1, outstream);
  3301.       }
  3302.   
  3303.     file_close ();
  3304.   }
  3305.   /* Define a special symbol (etext, edata, or end).  NAME is the
  3306.      name of the symbol, with a leading underscore (whether or not this
  3307.      system uses such underscores).  TYPE is its type (e.g. N_DATA | N_EXT).
  3308. ***************
  3309. *** 5616,5621 ****
  3310. --- 6396,6427 ----
  3311.     symbol_define ("__etext", N_TEXT | N_EXT, &etext_symbol_alt);
  3312.     symbol_define ("__end", N_BSS | N_EXT, &end_symbol_alt);
  3313.   
  3314. + #ifdef amigados
  3315. +   if (output_datadata_relocs)
  3316. +     symbol_define ("___datadata_relocs", N_TEXT | N_EXT, &datadata_reloc_symbol);
  3317. +   symbol_define ("__sdata", N_DATA | N_EXT, &sdata_symbol);
  3318. +   symbol_define ("___text_size", N_ABS | N_EXT, &text_size_symbol);
  3319. +   symbol_define ("___data_size", N_ABS | N_EXT, &data_size_symbol);
  3320. +   symbol_define ("___bss_size", N_ABS | N_EXT, &bss_size_symbol);
  3321. +   {
  3322. +     symbol *a_symbol;
  3323. +     symbol_define ("___machtype", N_ABS | N_EXT, &a_symbol);
  3324. +     if (a_symbol)
  3325. +       a_symbol->value = amiga_machtype;
  3326. +       
  3327. +     symbol_define ("___databss_together", N_ABS | N_EXT, &a_symbol);
  3328. +     if (a_symbol)
  3329. +       a_symbol->value = databss_together;
  3330. +       
  3331. +     if (databss_together)
  3332. +       {
  3333. +         symbol_define ("___a4_init", N_DATA | N_EXT, &a_symbol);
  3334. +         if (a_symbol)
  3335. +           a_symbol->value = data_start + 0x7ffe;
  3336. +       }
  3337. +   }
  3338. + #endif
  3339.   #ifdef sun
  3340.     {
  3341.       symbol *dynamic_symbol;
  3342. ***************
  3343. *** 5658,5664 ****
  3344.   
  3345.     return k;
  3346.   }
  3347.   /* Get the symbol table entry for the global symbol named KEY.
  3348.      Create one if there is none.  */
  3349.   
  3350. --- 6464,6470 ----
  3351.   
  3352.     return k;
  3353.   }
  3354.   /* Get the symbol table entry for the global symbol named KEY.
  3355.      Create one if there is none.  */
  3356.   
  3357. ***************
  3358. *** 5725,5731 ****
  3359.   
  3360.     return 0;
  3361.   }
  3362.   /* Report a usage error.
  3363.      Like fatal except prints a usage summary.  */
  3364.   
  3365. --- 6531,6537 ----
  3366.   
  3367.     return 0;
  3368.   }
  3369.   /* Report a usage error.
  3370.      Like fatal except prints a usage summary.  */
  3371.   
  3372. ***************
  3373. *** 5739,5750 ****
  3374. --- 6545,6567 ----
  3375.         fprintf (stderr, string, arg);
  3376.         fprintf (stderr, "\n");
  3377.       }
  3378. + #ifdef HUNK_INSTEAD_OF_A_OUT
  3379. +   fprintf (stderr, "\
  3380. + Usage: %s [-d] [-dc] [-dp] [-e symbol] [-l lib] [-n] [-noinhibit-exec]\n\
  3381. +        [-nostdlib] [-o file] [-r] [-s] [-t] [-u symbol] [-x] [-y symbol]\n\
  3382. +        [-z] [-A file] [-Bstatic] [-D size] [-L libdir] [-M] [-N]\n\
  3383. +        [-S] [-T[{text,data}] addr] [-V prefix] [-X] \n\
  3384. +        [{-a,-amiga-debug-hunk}] [{-f,-flavor} flavor] [file...]\n\
  3385. +        [-chip {c,d,b}] [-fast {c,d,b}] [-m,-shortdata]\n",
  3386. +        progname);
  3387. + #else
  3388.     fprintf (stderr, "\
  3389.   Usage: %s [-d] [-dc] [-dp] [-e symbol] [-l lib] [-n] [-noinhibit-exec]\n\
  3390.          [-nostdlib] [-o file] [-r] [-s] [-t] [-u symbol] [-x] [-y symbol]\n\
  3391.          [-z] [-A file] [-Bstatic] [-D size] [-L libdir] [-M] [-N]\n\
  3392.          [-S] [-T[{text,data}] addr] [-V prefix] [-X] [file...]\n",
  3393.          progname);
  3394. + #endif
  3395.     exit (1);
  3396.   }
  3397.   
  3398. ***************
  3399. *** 5765,5776 ****
  3400.      followed by the filename of ENTRY.  */
  3401.   
  3402.   void
  3403. ! fatal_with_file (string, entry)
  3404.        char *string;
  3405.        struct file_entry *entry;
  3406.   {
  3407.     fprintf (stderr, "%s: ", progname);
  3408. !   fprintf (stderr, string);
  3409.     print_file_name (entry, stderr);
  3410.     fprintf (stderr, "\n");
  3411.     exit (1);
  3412. --- 6582,6593 ----
  3413.      followed by the filename of ENTRY.  */
  3414.   
  3415.   void
  3416. ! fatal_with_file (string, entry, arg)
  3417.        char *string;
  3418.        struct file_entry *entry;
  3419.   {
  3420.     fprintf (stderr, "%s: ", progname);
  3421. !   fprintf (stderr, string, arg);
  3422.     print_file_name (entry, stderr);
  3423.     fprintf (stderr, "\n");
  3424.     exit (1);
  3425. ***************
  3426. *** 5784,5794 ****
  3427.        char *name;
  3428.   {
  3429.     extern int errno, sys_nerr;
  3430. -   extern char *sys_errlist[];
  3431.     char *s;
  3432.   
  3433.     if (errno < sys_nerr)
  3434. !     s = concat ("", sys_errlist[errno], " for %s");
  3435.     else
  3436.       s = "cannot open %s";
  3437.     fatal (s, name);
  3438. --- 6601,6610 ----
  3439.        char *name;
  3440.   {
  3441.     extern int errno, sys_nerr;
  3442.     char *s;
  3443.   
  3444.     if (errno < sys_nerr)
  3445. !     s = concat ("", strerror (errno), " for %s");
  3446.     else
  3447.       s = "cannot open %s";
  3448.     fatal (s, name);
  3449. ***************
  3450. *** 5802,5812 ****
  3451.        struct file_entry *entry;
  3452.   {
  3453.     extern int errno, sys_nerr;
  3454. -   extern char *sys_errlist[];
  3455.     char *s;
  3456.   
  3457.     if (errno < sys_nerr)
  3458. !     s = concat ("", sys_errlist[errno], " for ");
  3459.     else
  3460.       s = "cannot open ";
  3461.     fatal_with_file (s, entry);
  3462. --- 6618,6627 ----
  3463.        struct file_entry *entry;
  3464.   {
  3465.     extern int errno, sys_nerr;
  3466.     char *s;
  3467.   
  3468.     if (errno < sys_nerr)
  3469. !     s = concat ("", strerror (errno), " for ");
  3470.     else
  3471.       s = "cannot open ";
  3472.     fatal_with_file (s, entry);
  3473. ***************
  3474. *** 5824,5840 ****
  3475.     fprintf (stderr, "\n");
  3476.   }
  3477.   
  3478.   /* Output COUNT*ELTSIZE bytes of data at BUF
  3479.      to the descriptor DESC.  */
  3480.   
  3481.   void
  3482. ! mywrite (buf, count, eltsize, desc)
  3483.        char *buf;
  3484.        int count;
  3485.        int eltsize;
  3486. !      int desc;
  3487.   {
  3488.     register int val;
  3489.     register int bytes = count * eltsize;
  3490.   
  3491. --- 6639,6656 ----
  3492.     fprintf (stderr, "\n");
  3493.   }
  3494.   
  3495.   /* Output COUNT*ELTSIZE bytes of data at BUF
  3496.      to the descriptor DESC.  */
  3497.   
  3498.   void
  3499. ! mywrite (buf, count, eltsize, stream)
  3500.        char *buf;
  3501.        int count;
  3502.        int eltsize;
  3503. !      FILE *stream;
  3504.   {
  3505. + #if 0
  3506.     register int val;
  3507.     register int bytes = count * eltsize;
  3508.   
  3509. ***************
  3510. *** 5846,5860 ****
  3511.         buf += val;
  3512.         bytes -= val;
  3513.       }
  3514.   }
  3515.   
  3516. ! /* Output PADDING zero-bytes to descriptor OUTDESC.
  3517.      PADDING may be negative; in that case, do nothing.  */
  3518.   
  3519.   void
  3520. ! padfile (padding, outdesc)
  3521.        int padding;
  3522. !      int outdesc;
  3523.   {
  3524.     register char *buf;
  3525.     if (padding <= 0)
  3526. --- 6662,6679 ----
  3527.         buf += val;
  3528.         bytes -= val;
  3529.       }
  3530. + #else
  3531. +   fwrite (buf, eltsize, count, stream);
  3532. + #endif
  3533.   }
  3534.   
  3535. ! /* Output PADDING zero-bytes to descriptor OUTSTREAM.
  3536.      PADDING may be negative; in that case, do nothing.  */
  3537.   
  3538.   void
  3539. ! padfile (padding, outstream)
  3540.        int padding;
  3541. !      FILE *outstream;
  3542.   {
  3543.     register char *buf;
  3544.     if (padding <= 0)
  3545. ***************
  3546. *** 5862,5868 ****
  3547.   
  3548.     buf = (char *) alloca (padding);
  3549.     bzero (buf, padding);
  3550. !   mywrite (buf, padding, 1, outdesc);
  3551.   }
  3552.   
  3553.   /* Return a newly-allocated string
  3554. --- 6681,6687 ----
  3555.   
  3556.     buf = (char *) alloca (padding);
  3557.     bzero (buf, padding);
  3558. !   mywrite (buf, padding, 1, outstream);
  3559.   }
  3560.   
  3561.   /* Return a newly-allocated string
  3562. ***************
  3563. *** 5903,5910 ****
  3564.   xmalloc (size)
  3565.        int size;
  3566.   {
  3567.     register char *result = malloc (size);
  3568. !   if (!result)
  3569.       fatal ("virtual memory exhausted", 0);
  3570.     return result;
  3571.   }
  3572. --- 6722,6730 ----
  3573.   xmalloc (size)
  3574.        int size;
  3575.   {
  3576. +   extern char *malloc();
  3577.     register char *result = malloc (size);
  3578. !   if (!result && size)
  3579.       fatal ("virtual memory exhausted", 0);
  3580.     return result;
  3581.   }
  3582. ***************
  3583. *** 5916,5927 ****
  3584.        char *ptr;
  3585.        int size;
  3586.   {
  3587. !   register char *result = realloc (ptr, size);
  3588.     if (!result)
  3589.       fatal ("virtual memory exhausted", 0);
  3590.     return result;
  3591.   }
  3592.   #ifdef USG
  3593.   
  3594.   void
  3595. --- 6736,6748 ----
  3596.        char *ptr;
  3597.        int size;
  3598.   {
  3599. !   extern char *malloc(), *realloc();
  3600. !   register char *result = ptr ? realloc (ptr, size) : malloc (size);
  3601.     if (!result)
  3602.       fatal ("virtual memory exhausted", 0);
  3603.     return result;
  3604.   }
  3605.   #ifdef USG
  3606.   
  3607.   void
  3608. ***************
  3609. *** 5952,5954 ****
  3610. --- 6773,7453 ----
  3611.     return 8192;
  3612.   }
  3613.   #endif
  3614. + #ifdef HUNK_INSTEAD_OF_A_OUT
  3615. + /* the whole rest of the file is used for managment of hunks and subhunks.. */
  3616. + /* this is the amiga-equivalent of struct exec */
  3617. + struct simple_hunk_header {
  3618. +   long    id,    /* this will be 0x3f3 */
  3619. +     zero,
  3620. +     table_size,
  3621. +     first_hunk,
  3622. +     last_hunk,
  3623. +     sizes[4];   /* there can be at most a code,data,bss & debug hunk */
  3624. + };
  3625. + /* this writes out a hunk header, depending on the information collected
  3626. +  * so far, it will only create hunks, that really exist, so if your data-
  3627. +  * size is zero, you won't get a data-hunk at all. */
  3628. + void
  3629. + write_hunk_header(outfd)
  3630. +     int outfd;
  3631. + {
  3632. +   struct simple_hunk_header sh;
  3633. +   int this_hunk, header_size;
  3634. +   sh.id = 0x3f3;    /* HUNK_HEADER */
  3635. +   sh.zero = 0;
  3636. +   sh.table_size = current_hunk;
  3637. +   sh.first_hunk = 0;
  3638. +   sh.last_hunk  = current_hunk - 1;
  3639. +   this_hunk = 0;
  3640. +   if (number_of_code_hunk != -1)
  3641. +      sh.sizes[this_hunk++] = code_mem_type|LONGSIZE(text_size);
  3642. +   if (number_of_data_hunk != -1)
  3643. +   {
  3644. +      int size = LONGSIZE(data_size);
  3645. +      if (databss_together)
  3646. +      {
  3647. +        if (long_data_hunk || !output_datadata_relocs)
  3648. +          size=LONGSIZE(data_size+bss_size);
  3649. +        if (data_mem_type == 0)
  3650. +          data_mem_type=bss_mem_type;
  3651. +      }
  3652. +      sh.sizes[this_hunk++] = data_mem_type|size;
  3653. +   }
  3654. +   if (!databss_together && number_of_bss_hunk  != -1)
  3655. +      sh.sizes[this_hunk++] = bss_mem_type|LONGSIZE(bss_size);
  3656. +   if (number_of_debug_hunk != -1)
  3657. +      sh.sizes[this_hunk++] = 0;  /* to be filled in later */
  3658. +   header_size = sizeof(sh) - (4-this_hunk)*sizeof(long);
  3659. +   mywrite(&sh, 1, header_size, outfd);
  3660. + }
  3661. + /* if we really write out a debug hunk, this fills in the remaining
  3662. +  * spots, that are known only at the end of load-file output */
  3663. + void
  3664. + conditionally_rewrite_headers ()
  3665. + {
  3666. +   long size_of_debug_hunk,
  3667. +        end_hunk = 0x3f2,
  3668. +        eof;
  3669. +   /* if we don't want a debug hunk, just return */
  3670. +   if (number_of_debug_hunk == -1)  return;
  3671. +   /* while we're at it, since we started the debug-hunk, lets finish it
  3672. +    * now. */
  3673. +   fseek (outstream, 0L, 2);
  3674. +   eof = ftell (outstream);
  3675. +   dh.strs = eof - offset_of_debug_hunk - sizeof(dh) - dh.syms;
  3676. +   /* just to be sure, we HAVE to pad to a long-boundery */
  3677. +   if (eof & 3)
  3678. +     {
  3679. +       long zero = 0;
  3680. +       mywrite(&zero, 4 - (eof & 3), 1, outstream);
  3681. +       eof = (eof + 3) & ~3;
  3682. +     }
  3683. +   mywrite(&end_hunk, sizeof(long), 1, outstream);
  3684. +   /* ok, so calculate the size of the debug hunk. This is the 
  3685. +    * size of the debug_header plus the symbol and string tables,
  3686. +    * but it doesn't include the 2 longs, that identify the hunk and
  3687. +    * its length, whence the "- 2*sizeof(long)" */
  3688. +   size_of_debug_hunk = eof - offset_of_debug_hunk - 2*sizeof(long);
  3689. +   /* we actually need the size in longs.. */
  3690. +   size_of_debug_hunk = LONGSIZE(size_of_debug_hunk);
  3691. +   /* now first patch the debug-hunk itself, afterwards the load-file header */
  3692. +   fseek (outstream, offset_of_debug_hunk, 0);
  3693. +   dh.len = size_of_debug_hunk;
  3694. +   mywrite(&dh, sizeof dh, 1, outstream);
  3695. +   /* now the main header, this involves calculating, at which offset we
  3696. +    * find the index for the debug hunk */   
  3697. +   fseek (outstream, (5 + number_of_debug_hunk)*sizeof(long), 0);
  3698. +   mywrite(&size_of_debug_hunk, sizeof(long), 1, outstream);
  3699. +   fseek (outstream, 0L, 2);
  3700. +   /* that's it! */
  3701. + }
  3702. + /* this is the only information that we can store in a regular amiga
  3703. +  * symbol, just its value, nothing further, that's why I added the 
  3704. +  * debug-hunk-feature */
  3705. + typedef struct {
  3706. +   char *sym_name;
  3707. +   long  sym_offset;
  3708. + } simple_symbol;
  3709. + /* we'll only define symbols after at most 3 hunks, ie. the code, data
  3710. +  * and bss hunk, but not after the debug hunk, whence the index 3 */
  3711. + simple_symbol *hunk_sym_tab[3];
  3712. + int hunk_sym_tab_size[3], hunk_sym_tab_index[3];
  3713. + void
  3714. + init_symbol_hunks()
  3715. + {
  3716. +   int i;
  3717. + #if 0
  3718. +   if (trace_files) fprintf(stderr, "init_symbol_hunks()\n");
  3719. + #endif
  3720. +   for (i = 0; i < 3; i++)
  3721. +     {
  3722. +        hunk_sym_tab[i] = 
  3723. +          (simple_symbol *) xmalloc((hunk_sym_tab_size[i] = 10) * 
  3724. +        sizeof(simple_symbol));
  3725. +        hunk_sym_tab_index[i] = 0;
  3726. +     }
  3727. + }
  3728. + /* this should go into libc, well, it wasn't there, so... */
  3729. + char *
  3730. + strsave(str)
  3731. +     char *str;
  3732. + {
  3733. +   char *cp;
  3734. +   int len = strlen(str);
  3735. +   if (len)
  3736. +     {
  3737. +       cp = xmalloc(len+1);
  3738. +       strcpy(cp, str);
  3739. +     }
  3740. +   else
  3741. +     cp = NULL;
  3742. +   return cp;
  3743. + }
  3744. + void
  3745. + add_to_symbol_hunk(hunk_num, name, offset)
  3746. +     int hunk_num;
  3747. +     char *name;
  3748. +     long offset;
  3749. + {
  3750. +    if (hunk_num == -1) return;
  3751. +    if (hunk_num >= 3) fatal ("invalid hunk_number: %d\n", hunk_num);
  3752. +    /* no checks for duplicate symbols. Since it is legitimate to have
  3753. +     * symbols with the same name, we can't strip them.. just make 
  3754. +     * sure not to call this function multiple times with the same
  3755. +     * symbol, since it won't be detected, and you'll get several
  3756. +     * labels for the same offset...
  3757. +     */
  3758. +     
  3759. + #if 0
  3760. +    if (trace_files) fprintf(stderr, "add_to_symbol_hunk(%d, %s, %d)\n",
  3761. +                 hunk_num, name, offset);
  3762. + #endif
  3763. +    hunk_sym_tab[hunk_num][hunk_sym_tab_index[hunk_num]].sym_offset = offset;
  3764. +    hunk_sym_tab[hunk_num][hunk_sym_tab_index[hunk_num]++].sym_name = 
  3765. +      strsave(name);
  3766. +    if (hunk_sym_tab_index[hunk_num] == hunk_sym_tab_size[hunk_num])
  3767. +     hunk_sym_tab[hunk_num] = (simple_symbol *)
  3768. +       xrealloc(hunk_sym_tab[hunk_num],
  3769. +             (hunk_sym_tab_size[hunk_num] <<= 1) * 
  3770. +               sizeof(simple_symbol));
  3771. + }
  3772. + int
  3773. + compare_simple_symbols(l1, l2)
  3774. +     simple_symbol *l1, *l2;
  3775. + {
  3776. +   return l1->sym_offset - l2->sym_offset;
  3777. + }
  3778. + /* this writes the symbol subhunk #hunk_num, you call this just after
  3779. +  * you created your {code,data,bss}-hunk */
  3780. + void
  3781. + write_symbol_hunk(hunk_num)
  3782. +     int hunk_num;
  3783. + {
  3784. +   int i, j;
  3785. +   simple_symbol *tab;
  3786. +   long size, index;
  3787. +   if (hunk_num == -1) return;
  3788. +   if (hunk_num >= 3) fatal ("invalid hunk_number: %d\n", hunk_num);
  3789. +   
  3790. +   tab   = hunk_sym_tab[hunk_num];
  3791. +   size  = hunk_sym_tab_size[hunk_num];
  3792. +   index = hunk_sym_tab_index[hunk_num];
  3793. +    
  3794. +   /* kind of abused as general debug-flag:-) */
  3795. + #if 0
  3796. +   if (trace_files) fprintf(stderr, 
  3797. +                 "wsh: hnum=%d,size=%d,index=%d\n",
  3798. +                hunk_num,size,index);
  3799. + #endif
  3800. +    
  3801. +   if (index > 0)
  3802. +     {
  3803. +       qsort(tab, index, sizeof(simple_symbol), compare_simple_symbols);
  3804. +       j = 0x3f0; /* HUNK_SYMBOL */
  3805. +       mywrite(&j, 1, sizeof(long), outstream);
  3806. +    
  3807. +       for (i = 0; i < index; i++)
  3808. +         {
  3809. +        register simple_symbol *ss = tab+i;
  3810. +        int len = strlen (ss->sym_name);
  3811. +        j = LONGSIZE (len);
  3812. +        mywrite(&j, 1, sizeof(long), outstream);
  3813. +        mywrite(ss->sym_name, 1, len, outstream);
  3814. +        if (len < 4*j)
  3815. +          padfile (4*j - len, outstream);
  3816. +        mywrite(&(ss->sym_offset), 1, sizeof(long), outstream);
  3817. +     }
  3818. +       j = 0;
  3819. +       mywrite(&j, 1, sizeof(long), outstream);
  3820. +     }
  3821. + }
  3822. + /* now follow the quite similar routines for dealing with
  3823. +  * reloc-subhunks, the difference to the symbol-subhunks is, that reloc
  3824. +  * subhunks can be output only after the {code,data}-Hunks, AND there
  3825. +  * can be more than one after each of them */
  3826. + long *hunk_rel_tab[3];        /* Dynamically allocated tables of relocs */
  3827. + long hunk_rel_tab_size[3];    /* Size (in longs) of allocation of each table */
  3828. + long hunk_rel_tab_index[3];    /* Index of next free table entry */
  3829. + void
  3830. + init_reloc_hunk()
  3831. + {
  3832. +   int i;
  3833. + #if 0
  3834. +   if (trace_files) fprintf(stderr, "init_reloc_hunk()\n");
  3835. + #endif
  3836. +   for (i = 0; i < 3; i++)
  3837. +     {
  3838. +        hunk_rel_tab[i] = 
  3839. +          (long *) xmalloc((hunk_rel_tab_size[i] = 10) * sizeof(long));
  3840. +        hunk_rel_tab_index[i] = 0;
  3841. +     }
  3842. + }
  3843. + void
  3844. + add_to_reloc_hunk(hunk_num, offset)
  3845. +     int hunk_num;
  3846. +     long offset;
  3847. + {
  3848. +    /* no checks for duplicate symbols, they will show up when we sort
  3849. +     * the table, and we will strip them off before writing out the table */
  3850. + #if 0
  3851. +    if (trace_files) fprintf(stderr, "add_to_reloc_hunk(%d, %d)\n", hunk_num, offset);
  3852. + #endif
  3853. +    hunk_rel_tab[hunk_num][hunk_rel_tab_index[hunk_num]++] = offset;
  3854. +    if (hunk_rel_tab_index[hunk_num] == hunk_rel_tab_size[hunk_num])
  3855. +     hunk_rel_tab[hunk_num] = (long *)
  3856. +       xrealloc(hunk_rel_tab[hunk_num],
  3857. +                    (hunk_rel_tab_size[hunk_num] <<= 1) * sizeof(long));
  3858. + }
  3859. + int
  3860. + compare_longs(l1, l2)
  3861. +     long *l1, *l2;
  3862. + {
  3863. +   return *l1 - *l2;
  3864. + }
  3865. + int
  3866. + compare_strings (s1p, s2p)
  3867. +     char **s1p;
  3868. +     char **s2p;
  3869. + {
  3870. +   return (strcmp (*s1p, *s2p));
  3871. + }
  3872. + void
  3873. + write_reloc_hunk()
  3874. + {
  3875. +    int i, j;
  3876. +    long *tab, size, index, nwritten, nleft, nwrite;
  3877. +    /* only write a hunk-header & -end, if we really output some relocs */
  3878. +    int did_start_hunk = 0;
  3879. +    for (i = 0; i < 3; i++)
  3880. +      {
  3881. +     tab   = hunk_rel_tab[i];
  3882. +     size  = hunk_rel_tab_size[i];
  3883. +     index = hunk_rel_tab_index[i];
  3884. +     /* kind of abused as general debug-flag:-) */
  3885. + #if 0
  3886. +         if (trace_files) fprintf(stderr, 
  3887. +                  "wrh: i=%d,size=%d,index=%d\n",
  3888. +                  i,size,index);
  3889. + #endif
  3890. +         if (index > 0)
  3891. +       {
  3892. +         qsort(tab, index, sizeof(long), compare_longs);
  3893. +         /* kick out duplicate symbols.. I don't know, what
  3894. +          * the loader would do, if it had to relocate the same
  3895. +          * address twice.. BTW: can this happen or can't it???? */
  3896. +         for (j = 0; j < index-1; )
  3897. +           {
  3898. +         if (tab[j] == tab[j+1])
  3899. +           bcopy(tab+j+1, tab+j, ((index--)-j-1)*sizeof(long));
  3900. +         else
  3901. +           j++;
  3902. +           }
  3903. +         hunk_rel_tab_index[i] = index;
  3904. +         if (!did_start_hunk++)
  3905. +           {
  3906. +         j = 0x3ec; /* HUNK_RELOC32 */
  3907. +         mywrite(&j, 1, sizeof(long), outstream);
  3908. +           }
  3909. +         /* Starting apparently with AmigaDOS 2.0, the number of
  3910. +            offsets per hunk number must not exceed 65536.  So
  3911. +            split large tables into smaller ones. */
  3912. +         nwritten = 0;
  3913. +         nleft = index;
  3914. +         do
  3915. +           {
  3916. +         nwrite = min (nleft, 65536);
  3917. + #if 0
  3918. +         if (trace_files)
  3919. +           fprintf (stderr, "wrh: nwritten %d, nleft %d, nwrite %d\n",
  3920. +                nwritten, nleft, nwrite);
  3921. + #endif
  3922. +         mywrite(&nwrite, 1, sizeof(long), outstream);
  3923. +         mywrite(&i, 1, sizeof(long), outstream);
  3924. +         mywrite(tab + nwritten, 1, nwrite*sizeof(long), outstream);
  3925. +         nwritten += nwrite;
  3926. +         nleft -= nwrite;
  3927. +           } while (nleft > 0);
  3928. +       }
  3929. +      }
  3930. +    if (did_start_hunk)
  3931. +      {
  3932. +     j = 0;
  3933. +        mywrite(&j, 1, sizeof(long), outstream);
  3934. +      }
  3935. + }
  3936. + void
  3937. + write_datadata_relocs ()
  3938. + {
  3939. +   int numdd, i, prev;
  3940. +   prev = ftell (outstream);
  3941. +   fseek (outstream, datadata_relocs_offset, L_SET);
  3942. +   
  3943. +   numdd = hunk_rel_tab_index[number_of_data_hunk];
  3944. +   if (numdd > numdatadata_relocs)
  3945. +     fatal ("found more data-data relocs than estimated!\n", 0);
  3946. +   
  3947. +   mywrite (&numdd, 1, sizeof (long), outstream);
  3948. +   if (numdd)
  3949. +     mywrite (hunk_rel_tab[number_of_data_hunk], numdd, sizeof (long), outstream);
  3950. +   fseek (outstream, prev, L_SET);
  3951. + }
  3952. + /* create the bss hunk if needed */
  3953. + void
  3954. + write_bss()
  3955. + {
  3956. +   long bss_hunk[2];
  3957. +   if (!databss_together && bss_size)
  3958. +    {
  3959. +      if (trace_files)
  3960. +        fprintf (stderr, "Write BSS hunk at 0x%x\n", ftell (outstream));
  3961. +      bss_hunk[0] = 0x3eb;
  3962. +      bss_hunk[1] = LONGSIZE(bss_size);
  3963. +      mywrite(bss_hunk, 1, sizeof bss_hunk, outstream);
  3964. +      write_symbol_hunk(number_of_bss_hunk);
  3965. +      bss_hunk[0] = 0x3f2; /* HUNK_END */
  3966. +      mywrite(bss_hunk, 1, sizeof(long), outstream);
  3967. +    }
  3968. + }
  3969. + /* this scans one object file for its symbols, and deposits them in 
  3970. +  * the symbol-hunk tables for later output */
  3971. + void
  3972. + look_for_file_syms (entry)
  3973. +      struct file_entry *entry;
  3974. + {
  3975. +   register struct nlist *p = entry->symbols;
  3976. +   register struct nlist *end = p + entry->syms_size / sizeof (struct nlist);
  3977. + #if 0
  3978. +   /* don't do this, it only confuses most amiga disassemblers.. */
  3979. +   /* Generate a local symbol for the start of this file's text.  */
  3980. +   if (discard_locals != DISCARD_ALL)
  3981. +     add_to_symbol_hunk(number_of_code_hunk, entry->local_sym_name, 
  3982. +        entry->text_start_address);
  3983. + #endif
  3984. +   /* Read the file's string table.  */
  3985. +   entry->strings = (char *) alloca (entry->strs_size);
  3986. +   read_entry_strings (file_open (entry), entry);
  3987. +   for (; p < end; p++)
  3988. +     {
  3989. +       register unsigned char type = p->n_type;
  3990. +       register int write = 0;
  3991. +       int this_hunk;
  3992. +       char *cp;
  3993. +       /* WRITE gets 1 for a non-global symbol that should be written.  */
  3994. +       if (SET_ELEMENT_P (type))    /* This occurs even if global.  These */
  3995. +                 /* types of symbols are never written */
  3996. +                 /* globally, though they are stored */
  3997. +                 /* globally.  */
  3998. +         write = output_style == OUTPUT_RELOCATABLE;
  3999. +       else if (!(type & (N_STAB | N_EXT)))
  4000. +           /* ordinary local symbol */
  4001. +       write = ((discard_locals != DISCARD_ALL)
  4002. +            && !(discard_locals == DISCARD_L &&
  4003. +                (p->n_un.n_strx + entry->strings)[0] == LPREFIX)
  4004. +            && type != N_WARNING);
  4005. +       else if (!(type & N_EXT))
  4006. +     /* debugger symbol */
  4007. +         write = (strip_symbols == STRIP_NONE);
  4008. +       /* skip STAB symbols if present */
  4009. +       write = write && !(type & N_STAB);
  4010. +       /* those weird types are NOT output in the normal symbols:-)) */
  4011. +       write = write && (type != N_ABS && type != (N_ABS|N_EXT));
  4012. +       /* don't know where those symbols come from, they're well suited to
  4013. +        * crash enforcer, and they're not `real' symbols anyway.. */
  4014. +       if (p->n_un.n_strx > entry->strs_size) continue;
  4015. +       /* symbols that end with a dot are only useful for gdb, 
  4016. +        * not for a normal amiga debugger (currently gcc_compiled. and
  4017. +        * gcc_compiled2.) so skip them in this section */
  4018. +       /* check to see, whether this string ends with a dot */
  4019. +       if (write && p->n_un.n_strx)
  4020. +         {
  4021. +           cp = rindex (p->n_un.n_strx + entry->strings, '.');
  4022. +       write = write && !(cp && !cp[1]);
  4023. +       
  4024. + #if 0
  4025. +       printf ("%s >%s<\n", write ? "adding" : "skipping", p->n_un.n_strx + entry->strings);
  4026. + #endif
  4027. +     }
  4028. +       if (write)
  4029. +     {
  4030. +       if (p->n_un.n_strx)
  4031. +         {
  4032. +           switch (type & ~N_EXT)
  4033. +             {
  4034. +           case N_TEXT:
  4035. +             this_hunk = number_of_code_hunk;
  4036. +             break;
  4037. +           case N_SETV:
  4038. +           case N_DATA:
  4039. +             this_hunk = number_of_data_hunk;
  4040. +             break;
  4041. +           case N_UNDF:
  4042. +           case N_BSS:
  4043. +             this_hunk = number_of_bss_hunk;
  4044. +             break;
  4045. +           default:
  4046. +             error ("unknown type %d while trying to build lsymhunk", type);
  4047. +             goto skip1;
  4048. +             }
  4049. +           add_to_symbol_hunk(this_hunk, p->n_un.n_strx + entry->strings,
  4050. +                  p->n_value);
  4051. + skip1:    ;
  4052. +             }
  4053. +     }
  4054. +     }
  4055. + }
  4056. + /* scan all input files for symbols and store them in the symbolhunk tables */
  4057. + void
  4058. + look_for_symbols()
  4059. + {
  4060. +   int this_hunk;
  4061. +   int i;
  4062. +   symbol *sp;
  4063. +   if (strip_symbols == STRIP_ALL)
  4064. +     return;
  4065. +   /* Write the local symbols defined by the various files.  */
  4066. +   each_file (look_for_file_syms, 0);
  4067. +   file_close ();
  4068. +   /* Scan the symbol hash table, bucket by bucket.  */
  4069. +   for (i = 0; i < TABSIZE; i++)
  4070. +     for (sp = symtab[i]; sp; sp = sp->link)
  4071. +       {
  4072. +     struct nlist nl;
  4073. +     /* Compute a `struct nlist' for the symbol.  */
  4074. +     nl.n_value = 0;
  4075. +     if (sp->defined || sp->referenced)
  4076. +       {
  4077. +         /* common condition needs to be before undefined condition */
  4078. +         /* because unallocated commons are set undefined in */
  4079. +         /* digest_symbols */
  4080. +         if (sp->defined > 1) /* defined with known type */
  4081. +           {
  4082. +         /* If the target of an indirect symbol has been
  4083. +            defined and we are outputting an executable,
  4084. +            resolve the indirection; it's no longer needed */
  4085. +         if (output_style != OUTPUT_RELOCATABLE
  4086. +             && ((sp->defined & ~N_EXT) == N_INDR)
  4087. +             && (((symbol *) sp->value)->defined > 1))
  4088. +           {
  4089. +             symbol *newsp = (symbol *) sp->value;
  4090. +             nl.n_type = newsp->defined;
  4091. +             nl.n_value = newsp->value;
  4092. +           }
  4093. +         else
  4094. +           {
  4095. +             nl.n_type = sp->defined;
  4096. +             if (sp->defined != (N_INDR | N_EXT))
  4097. +               nl.n_value = sp->value;
  4098. +             else
  4099. +               nl.n_value = 0;
  4100. +           }
  4101. +           }
  4102. +         else if (sp->max_common_size) /* defined as common but not allocated. */
  4103. +           {
  4104. +         /* happens only with -r and not -d */
  4105. +         /* write out a common definition */
  4106. +         nl.n_type = N_UNDF | N_EXT;
  4107. +         nl.n_value = sp->max_common_size;
  4108. +           }
  4109. +         else if (!sp->defined)          /* undefined -- legit only if -r */
  4110. +           {
  4111. +         nl.n_type = N_UNDF | N_EXT;
  4112. +         nl.n_value = 0;
  4113. +           }
  4114. +         else
  4115. +           fatal ("internal error: %s defined in mysterious way", sp->name);
  4116. +         switch (nl.n_type & ~N_EXT)
  4117. +           {
  4118. +         case N_TEXT:
  4119. +           this_hunk = number_of_code_hunk;
  4120. +           break;
  4121. +         case N_SETV:
  4122. +         case N_DATA:
  4123. +           this_hunk = number_of_data_hunk;
  4124. +           break;
  4125. +         case N_UNDF:
  4126. +         case N_BSS:
  4127. +           this_hunk = number_of_bss_hunk;
  4128. +           break;
  4129. +         case N_ABS:
  4130. +           break;
  4131. +         default:
  4132. +           error ("unknown type %d while trying to build symhunk", nl.n_type);
  4133. +           goto skip2;
  4134. +           }
  4135. +         /* sigh, there is no equivalent in the symbol section of a load
  4136. +          * file on the amiga, have to forget about those symbols */
  4137. +         if ((nl.n_type & ~N_EXT) == N_ABS)
  4138. +           continue;
  4139. +         add_to_symbol_hunk(this_hunk, sp->name, nl.n_value);
  4140. + skip2:    ;
  4141. +       }
  4142. +       }
  4143. + }
  4144. + void
  4145. + relocate_set_vectors (vectors, relvectors, num_entries)
  4146. +     unsigned long *vectors;
  4147. +     unsigned char *relvectors;
  4148. +     int num_entries;
  4149. + {
  4150. +   unsigned long i;
  4151. +   unsigned long offset = set_sect_start;
  4152. +   int hunk_num;
  4153. +   while (num_entries-- > 0)
  4154. +     {
  4155. +       /* the number of entries for this symbol */
  4156. +       i = *vectors++; offset += 4; relvectors++;
  4157. +       while (num_entries --, i--)
  4158. +     {
  4159. +       /* relocation ok? */
  4160. +       if (*relvectors)
  4161. +         {
  4162. +           hunk_num = number_of_code_hunk;
  4163. +           if (*vectors >= text_size)
  4164. +             {
  4165. +           if (*vectors >= text_size + data_size)
  4166. +             {
  4167. +               hunk_num = number_of_bss_hunk;
  4168. +               if (databss_together)
  4169. +                 *vectors -= text_size;
  4170. +               else
  4171. +                 *vectors -= text_size + data_size;
  4172. +             }
  4173. +           else
  4174. +             {
  4175. +               hunk_num = number_of_data_hunk;
  4176. +               *vectors -= text_size;
  4177. +             }
  4178. +             }
  4179. +           add_to_reloc_hunk (hunk_num, offset);
  4180. +         }
  4181. +       ++vectors;
  4182. +       offset += 4;
  4183. +       ++relvectors;
  4184. +     }
  4185. +       /* check.. HAS to be zero */
  4186. +       if (*vectors)
  4187. +     fatal ("set-vector corrupt, num_entries = %d", num_entries);
  4188. +       vectors++; offset += 4; relvectors++; --num_entries;
  4189. +     }
  4190. + }
  4191. + #endif
  4192. diff -rc --new-file binutils-1.8.x-base/objdump.c binutils-1.8.x/objdump.c
  4193. *** binutils-1.8.x-base/objdump.c    Sat Dec 30 00:16:07 1989
  4194. --- binutils-1.8.x/objdump.c    Wed Sep 22 12:45:32 1993
  4195. ***************
  4196. *** 24,31 ****
  4197.   #include <stdio.h>
  4198.   #include "getopt.h"
  4199.   
  4200.   #ifndef COFF_ENCAPSULATE
  4201. ! #include <a.out.h>
  4202.   /* Tell a.out.gnu.h not to try to redefine some things.  */
  4203.   #define __STRUCT_EXEC_OVERRIDE__
  4204.   #define N_NLIST_DECLARED
  4205. --- 24,35 ----
  4206.   #include <stdio.h>
  4207.   #include "getopt.h"
  4208.   
  4209. + #ifdef MCH_AMIGA
  4210. + #define getpagesize() 256
  4211. + #endif
  4212.   #ifndef COFF_ENCAPSULATE
  4213. ! #include <sun/a.out.h>
  4214.   /* Tell a.out.gnu.h not to try to redefine some things.  */
  4215.   #define __STRUCT_EXEC_OVERRIDE__
  4216.   #define N_NLIST_DECLARED
  4217. diff -rc --new-file binutils-1.8.x-base/ranlib.c binutils-1.8.x/ranlib.c
  4218. *** binutils-1.8.x-base/ranlib.c    Thu Mar  1 00:18:42 1990
  4219. --- binutils-1.8.x/ranlib.c    Sat Feb  5 12:31:20 1994
  4220. ***************
  4221. *** 54,60 ****
  4222.      as the location of the GNU AR program.  */
  4223.   
  4224.   char *prog = AR_PROG;
  4225. ! char *prog_pref = "/usr/local/gnubin/ar";
  4226.   
  4227.   int
  4228.   main (argc, argv)
  4229. --- 54,60 ----
  4230.      as the location of the GNU AR program.  */
  4231.   
  4232.   char *prog = AR_PROG;
  4233. ! char *prog_pref = "/gnu/bin/ar";
  4234.   
  4235.   int
  4236.   main (argc, argv)
  4237. diff -rc --new-file binutils-1.8.x-base/strip.c binutils-1.8.x/strip.c
  4238. *** binutils-1.8.x-base/strip.c    Mon Jun 11 21:40:01 1990
  4239. --- binutils-1.8.x/strip.c    Wed Sep 22 12:45:42 1993
  4240. ***************
  4241. *** 71,77 ****
  4242.   
  4243.   /* If BSD, we can use `ftruncate'.  */
  4244.   
  4245. ! #ifndef USG
  4246.   #define HAVE_FTRUNCATE
  4247.   #endif
  4248.   
  4249. --- 71,77 ----
  4250.   
  4251.   /* If BSD, we can use `ftruncate'.  */
  4252.   
  4253. ! #if !defined(USG) && !defined(MCH_AMIGA)
  4254.   #define HAVE_FTRUNCATE
  4255.   #endif
  4256.   
  4257. ***************
  4258. *** 287,294 ****
  4259. --- 287,296 ----
  4260.       signal (SIGTERM, SIG_DFL);
  4261.   
  4262.     /* Handle any signal that came in while they were deferred.  */
  4263. + #ifndef MCH_AMIGA
  4264.     if (delayed_signal)
  4265.       kill (getpid (), delayed_signal);
  4266. + #endif
  4267.   }
  4268.   
  4269.   /** Convenient functions for operating on one or all files being processed.  */
  4270. ***************
  4271. *** 928,933 ****
  4272. --- 930,936 ----
  4273.   }
  4274.   
  4275.   #ifdef USG
  4276. + #ifndef MCH_AMIGA
  4277.   
  4278.   rename (from, to)
  4279.        char *from, *to;
  4280. ***************
  4281. *** 940,945 ****
  4282. --- 943,949 ----
  4283.       return 0;
  4284.   }
  4285.   
  4286. + #endif
  4287.   #endif
  4288.   
  4289.   usage ()
  4290.