home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / src / diffs / binutils-1.8.x.diffs < prev    next >
Encoding:
Text File  |  1995-01-21  |  126.6 KB  |  4,551 lines

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