home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / xenix-gnu / part01 / gcc-1.40.pch next >
Encoding:
Text File  |  1991-09-27  |  40.2 KB  |  1,343 lines

  1. *** gcc-1.40/Makefile    Mon Jul 29 13:15:49 1991
  2. --- Makefile    Mon Jul 29 13:45:38 1991
  3. ***************
  4. *** 157,162 ****
  5. --- 157,167 ----
  6.   # HARD_PARAMS_FLAGS= -Anansi
  7.   # (Says vasta@apollo.com.)
  8.   
  9. + # To compile GCC with Microsoft CC use the following CFLAGS and then
  10. + # 'make msc'.  Note that the resultant cc1 CANNOT compile with optimization
  11. + # switched on, ie stage 2 should not have '-O' in CFLAGS
  12. + CFLAGS = -g $(XCFLAGS)
  13. + PRAGMA=pragmapack.o
  14.   
  15.   # Dependency on obstack, alloca, malloc or whatever library facilities
  16.   # are not installed in the system libraries.
  17. ***************
  18. *** 192,198 ****
  19.    symout.o dbxout.o sdbout.o emit-rtl.o insn-emit.o \
  20.    integrate.o jump.o cse.o loop.o flow.o stupid.o combine.o \
  21.    regclass.o local-alloc.o global-alloc.o reload.o reload1.o caller-save.o \
  22. !  insn-peep.o final.o recog.o insn-recog.o insn-extract.o insn-output.o
  23.   
  24.   # Files to be copied away after each stage in building.
  25.   STAGE_GCC=gcc
  26. --- 197,203 ----
  27.    symout.o dbxout.o sdbout.o emit-rtl.o insn-emit.o \
  28.    integrate.o jump.o cse.o loop.o flow.o stupid.o combine.o \
  29.    regclass.o local-alloc.o global-alloc.o reload.o reload1.o caller-save.o \
  30. !  insn-peep.o final.o recog.o insn-recog.o insn-extract.o insn-output.o $(PRAGMA)
  31.   
  32.   # Files to be copied away after each stage in building.
  33.   STAGE_GCC=gcc
  34. ***************
  35. *** 239,244 ****
  36. --- 244,257 ----
  37.   # is include the system varargs.h.
  38.   
  39.   all: config.status gnulib gcc cc1 cpp float.h gnulib2 # cc1plus
  40. + msc: config.status gnulib cc1 cpp float.h gcc.msc gnulib2 # cc1plus
  41. + gcc.msc:    cc1 cpp version.o $(LIBDEPS)
  42. +     ./cpp -I/usr/include $(CPPFLAGS) $(INCLUDES) gcc.c > tmpgcc.i
  43. +     -./cc1 -quiet $(CFLAGS) -o tmpgcc.s tmpgcc.i
  44. +     /usr/local/lib/gcc-as -o gcc.o tmpgcc.s
  45. +     rm -f tmpgcc.s
  46. +     $(CC) $(CFLAGS) $(LDFLAGS) -o gcc gcc.o version.o $(LIBS)
  47.   
  48.   # Use this instead of `all' if you need to convert the libraries
  49.   # before you can use the compiler.
  50. ***************
  51. *** 433,440 ****
  52.   # from the GNU Emacs distribution.
  53.   # Note some machines won't allow $(CC) without -S on this source file.
  54.   alloca.o:    alloca.c
  55. !     $(CC) $(CFLAGS) -S `echo $(srcdir)/alloca.c | sed 's,^\./,,'`
  56. !     as alloca.s -o alloca.o
  57.   
  58.   # Now the source files that are generated from the machine description.
  59.   
  60. --- 446,452 ----
  61.   # from the GNU Emacs distribution.
  62.   # Note some machines won't allow $(CC) without -S on this source file.
  63.   alloca.o:    alloca.c
  64. !     $(CC) $(CFLAGS) -c `echo $(srcdir)/alloca.c | sed 's,^\./,,'`
  65.   
  66.   # Now the source files that are generated from the machine description.
  67.   
  68. *** gcc-1.40/Makefile.msc
  69. --- Makefile.msc    Wed Jul 10 16:36:39 1991
  70. ***************
  71. *** 0 ****
  72. --- 1,22 ----
  73. + # Microsoft C 5.1's built in cpp does not grok the large macros.
  74. + # Therefore use the AT&T cpp instead for the files that fail.
  75. + # Use this command line:
  76. + #    make -f Makefile -f Makefile.msc msc ALLOCA=alloca.o
  77. + explow.o:    explow.c
  78. +     /lib/cpp -P ${INCLUDES} explow.c >explow.i
  79. +     mv explow.i x.c
  80. +     cc ${CFLAGS} -c x.c
  81. +     mv x.o explow.o
  82. + reload.o:    reload.c
  83. +     /lib/cpp -P ${INCLUDES} reload.c >reload.i
  84. +     mv reload.i x.c
  85. +     cc ${CFLAGS} -c x.c
  86. +     mv x.o reload.o
  87. + recog.o:    recog.c
  88. +     /lib/cpp -P ${INCLUDES} recog.c >recog.i
  89. +     mv recog.i x.c
  90. +     cc ${CFLAGS} -c x.c
  91. +     mv x.o recog.o
  92. *** gcc-1.40/c-parse.y    Mon Jul 29 13:15:54 1991
  93. --- c-parse.y    Wed Jul 10 15:56:21 1991
  94. ***************
  95. *** 1803,1808 ****
  96. --- 1803,1849 ----
  97.             && getc (finput) == 'm'
  98.             && getc (finput) == 'a'
  99.             && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
  100. + #ifdef PRAGMA_PACK
  101. +       {
  102. +         token = yylex();
  103. +             if (token != IDENTIFIER) 
  104. +             goto skipline;
  105. +             if (strcmp(token_buffer, "pack") != 0)
  106. +                 goto skipline;
  107. +         
  108. +         token = yylex();
  109. +           if (token != '(') {
  110. +             error ("invalid #pragma pack expecting '('");
  111. +             goto skipline;
  112. +         }
  113. +         /* setup default alignment first */
  114. +         pragma_pack_default();
  115. +         token = yylex();
  116. +         if (token != ')')
  117. +         {
  118. +             if (token == CONSTANT
  119. +                 && TREE_CODE (yylval.ttype) == INTEGER_CST) {
  120. +                 int l = TREE_INT_CST_LOW (yylval.ttype);
  121. +                 pragma_pack(l);
  122. +             }
  123. +             else {
  124. +                 error ("invalid #pragma pack expecting 1, 2 or 4");
  125. +                 goto skipline;
  126. +             }
  127. +             token = yylex();
  128. +         }
  129. +           if (token != ')') {
  130. +             error ("invalid #pragma pack expecting ')'");
  131. +             goto skipline;
  132. +         }
  133. +         }
  134. + #endif
  135.           goto skipline;
  136.       }
  137.   
  138. *** gcc-1.40/config/tm-xenix386.h
  139. --- config/tm-xenix386.h    Thu Aug 22 15:28:27 1991
  140. ***************
  141. *** 0 ****
  142. --- 1,146 ----
  143. + /* Definitions for Intel 386 running SCO XENIX 386.
  144. +    Copyright (C) 1988 Free Software Foundation, Inc.
  145. + This file is part of GNU CC.
  146. + GNU CC is free software; you can redistribute it and/or modify
  147. + it under the terms of the GNU General Public License as published by
  148. + the Free Software Foundation; either version 1, or (at your option)
  149. + any later version.
  150. + GNU CC is distributed in the hope that it will be useful,
  151. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  152. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  153. + GNU General Public License for more details.
  154. + You should have received a copy of the GNU General Public License
  155. + along with GNU CC; see the file COPYING.  If not, write to
  156. + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  157. + #include "tm-i386.h"
  158. + /* Use the XENIX GAS assembler syntax.  */
  159. + #include "tm-xgas386.h"
  160. + /* By default, target has a 80387 -- XENIX emulates it anyway  */
  161. + #define TARGET_DEFAULT 1
  162. + /* Use crt1.o as a startup file and crtn.o as a closing file.  */
  163. + #define STARTFILE_SPEC  "Sseg.o%s %{!p:Scrt0.o%s} %{p:Smcrt0.o%s}"
  164. + #define STANDARD_STARTFILE_PREFIX_1 "/lib/386/"
  165. + /* -v is appropriate for use with GAS */
  166. + #define ASM_SPEC    "%{v} %{g}"
  167. + #define LIB_SPEC "Slibcfp.a%s Slibc.a%s"
  168. + #define FULL_LINK_SPEC "%{!c:%{!M*:%{!E:%{!S:ld %{o*} %l %{g:-g} \
  169. +  %{A} %{r} %{s} %{u*} \
  170. +  %{!nostdlib:%S} %{L*} %{!o:-o a.out} %o %{!nostdlib:gnulib%s %L gnulib%s}\n \
  171. +   }}}}";
  172. + #define LINK_SPEC "-i"
  173. + /* This is for use with G++.  FASCIST_LDR is defined in G++'s Makefile */
  174. + #ifdef FASCIST_LDR
  175. + #define FULL_COLLECT_SPEC \
  176. +   "%{!c:%{!M*:%{!E:%{!S:collect -o %g.S %g.R\n\
  177. + as %g.S -o %g.O\n\
  178. + ld %{o*} %{!o:-o a.out} %{!nostdlib:%S } %l %{g:-g} \
  179. + %{L*} %o %g.O %{!nostdlib:gnulib++%s gnulib%s %L } \n\
  180. + }}}}"
  181. + #define PLUS_FULL_LINK_SPEC \
  182. +   "%{!c:%{!M*:%{!E:%{!S:ld -o %g.R \
  183. +   %{!nostdlib:%S } %l %{g:-g}\
  184. +   %{L*} %o %{!nostdlib:gnulib++%s gnulib%s g++dummy%s %L }\n }}}}";
  185. + #else /* not FASCIST_LDR */
  186. + #define FULL_COLLECT_SPEC \
  187. +   "%{!c:%{!M*:%{!E:%{!S:collect -o %g.S %g.R\n\
  188. + as %g.S -o %g.O\n\
  189. + ld %{o*} %{!o:-o a.out} %{!nostdlib:%S } %g.R %g.O \
  190. +   %{!nostdlib:gnulib++%s gnulib%s %L } \n\
  191. + }}}}"
  192. + #define PLUS_FULL_LINK_SPEC \
  193. +   "%{!c:%{!M*:%{!E:%{!S:ld -r -o %g.R %l %{g:-g}\
  194. +   %{L*} %o %{!nostdlib:%L }\n }}}}";
  195. + #endif /* not FASCIST_LDR */
  196. + /* Specify predefined symbols in preprocessor.  */
  197. + /* You may wish to add -DM_INTERNAT, depending on your libraries. */
  198. + #define CPP_PREDEFINES "-Dunix \
  199. + -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT -DM_I386 -DM_XENIX -DM_BITFIELDS \
  200. + -Di386 -DM_XOUT -DM_SYS5 -DM_SYSV -DM_SYS3 -DM_SYSIII \
  201. + -DM_WORDSWAP"
  202. + /* no #sccs in preprocessor.  */
  203. + #undef SCCS_DIRECTIVE
  204. + /* no #ident */
  205. + /* #define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); */
  206. + /* We dont want to output SDB debugging information.  */
  207. + #undef SDB_DEBUGGING_INFO
  208. + /* We want to output DBX debugging information, for use with GDB only  */
  209. + #define DBX_DEBUGGING_INFO
  210. + /* Implicit library calls should use memcpy, not bcopy, etc.  */
  211. + #define TARGET_MEM_FUNCTIONS
  212. + /* Writing `int' for a bitfield forces int alignment for the structure.  */
  213. + #undef PCC_BITFIELD_TYPE_MATTERS
  214. + /* Generate an external symbol request for __fltused if 80387 selected */
  215. + #undef ASM_FILE_START
  216. + #define ASM_FILE_START(FILE)                    \
  217. +   { fprintf (FILE, "\t.file\t\"%s\"\n", dump_base_name);     \
  218. +     if (TARGET_80387)                         \
  219. +       fprintf (FILE, "\t.stabs\t\"__fltused\",0,0,0,0\n"); }
  220. + /* Machines that use the AT&T assembler syntax
  221. +    also return floating point values in an FP register.  */
  222. + /* Define how to find the value returned by a function.
  223. +    VALTYPE is the data type of the value (as a tree).
  224. +    If the precise function being called is known, FUNC is its FUNCTION_DECL;
  225. +    otherwise, FUNC is 0.  */
  226. + #define VALUE_REGNO(MODE) \
  227. +   (((MODE)==SFmode || (MODE)==DFmode) ? FIRST_FLOAT_REG : 0)
  228. + /* 1 if N is a possible register number for a function value. */
  229. + #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N)== FIRST_FLOAT_REG)
  230. + /* Put address tables in data segment */
  231. + #undef ASM_OUTPUT_CASE_LABEL
  232. + #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE)    \
  233. +   { data_section();                        \
  234. +     ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM); }
  235. + #undef ASM_OUTPUT_CASE_END
  236. + #define ASM_OUTPUT_CASE_END(FILE,NUM,INSN) text_section()
  237. + #undef FUNCTION_PROFILER
  238. + #define FUNCTION_PROFILER(FILE, LABELNO)  \
  239. +    fprintf (FILE, "\tmovl $%sP%d,%%edx\n\tcall __mcount\n", LPREFIX, (LABELNO));
  240. *** gcc-1.40/config/tm-xgas386.h
  241. --- config/tm-xgas386.h    Wed Jul 10 15:56:17 1991
  242. ***************
  243. *** 0 ****
  244. --- 1,253 ----
  245. + /* Definitions for AT&T assembler syntax for the Intel 80386.
  246. +    Copyright (C) 1988 Free Software Foundation, Inc.
  247. + This file is part of GNU CC.
  248. + GNU CC is free software; you can redistribute it and/or modify
  249. + it under the terms of the GNU General Public License as published by
  250. + the Free Software Foundation; either version 1, or (at your option)
  251. + any later version.
  252. + GNU CC is distributed in the hope that it will be useful,
  253. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  254. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  255. + GNU General Public License for more details.
  256. + You should have received a copy of the GNU General Public License
  257. + along with GNU CC; see the file COPYING.  If not, write to
  258. + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  259. + #ifdef PRAGMA_PACK
  260. + #define TARGET_VERSION fprintf (stderr, " (80386, Xenix GAS syntax, #pragma pack() support included)");
  261. + #else
  262. + #define TARGET_VERSION fprintf (stderr, " (80386, Xenix GAS syntax)");
  263. + #endif
  264. + /* Define the syntax of instructions and addresses.  */
  265. + /* Define some concatenation macros to concatenate an opcode
  266. +    and one, two or three operands.  In other assembler syntaxes
  267. +    they may alter the order of ther operands.  */
  268. + #ifdef __STDC__
  269. + #define AS2(a,b,c) #a " " #b "," #c
  270. + #define AS3(a,b,c,d) #a " " #b "," #c "," #d
  271. + #define AS1(a,b) #a " " #b
  272. + #else
  273. + #define AS1(a,b) "a b"
  274. + #define AS2(a,b,c) "a b,c"
  275. + #define AS3(a,b,c,d) "a b,c,d"
  276. + #endif  
  277. + /* Output the size-letter for an opcode.
  278. +    CODE is the letter used in an operand spec (L, B, W, S or Q).
  279. +    CH is the corresponding lower case letter
  280. +      (except if CODE is L then CH is `l').  */
  281. + #define PUT_OP_SIZE(CODE,CH,FILE) putc (CH,(FILE))
  282. + /* Opcode suffix for fullword insn.  */
  283. + #define L_SIZE "l"
  284. + /* Prefix for register names in this syntax.  */
  285. + #define RP "%"
  286. + /* Prefix for immediate operands in this syntax.  */
  287. + #define IP "$"
  288. + /* Prefix for internally generated assembler labels.  */
  289. + #define LPREFIX ".L"
  290. + /* Output the prefix for an immediate operand, or for an offset operand.  */
  291. + #define PRINT_IMMED_PREFIX(FILE)  fputs ("$", (FILE))
  292. + #define PRINT_OFFSET_PREFIX(FILE)  fputs ("$", (FILE))
  293. + /* Indirect call instructions should use `*'.  */
  294. + #define USE_STAR 1
  295. + /* Prefix for a memory-operand X.  */
  296. + #define PRINT_PTR(X, FILE)
  297. + /* Delimiters that surround base reg and index reg.  */
  298. + #define ADDR_BEG(FILE) putc('(', (FILE))
  299. + #define ADDR_END(FILE) putc(')', (FILE))
  300. + /* Print an index register (whose rtx is IREG).  */
  301. + #define PRINT_IREG(FILE,IREG) \
  302. +   do                                \
  303. +   { fputs (",", (FILE)); PRINT_REG ((IREG), 0, (FILE)); }    \
  304. +   while (0)
  305. +   
  306. + /* Print an index scale factor SCALE.  */
  307. + #define PRINT_SCALE(FILE,SCALE) \
  308. +   if ((SCALE) != 1) fprintf ((FILE), ",%d", (SCALE))
  309. + /* Print a base/index combination.
  310. +    BREG is the base reg rtx, IREG is the index reg rtx,
  311. +    and SCALE is the index scale factor (an integer).  */
  312. + #define PRINT_B_I_S(BREG,IREG,SCALE,FILE) \
  313. +   { ADDR_BEG (FILE);                 \
  314. +     if (BREG) PRINT_REG ((BREG), 0, (FILE));    \
  315. +     if ((IREG) != 0)                \
  316. +       { PRINT_IREG ((FILE), (IREG));        \
  317. +         PRINT_SCALE ((FILE), (SCALE)); }    \
  318. +     ADDR_END (FILE); }
  319. + /* Define the syntax of pseudo-ops, labels and comments.  */
  320. + /* Assembler pseudos to introduce constants of various size.  */
  321. + #define ASM_BYTE "\t.byte "
  322. + #define ASM_SHORT "\t.value "
  323. + #define ASM_LONG "\t.long "
  324. + #define ASM_DOUBLE "\t.double "
  325. + /* String containing the assembler's comment-starter.  */
  326. + #define COMMENT_BEGIN "/"
  327. + /* Output at beginning of assembler file.  */
  328. + /* The .file command should always begin the output.  */
  329. + #undef ASM_FILE_START
  330. + #define ASM_FILE_START(FILE) \
  331. +   fprintf (FILE, "\t.file\t\"%s\"\n", dump_base_name);
  332. + /* Don't write a `.optim' pseudo; this assembler doesn't handle them.  */
  333. + #undef ASM_FILE_START_1
  334. + #define ASM_FILE_START_1(FILE)
  335. + /* Output to assembler file text saying following lines
  336. +    may contain character constants, extra white space, comments, etc.  */
  337. + #define ASM_APP_ON "/APP\n"
  338. + /* Output to assembler file text saying following lines
  339. +    no longer contain unusual constructs.  */
  340. + #define ASM_APP_OFF "/NO_APP\n"
  341. + /* This is how to output an assembler line
  342. +    that says to advance the location counter by SIZE bytes.  */
  343. + #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
  344. +   fprintf ((FILE), "\t.set .,.+%d\n", (SIZE))
  345. + /* Output before read-only data.  */
  346. + #define TEXT_SECTION_ASM_OP ".text"
  347. + /* Output before writable data.  */
  348. + #define DATA_SECTION_ASM_OP ".data"
  349. + /* Define the syntax of labels and symbol definitions/declarations.  */
  350. + /* This says how to output an assembler line
  351. +    to define a global common symbol.  */
  352. + /* We don't use ROUNDED because the standard compiler doesn't,
  353. +    and the linker gives error messages if a common symbol
  354. +    has more than one length value.  */
  355. + #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
  356. + ( fputs (".comm ", (FILE)),            \
  357. +   assemble_name ((FILE), (NAME)),        \
  358. +   fprintf ((FILE), ",%d\n", (SIZE)))
  359. + /* This says how to output an assembler line
  360. +    to define a local common symbol.  */
  361. + /* Try lcomm to generate local bss 
  362. +  *
  363. +  * #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
  364. +  *   (data_section (),                \
  365. +  *    ASM_OUTPUT_LABEL ((FILE), (NAME)),        \
  366. +  *    fprintf ((FILE), "\t.set .,.+%d\n", (ROUNDED)))
  367. +  */
  368. + #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
  369. + ( fputs (".lcomm ", (FILE)),            \
  370. +   assemble_name ((FILE), (NAME)),        \
  371. +   fprintf ((FILE), ",%d\n", (SIZE)))
  372. + /* This is how to output an assembler line
  373. +    that says to advance the location counter
  374. +    by a multiple of 2**LOG bytes.  */
  375. + #define ASM_OUTPUT_ALIGN(FILE,LOG)    \
  376. +      if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", (LOG))
  377. + /* This is how to store into the string BUF
  378. +    the symbol_ref name of an internal numbered label where
  379. +    PREFIX is the class of label and NUM is the number within the class.
  380. +    This is suitable for output with `assemble_name'.  */
  381. + #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)    \
  382. +   sprintf ((BUF), "*.%s%d", (PREFIX), (NUMBER))
  383. + /* This is how to output an internal numbered label where
  384. +    PREFIX is the class of label and NUM is the number within the class.  */
  385. + #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)    \
  386. +   fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
  387. + /* This is how to output a reference to a user-level label named NAME.  */
  388. + #define ASM_OUTPUT_LABELREF(FILE,NAME)    \
  389. +   fprintf (FILE, "_%s", NAME)
  390. + /* This is how to output a command to make the user-level label named NAME
  391. +    defined for reference from other files.  */
  392. + #define ASM_GLOBALIZE_LABEL(FILE,NAME)    \
  393. +   (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE))
  394. + /* How to output an ASCII string constant.  */
  395. + #define ASM_OUTPUT_ASCII(FILE, p, size) \
  396. + { int i=0;                         \
  397. +   while (i < size)                    \
  398. +     { if (i%10 == 0) { if (i!=0) fprintf (FILE, "\n");    \
  399. +                fprintf (FILE, ASM_BYTE); }    \
  400. +       else fprintf (FILE, ",");                \
  401. +     fprintf (FILE, "0x%x",(p[i++] & 0377)) ;}    \
  402. +       fprintf (FILE, "\n"); }
  403. + #define EXTRA_SECTIONS in_cdata
  404. + /* Define the additional functions to select our additional sections.  */
  405. + #define CDATA_SECTION_ASM_OP ".data 1"
  406. + #define EXTRA_SECTION_FUNCTIONS                        \
  407. + void                                    \
  408. + cdata_section ()                            \
  409. + {                                    \
  410. +   if (in_section != in_cdata)                        \
  411. +     {                                    \
  412. +       fprintf (asm_out_file, "%s\n", CDATA_SECTION_ASM_OP);        \
  413. +       in_section = in_cdata;                        \
  414. +     }                                \
  415. + }
  416. + /* Given a decl node or constant node, choose the section to output it in
  417. +    and select that section.  */
  418. +        /* following takes  care of constants  emitted from
  419. +       the hash table entries (see above comment)
  420. +        */
  421. + #define SELECT_SECTION_MODE(MODE,RTX) cdata_section();
  422. + #define SELECT_RTX_SECTION(MODE, RTX) cdata_section();
  423. + #define SELECT_SECTION(DECL)                        \
  424. +   { if (TREE_CODE (DECL) == STRING_CST) {                \
  425. +        if (flag_writable_strings)                    \
  426. +           data_section ();                        \
  427. +        else                                \
  428. +         cdata_section ();                        \
  429. +     }                                    \
  430. +     else if (TREE_READONLY (DECL) && ! TREE_VOLATILE (DECL))        \
  431. +       cdata_section ();                            \
  432. +     else                                \
  433. +       data_section (); }
  434. *** gcc-1.40/config/xm-xenix386.h
  435. --- config/xm-xenix386.h    Fri Jul 12 07:43:58 1991
  436. ***************
  437. *** 0 ****
  438. --- 1,55 ----
  439. + /* Configuration for GNU C-compiler for Intel 80386 running SCO Xenix 386
  440. +    Copyright (C) 1988 Free Software Foundation, Inc.
  441. + This file is part of GNU CC.
  442. + GNU CC is free software; you can redistribute it and/or modify
  443. + it under the terms of the GNU General Public License as published by
  444. + the Free Software Foundation; either version 1, or (at your option)
  445. + any later version.
  446. + GNU CC is distributed in the hope that it will be useful,
  447. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  448. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  449. + GNU General Public License for more details.
  450. + You should have received a copy of the GNU General Public License
  451. + along with GNU CC; see the file COPYING.  If not, write to
  452. + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  453. + /* #defines that need visibility everywhere.  */
  454. + #define FALSE 0
  455. + #define TRUE 1
  456. + /* This describes the machine the compiler is hosted on.  */
  457. + #define HOST_BITS_PER_CHAR 8
  458. + #define HOST_BITS_PER_SHORT 16
  459. + #define HOST_BITS_PER_INT 32
  460. + #define HOST_BITS_PER_LONG 32
  461. + /* Arguments to use with `exit'.  */
  462. + #define SUCCESS_EXIT_CODE 0
  463. + #define FATAL_EXIT_CODE 33
  464. + #define USG
  465. + #ifndef __GNUC__
  466. + #define register auto /* Register variables are broken */
  467. + #endif
  468. + /* target machine dependencies.
  469. +    tm.h is a symbolic link to the actual target specific file.   */
  470. + #include "tm.h"
  471. + #define bcopy(a,b,c) memcpy (b,a,c)
  472. + #define bzero(a,b) memset (a,0,b)
  473. + #define bcmp(a,b,c) memcmp (a,b,c)
  474. + #ifdef __GNUC__
  475. + #define alloca(n) __builtin_alloca(n)
  476. + #endif
  477. + /* Implement Microsoft C compatible #pragma pack() */
  478. + #define PRAGMA_PACK
  479. *** gcc-1.40/config.gcc    Mon Jul 29 13:16:42 1991
  480. --- config.gcc    Wed Jul 10 15:56:16 1991
  481. ***************
  482. *** 331,336 ****
  483. --- 331,340 ----
  484.   #    370)
  485.   #        machine=370
  486.   #        ;;
  487. +     xenix386)        # for SCO Xenix/386
  488. +         cpu_type=i386
  489. +         configuration_file=xm-${machine}.h
  490. +         ;;
  491.       esac
  492.   
  493.           # if cpu_type is not set, define cpu_type to machine.
  494. *** gcc-1.40/gcc.c    Mon Jul 29 13:16:57 1991
  495. --- gcc.c    Fri Jul 12 08:15:31 1991
  496. ***************
  497. *** 303,312 ****
  498. --- 303,316 ----
  499.   };
  500.   
  501.   /* Here is the spec for running the linker, after compiling all files.  */
  502. + #ifdef FULL_LINK_SPEC
  503. + char *link_spec = FULL_LINK_SPEC
  504. + #else
  505.   char *link_spec = "%{!c:%{!M*:%{!E:%{!S:ld %{o*} %l\
  506.    %{A} %{d} %{e*} %{N} %{n} %{r} %{s} %{S} %{T*} %{t} %{u*} %{X} %{x} %{z}\
  507.    %{y*} %{!A:%{!nostdlib:%S}} \
  508.    %{L*} %o %{!nostdlib:%G gnulib%s %L gnulib%s %{!A:%E}}\n }}}}";
  509. + #endif
  510.   
  511.   /* Accumulate a command (program name and args), and run it.  */
  512.   
  513. ***************
  514. *** 361,368 ****
  515.   #define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
  516.   #endif /* !defined STANDARD_STARTFILE_PREFIX */
  517.   
  518.   char *standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
  519. ! char *standard_startfile_prefix_1 = "/lib/";
  520.   char *standard_startfile_prefix_2 = "/usr/lib/";
  521.   
  522.   /* Clear out the vector of arguments (after a command is executed).  */
  523. --- 365,376 ----
  524.   #define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
  525.   #endif /* !defined STANDARD_STARTFILE_PREFIX */
  526.   
  527. + #ifndef STANDARD_STARTFILE_PREFIX_1
  528. + #define STANDARD_STARTFILE_PREFIX_1 "/lib/"
  529. + #endif /* !defined STANDARD_STARTFILE_PREFIX_1 */
  530.   char *standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
  531. ! char *standard_startfile_prefix_1 = STANDARD_STARTFILE_PREFIX_1;
  532.   char *standard_startfile_prefix_2 = "/usr/lib/";
  533.   
  534.   /* Clear out the vector of arguments (after a command is executed).  */
  535. ***************
  536. *** 1383,1389 ****
  537.   
  538.   char *
  539.   handle_braces (p)
  540. !      register char *p;
  541.   {
  542.     register char *q;
  543.     char *filter;
  544. --- 1391,1397 ----
  545.   
  546.   char *
  547.   handle_braces (p)
  548. !      char *p;
  549.   {
  550.     register char *q;
  551.     char *filter;
  552. *** gcc-1.40/pragmapack.c
  553. --- pragmapack.c    Wed Jul 10 16:57:32 1991
  554. ***************
  555. *** 0 ****
  556. --- 1,26 ----
  557. + #define DEFAULT_ALIGN    32
  558. + static int pack_align = DEFAULT_ALIGN;
  559. + static int was_pragma = 0;
  560. + pragma_pack(val)
  561. + int val;
  562. + {
  563. +     pack_align = 8 * val;
  564. +     was_pragma = 1;
  565. + }
  566. + pragma_align_val()
  567. + {
  568. +     return pack_align;
  569. + }
  570. + pragma_pack_default()
  571. + {
  572. +     pack_align = DEFAULT_ALIGN;
  573. + }
  574. + int pragma_pack_seen()
  575. + {
  576. +     return was_pragma;
  577. + }
  578. *** gcc-1.40/stor-layout.c    Mon Jul 29 13:17:35 1991
  579. --- stor-layout.c    Wed Jul 10 15:56:23 1991
  580. ***************
  581. *** 514,519 ****
  582. --- 514,523 ----
  583.        or some divisor of it.  */
  584.   
  585.         layout_decl (field, var_size ? size_unit : const_size);
  586. + #ifdef PRAGMA_PACK
  587. +       if (pragma_pack_seen())
  588. +         DECL_ALIGN(field) = MIN(pragma_align_val(), DECL_ALIGN(field));
  589. + #endif
  590.         desired_align = DECL_ALIGN (field);
  591.   
  592.         /* Record must have at least as much alignment as any field.
  593. *** gcc-1.40/c-parse.tab.c    Mon Jul 29 13:21:25 1991
  594. --- c-parse.tab.c    Mon Jul 29 13:53:35 1991
  595. ***************
  596. *** 3201,3206 ****
  597. --- 3205,3251 ----
  598.             && getc (finput) == 'm'
  599.             && getc (finput) == 'a'
  600.             && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
  601. + #ifdef PRAGMA_PACK
  602. +       {
  603. +         token = yylex();
  604. +             if (token != IDENTIFIER) 
  605. +             goto skipline;
  606. +             if (strcmp(token_buffer, "pack") != 0)
  607. +                 goto skipline;
  608. +         
  609. +         token = yylex();
  610. +           if (token != '(') {
  611. +             error ("invalid #pragma pack expecting '('");
  612. +             goto skipline;
  613. +         }
  614. +         /* setup default alignment first */
  615. +         pragma_pack_default();
  616. +         token = yylex();
  617. +         if (token != ')')
  618. +         {
  619. +             if (token == CONSTANT
  620. +                 && TREE_CODE (yylval.ttype) == INTEGER_CST) {
  621. +                 int l = TREE_INT_CST_LOW (yylval.ttype);
  622. +                 pragma_pack(l);
  623. +             }
  624. +             else {
  625. +                 error ("invalid #pragma pack expecting 1, 2 or 4");
  626. +                 goto skipline;
  627. +             }
  628. +             token = yylex();
  629. +         }
  630. +           if (token != ')') {
  631. +             error ("invalid #pragma pack expecting ')'");
  632. +             goto skipline;
  633. +         }
  634. +         }
  635. + #endif
  636.           goto skipline;
  637.       }
  638.   
  639. *** fix.h.xenix
  640. --- fix.h.xenix    Thu Aug 22 21:18:21 1991
  641. ***************
  642. *** 0 ****
  643. --- 1,198 ----
  644. + # @(#) $Id: fix.h.xenix,v 1.3 1991/08/22 05:39:05 ronald Exp $
  645. + #
  646. + # (C) Copyright 1990, 1991 Ronald Khoo <ronald@ibmpcug.co.uk>
  647. + # Permission granted to use or abuse this program for any purpose,
  648. + # provided that all modified copies are clearly marked as such.
  649. + # No warranty is given for the fitness of this program for any purpose.
  650. + #
  651. + # Please treat this file as a document saying what I did and not really
  652. + # a program.  i.e.  Please read it through before considering running it.
  653. + #
  654. + # This is a quick hack to fix the SCO Xenix 386 include files so that
  655. + # they work with gcc at all.  No attempt has been made to do this
  656. + # in a general way whatsoever, and this script was not made with any
  657. + # reference to the GCC fixincludes script:  I still have no idea what
  658. + # that does.  This works (ish) for me.  Your mileage may vary.
  659. + # My include files were from the 2.3.4 operating system and the 2.3.1b
  660. + # development system.
  661. + #
  662. + # What the script does do:
  663. + #
  664. + # * stream edit files from /usr/include and /usr/include/sys
  665. + #   into /usr/local/lib/gcc-include, skipping those which are
  666. + #   provided by GCC.
  667. + # * make all references to M_I386 refer to __M_I386__ instead.
  668. + #   This enables programs compiled with gcc -ansi not to coredump.
  669. + #   This only works with gcc so don't give these hacked .h files to cc !!
  670. + # * put protection #ifdef tests to all files to allow them to be safely
  671. + #   multiply included.
  672. + # * time_t and size_t seem to be typedefed all over the place.  Protect them.
  673. + # * remove definition and use of va_list in stdio.h -- that's bogus.
  674. + #   (SCO has already fixed this one in 2.3.1)
  675. + # * make types of SIG_IGN, etc consistently void * in sys/signal.h
  676. + #   (to be consistent with <signal.h>)
  677. + # * various other individual hacks I've come across.  Note that these
  678. + #   are entirely ad-hoc.  You can find them in the lines starting with
  679. + #   sed_<name>="
  680. + #
  681. + # In particular, the ad-hocery was intended to make rcs 5.5 compile without
  682. + # hacking, even with all the recommended warning options set.
  683. + # It doesn't quite work -- rcs 5.5's configuration script is slightly broken.
  684. + # I hate gratuitous declarations.
  685. + #
  686. + # Note that this is only a beginning.  I keep finding annoyances which
  687. + # have to be fixed by hand.  Many prototypes are wrong in places like
  688. + # <stdio.h>, <stdlib.h> etc.  An afternoon spent with an editor in one
  689. + # hand and the ANSI standard in the other would probably not go amiss.
  690. + #
  691. + # This script will probably fall flat on its face if you've already
  692. + # modified the system include files to do what it wants to do.
  693. + # Starting from a fresh set may be a reasonable approach.
  694. + #
  695. + # $Log: fix.h.xenix,v $
  696. + # Revision 1.3  1991/08/22  05:39:05  ronald
  697. + # pre-release version for gfm@mencon.oz to try out.
  698. + #
  699. + # Revision 1.2  1991/08/19  10:55:30  ronald
  700. + # Interim release for gcc 1.40, beta testers.
  701. + #
  702. + # Revision 1.1  90/04/25  18:51:21  ronald
  703. + # Initial revision
  704. + # 
  705. + PATH=/etc:/bin:/usr/bin export PATH
  706. + # usage: /usr/local/lib/fix.h.xenix
  707. + lib=${lib-/usr/local/lib}
  708. + include=$lib/gcc-include
  709. + stdinc=${stdinc-/usr/include}
  710. + sed_mi386=" -e '/\\([^_]\\)M_I386/s//\\1__M_I386__/g'"
  711. + sed_timet=" -e '/typedef.*[     ]time_t/ {
  712. + i\\
  713. + #ifndef _TIME_T
  714. + i\\
  715. + #define _TIME_T
  716. + a\\
  717. + #endif /* _TIME_T */
  718. + }'"
  719. + sed_sizet=" -e '/typedef.*[     ]size_t/ {
  720. + i\\
  721. + #ifndef _SIZE_T
  722. + i\\
  723. + #define _SIZE_T
  724. + a\\
  725. + #endif /* _SIZE_T */
  726. + }'"
  727. + # No prizes for guessing what this macro is used for.
  728. + # Also, no prizes for guessing which editor I use.
  729. + # :s/^[     ]*\([^( ]*\)[     ]*\((.*\);[     ]*$/    \/\\\\(\1[     ]*\\\\)([^)][^)]*)\/s\/\/\\\\1 \2\//
  730. + #
  731. + sed_param=" -e '
  732. +     /\(\/\*[^/]*\)\/\*/s//\1 *\/ \/*/
  733. +     /^\/\*.*\/\*.*pdp11[     ]*\$/s/\$/*\//
  734. + '"
  735. + sed_errno=" -e '
  736. +     /\\(perror[     ]*\\)([^)][^)]*)/s//\\1 ( const char * )/
  737. + '"
  738. + sed_stdlib=" -e '
  739. +     /\\(getenv[     ]*\\)([^)][^)]*)/s//\\1 (const char *)/
  740. +     /\\(atoi[     ]*\\)([^)][^)]*)/s//\\1 (const char *)/
  741. +     /.*\\(free[     ]*\\)([^)][^)]*)/s//extern void \\1 ( void * )/
  742. +     /.*\\(malloc[     ]*\\)([^)][^)]*)/s//extern void *\\1 (unsigned)/
  743. +     /.*\\(realloc[     ]*\\)([^)][^)]*)/s//extern void *\\1 (void *, unsigned)/
  744. +     /.*\\(calloc[     ]*\\)([^)][^)]*)/s//extern void *\\1 (unsigned, unsigned)/
  745. + '"
  746. + sed_stdio=" -e '
  747. +     /\\(printf[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, ...)/
  748. +     /\\(fprintf[     ]*\\)([^)][^)]*)/s//\\1 ( FILE *, const char *, ... )/
  749. +     /\\(vfprintf[     ]*\\)([^)][^)]*)/s//\\1 ( FILE *, const char *, char * )/
  750. +     /\\(vprintf[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, char * )/
  751. +     /\\(sprintf[     ]*\\)([^)][^)]*)/s//\\1 ( char *, const char *, ... )/
  752. +     /\\(vsprintf[     ]*\\)([^)][^)]*)/s//\\1 ( char *, const char *, char * )/
  753. +     /\\(fopen[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, const char * )/
  754. +     /\\(fdopen[     ]*\\)([^)][^)]*)/s//\\1 ( int, const char * )/
  755. +     /\\(fputs[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, FILE * )/
  756. +     /\\(fread[     ]*\\)([^)][^)]*)/s//\\1 ( void *, size_t, size_t, FILE * )/
  757. +     /\\(fwrite[     ]*\\)([^)][^)]*)/s//\\1 ( const void *, size_t, size_t, FILE * )/
  758. +     /typedef.*va_list/d
  759. +     /va_list/s//char */
  760. + '"
  761. + sed_string=" -e '
  762. +      /\\(strlen[     ]*\\)([^)][^)]*)/s//\\1 ( const char * )/
  763. +      /\\(strcat[     ]*\\)([^)][^)]*)/s//\\1 ( char *, const char * )/
  764. +      /\\(strncat[     ]*\\)([^)][^)]*)/s//\\1 ( char *, const char *, int )/
  765. +      /\\(strcpy[     ]*\\)([^)][^)]*)/s//\\1 ( char *, const char * )/
  766. +      /\\(strncpy[     ]*\\)([^)][^)]*)/s//\\1 ( char *, const char *, int )/
  767. +      /\\(strchr[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, int )/
  768. +      /\\(strrchr[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, int )/
  769. +      /\\(strcmp[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, const char * )/
  770. +      /\\(strncmp[     ]*\\)([^)][^)]*)/s//\\1 ( const char *, const char *, int )/
  771. +     /define.*strerror.*;[     ]*\$/s/;[     ]*\$//
  772. + '"
  773. + sed_signal=" -e '/int.*(\\*)/s/int/void/g'"
  774. + sed_error=" -e '/^[     ]*ERROR[     ]\\(.*\\)\$/ {
  775. + s//\\1/
  776. + s/\"//g
  777. + s/[     ][     ]*/ /g
  778. + s/.*/    #error \"&\"/
  779. + }'"
  780. + hackit()
  781. + {
  782. +     echo "\r                         \rHacking $1\c"  >&2 
  783. +     idemp=
  784. +     expr "`sed 1q $1`" : '.*ifn.*_H.*' > /dev/null && idemp=yes
  785. +     test "$idemp" || {
  786. +         name=_INCLUDED_`echo $1 | tr './[a-z]' '__[A-Z]'`_AUTOFIX
  787. +         echo "#ifndef $name" > $include/$1
  788. +         echo "#define $name" >> $include/$1
  789. +     }
  790. +     script="$sed_mi386"
  791. +     grep -s size_t $1 > /dev/null &&
  792. +         grep -s _SIZE_T $1 > /dev/null || script="$script $sed_sizet"
  793. +     grep -s time_t $1 > /dev/null &&
  794. +         grep -s _TIME_T $1 > /dev/null || script="$script $sed_timet"
  795. +     case $1 in
  796. +         errno.h)    script="$script $sed_errno"    ;;
  797. +         stdlib.h)    script="$script $sed_stdlib"    ;;
  798. +         string.h)    script="$script $sed_string"    ;;
  799. +         stdio.h)    script="$script $sed_errno $sed_stdio"    ;;
  800. +         sys/param.h)    script="$script $sed_param"    ;;
  801. +         sys/signal.h)    script="$script $sed_signal"    ;;
  802. +         curses.h|sys/emap.h|sys/param.h|sys/sxt.h)
  803. +                 script="$script $sed_error"    ;;
  804. +     esac
  805. +     eval sed "$script" $1 >> $include/$1
  806. +     test "$idemp" || echo "#endif /* $name */" >> $include/$1
  807. + }
  808. + [ -d $include ] || mkdir $include
  809. + [ -d $include/sys ] || mkdir $include/sys
  810. + cd $stdinc || exit 1
  811. + echo "\rHacking files from $stdinc into $include" >&2
  812. + # This bit is useful for hacking the sed scripts above.
  813. + # for i in sys/param.h # stdio.h stdlib.h errno.h curses.h string.h 
  814. + # do hackit $i ; done
  815. + # exit 1
  816. + for i in *.h 
  817. + do
  818. +     case $i in
  819. +         # Use the GCC supplied versions of these files:
  820. +         assert.h|float.h|limits.h|stdarg.h|stddef.h|varargs.h)    ;;
  821. +         *) hackit $i ;;
  822. +     esac
  823. + done
  824. + echo "\rHacking files from $stdinc/sys into $include/sys" >&2
  825. + for i in sys/*.h ; do hackit $i ; done
  826. + cd $include
  827. + cd sys ; chgrp bin . *.h ; chmod 664 *.h ; chmod 775 . ; chown bin . *.h
  828. + cd .. ; chgrp bin . *.h ; chmod 664 *.h ; chmod 775 . ; chown bin . *.h
  829. + echo '\r..... done.  Have a nice day.  --Ronald' >&2
  830. *** fixmin.xenix
  831. --- fixmin.xenix    Thu Aug 22 21:09:28 1991
  832. ***************
  833. *** 0 ****
  834. --- 1,76 ----
  835. + # $Id: fixmin.xenix,v 1.1 1991/08/22 20:06:32 ronald Exp $
  836. + # Change Log is at the end of the file.
  837. + #
  838. + # This is the bare minimum of header fixing that I could get away with
  839. + # in order to compile GCC.  This applies to Xenix 2.3.3 with 2.3.1
  840. + # Development System.  You're on your own with other versions.
  841. + # These changes should only be in effect while building gcc.
  842. + # You should undo them, and replace the fixes with something better
  843. + # in /usr/local/lib/gcc-include once you've installed gcc.
  844. + # usage: fixmin.xenix [ undo ]
  845. + # If the "undo" parameter is specified, reverses the actions of a
  846. + # previous run of fixmin.
  847. + cd /usr/include
  848. + if test "$1" = undo ; then
  849. +     for i in *.bfm ; do
  850. +         j=`basename $i .bfm`
  851. +         mv $i $j
  852. +         echo restored $j >&2
  853. +     done
  854. +     cd sys
  855. +     for i in *.bfm ; do
  856. +         j=`basename $i .bfm`
  857. +         mv $i $j
  858. +         echo restored sys/$j >&2
  859. +     done
  860. +     exit 0
  861. + fi
  862. + for i in stdio.h time.h string.h sys/types.h ; do
  863. +     if egrep '(_SIZE_T|_TIME_T)' $i  > /dev/null || test -r $i.bfm; then
  864. +         : do nothing, already there
  865. +     else
  866. +         echo fixing $i
  867. +         sed '/typedef.*[     ]size_t/ {
  868. + i\
  869. + #ifndef _SIZE_T
  870. + i\
  871. + #define _SIZE_T
  872. + a\
  873. + #endif
  874. + }
  875. + /typedef.*[     ]time_t/ {
  876. + i\
  877. + #ifndef _TIME_T
  878. + i\
  879. + #define _TIME_T
  880. + a\
  881. + #endif
  882. + }'        $i > $i.new
  883. +         mv $i $i.bfm
  884. +         mv $i.new $i
  885. +     fi
  886. + done
  887. + if sed 1q stdio.h | grep -s 'ifndef[     ][     ]*FILE' > /dev/null ; then
  888. +     : do nothing -- already there.
  889. + else
  890. +     echo stdio.h once more ...
  891. +     ed stdio.h <<-\EOF
  892. +         0a
  893. +         #ifndef FILE
  894. +         .
  895. +         $a
  896. +         #endif
  897. +         .
  898. +         w
  899. + EOF
  900. + fi
  901. + #
  902. + # $Log: fixmin.xenix,v $
  903. + # Revision 1.1  1991/08/22  20:06:32  ronald
  904. + # Initial revision
  905. + #
  906. *** xenixld.c
  907. --- xenixld.c    Thu Aug 22 21:17:40 1991
  908. ***************
  909. *** 0 ****
  910. --- 1,264 ----
  911. + static char rcsid[] = "@(#) $Id: xenixld.c,v 1.2 1991/08/22 20:17:03 ronald Exp $\n";
  912. + /*
  913. +  * This is the version distributed by RoboBar limited, currently maintained
  914. +  * by Ronald Khoo <ronald@ibmpcug.co.uk>
  915. +  *
  916. +  * $Log: xenixld.c,v $
  917. +  * Revision 1.2  1991/08/22  20:17:03  ronald
  918. +  * Baseline for release with GCC 1.40
  919. +  * Various mods by Steve, and a hack to prevent loading of COFF files.
  920. +  *
  921. +  */
  922. + /* Linker driver program for Xenix that can handle gcc command lines
  923. +    Copyright (C) 1990 Christoph Badura
  924. +    Comments and buggestions are welcome. Write to bad@flatlin.sub.org.
  925. + This file is not part of GNU CC.
  926. + This program is free software; you can redistribute it and/or modify
  927. + it under the terms of the GNU General Public License as published by
  928. + the Free Software Foundation; either version 1, or (at your option)
  929. + any later version.
  930. + This program is distributed in the hope that it will be useful,
  931. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  932. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  933. + GNU General Public License for more details.
  934. + You should have received a copy of the GNU General Public License
  935. + along with GNU CC; see the file COPYING.  If not, write to
  936. + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  937. + */
  938. + #include <stdio.h>
  939. + #include "config.h"
  940. + #ifdef USG
  941. + #define R_OK 4
  942. + #define W_OK 2
  943. + #define X_OK 1
  944. + #define vfork fork
  945. + #endif /* USG */
  946. + extern void free ();
  947. + /* Default prefixes to attach to command names.  */
  948. + #ifndef STANDARD_STARTFILE_PREFIX
  949. + #define STANDARD_STARTFILE_PREFIX "/usr/local/lib/"
  950. + #endif /* !defined STANDARD_STARTFILE_PREFIX */
  951. + char *standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
  952. + char *standard_startfile_prefix_1 = "/lib/386/";
  953. + char *standard_startfile_prefix_2 = "/usr/lib/";
  954. + char * progname;        /* who am i */
  955. + fatal (char *msg)
  956. + {
  957. +     fprintf (stderr, "%s:%s\n", progname, msg);
  958. +     exit (1);
  959. + }
  960. + xmalloc (size)
  961. +      int size;
  962. + {
  963. +   register int value = malloc (size);
  964. +   if (!value)
  965. +     fatal ("Virtual memory full.");
  966. +   return value;
  967. + }
  968. + xrealloc (void *ptr, int size)
  969. + {
  970. +   register int value = realloc (ptr, size);
  971. +   if (!value)
  972. +     fatal ("Virtual memory full.");
  973. +   return value;
  974. + }
  975. + struct lib_path {
  976. +     struct lib_path *next;
  977. +     int    length;            /* length of following string */
  978. +     char *path;
  979. + };
  980. + struct lib_path *lib_path;    /* the library search path */
  981. + struct lib_path *
  982. + add_path (char *name, struct lib_path *prev)
  983. + {
  984. +     int size;
  985. +     struct lib_path *lp;
  986. + #ifdef DEBUG
  987. +     fprintf (stderr, "%s: adding %s to library path\n", progname, name);
  988. + #endif
  989. +     lp = (struct lib_path *) xmalloc (sizeof (struct lib_path));
  990. +     lp->next = prev;
  991. +     lp->length = strlen (name);
  992. +     lp->path = name;
  993. +     return lp;
  994. + }
  995. + /*
  996. +  * Added by Ronald.Khoo@ibmpcug.co.uk:
  997. +  * SCO systems have two kinds of libraries, OMF and COFF.  XENIX GCC/G++
  998. +  * only works with OMF, this hack prevents the program accidentally finding
  999. +  * COFF libraries earlier in the search path from the corresponding OMF one.
  1000. +  */
  1001. + int
  1002. + islib(char *name)
  1003. + {
  1004. +     int i;
  1005. +     FILE *fp = fopen(name, "r");
  1006. +     if (fp == 0)
  1007. +         return 0;
  1008. +     i = getw(fp);
  1009. +     fclose(fp);
  1010. +     return (i & 0xff) == 0x80 /* OMF */ || (i & 0xffff) == 0xff65 /* ar */;
  1011. + }
  1012. + char *
  1013. + find_library_1 (char *name)
  1014. + {
  1015. +     struct lib_path *lp;
  1016. +     int name_size, size = 0;
  1017. +     char *temp_name = 0;
  1018. +     int win = 0;
  1019. +     name_size = strlen (name) + 1;
  1020. +     for (lp=lib_path; lp && !win; lp=lp->next) {
  1021. +     if ((lp->length + name_size + 1) > size) {
  1022. +         size = lp->length + name_size + 1;
  1023. +         if (temp_name)
  1024. +         free (temp_name);
  1025. +         temp_name = 0;
  1026. +     }
  1027. +     if (!temp_name)
  1028. +         temp_name = (char *)xmalloc (size);
  1029. +     strcpy (temp_name, lp->path);
  1030. +     if (temp_name[lp->length - 1] != '/')
  1031. +         strcat (temp_name, "/");
  1032. +     strcat (temp_name, name);
  1033. +     win = islib(temp_name);
  1034. + #ifdef DEBUG
  1035. +     fprintf (stderr, "%s: searching %s -> %d\n", progname, temp_name, win);
  1036. + #endif
  1037. +     }
  1038. +     if (win)
  1039. +     return temp_name;
  1040. +     else {
  1041. +     free (temp_name);
  1042. +     return name;
  1043. +     }
  1044. + }
  1045. + char *
  1046. + find_library (char *name)
  1047. + {
  1048. +     char *temp_name;
  1049. +     char *lib_name;
  1050. +     temp_name = (char *)xmalloc (strlen (name) + 7); /* 6 chars for "Slib" and ".a" */
  1051. +     strcpy (temp_name, "lib");
  1052. +     strcat (temp_name, name);
  1053. +     strcat (temp_name, ".a");
  1054. +     if ((lib_name = find_library_1 (temp_name)) == temp_name) {
  1055. +     strcpy (temp_name, "Slib"); /* system libraries start with "Slib" */
  1056. +     strcat (temp_name, name);
  1057. +     strcat (temp_name, ".a");
  1058. +     lib_name = find_library_1 (temp_name);
  1059. +     }
  1060. +     free (temp_name);
  1061. + #ifdef DEBUG
  1062. +     fprintf (stderr, "%s: library name is %s\n", progname, lib_name);
  1063. +     fprintf (stderr, "%s: returning %s\n", progname,
  1064. +          (lib_name == temp_name) ? name : lib_name);
  1065. + #endif
  1066. +     return (lib_name == temp_name) ? name : lib_name;
  1067. + }
  1068. + char **argbuf;            /* this holds the argument vector for ld */
  1069. + int argbuf_index, argbuf_length;
  1070. + /* Add one argument to the vector at the end. */
  1071. + void
  1072. + store_arg (char *arg)
  1073. + {
  1074. +   if (argbuf_index + 1 == argbuf_length)
  1075. +     {
  1076. +       argbuf = (char **) xrealloc (argbuf, (argbuf_length*=2)*sizeof (char *));
  1077. +     }
  1078. +   argbuf[argbuf_index++] = arg;
  1079. +   argbuf[argbuf_index] = 0;
  1080. + }
  1081. + /*
  1082. +  * The standard Xenix ld is seriously braindamaged. It does not understand
  1083. +  * -llib options.  So we expand them here and furthermore we process -Lpath
  1084. +  * options as used by the GNU tools.
  1085. +  */
  1086. + int
  1087. + main (int argc, char **argv)
  1088. + {
  1089. +     int size;
  1090. +     char *lib_name;
  1091. + #ifdef DEBUG
  1092. +     char **argp;
  1093. + #endif
  1094. +     progname = *argv;
  1095. +     argbuf_length = 10;
  1096. +     argbuf_index = 0;
  1097. +     argbuf = (char **) xmalloc (argbuf_length * sizeof (char *));
  1098. +     /* push default library search paths on lib_stack */
  1099. +     lib_path = add_path (standard_startfile_prefix_2, (struct lib_path *)0);
  1100. +     lib_path = add_path (standard_startfile_prefix_1, lib_path);
  1101. +     lib_path = add_path (standard_startfile_prefix, lib_path);
  1102. +     /*
  1103. +      * Copy argv to argbuf processing -L switches and
  1104. +      * resolving library names. Preserve the order of the arguments.
  1105. +      */
  1106. +     store_arg ("ld"); /* provide argv[0] for ld */
  1107. +     for (++argv; --argc > 0; ++argv) {
  1108. +     if ((*argv)[0] == '-')
  1109. +         switch ((*argv)[1]) {
  1110. +         case 'L':
  1111. +         lib_path = add_path ((*argv)+2, lib_path);
  1112. +         break;
  1113. +         case 'l':
  1114. +         lib_name = find_library ((*argv)+2);
  1115. + #ifdef DEBUG
  1116. +         fprintf (stderr, "%s: found library %s\n", progname, lib_name);
  1117. + #endif
  1118. +         store_arg (lib_name);
  1119. +         break;
  1120. +         default:
  1121. +         store_arg (*argv);
  1122. +         }
  1123. +     else
  1124. +         /* just an input file */
  1125. +         store_arg (*argv);
  1126. +     }
  1127. + #ifdef DEBUG
  1128. +     fprintf (stderr, "%s: linker call: \"", progname);
  1129. +     for (argp=argbuf; *argp; argp++)
  1130. +     fprintf (stderr, "%s ", *argp);
  1131. +     putc ('\n', stderr);
  1132. + #endif
  1133. +     execv ("/bin/ld", argbuf);
  1134. +     /* maybe ld is not ld */
  1135. +     fprintf (stderr, "%s: unable to run /bin/ld", progname);
  1136. +     exit (1);
  1137. + }
  1138.  
  1139.