home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1970 < prev    next >
Internet Message Format  |  1990-12-28  |  39KB

  1. From: loic@adesign.uucp (Loic Dachary)
  2. Newsgroups: alt.sources
  3. Subject: gas-1.36 patches for COFF generation
  4. Message-ID: <LOIC.90Oct16093019@adesign.uucp>
  5. Date: 16 Oct 90 08:30:19 GMT
  6.  
  7.  
  8.     Hello,
  9.  
  10.    I have posted an article last week on gnu.gcc to announce that patches
  11. to gas-1.36 for COFF object file generation were availables.
  12.    About 30 mails have asked for it since then. Sorry if I'm wrong but I will
  13. consider this enough to post. Is there a precise definition of "popular
  14. demand" somewhere ?-)
  15.  
  16.    The patches will be posted in the alt.sources newsgroup. They are about
  17. 160 K due to diff -c verbosity and are splitted in 5 articles. To apply
  18. them just concat all the articles together and pipe the result to patch. They
  19. will succeed on gas-1.36.
  20.    They have been tested on Unisoft 1.3, SunOs 3.5 & 4.0.3, Esix rev C, 
  21. CTIX 3.2, Ix 2.02 and SCO unix. They have been used to compile the following :
  22. Unisoft V.3.2 kernel with tcp/ip extensions, MIT X11R4 libraries and clients, 
  23. bison-1.11, compress-4.0, cproto, cshar, diff-1.14, dist-18.55, flex-2.3, 
  24. gas-1.36, gcc-1.37.1, gdb-3.6, grep-1.5, kermit, make-3.58, makedep, patch,
  25. printf, tar-1.08, texi2roff, uuencode, uutraf-1.2, bash-1.05.
  26.  
  27.    How to make it work ?
  28.  
  29.    . There is a new file named config.gas. It is a shell script that make the 
  30. appropriate links for a given configuration.
  31.      If you have a 68k or an i386, there is a good chance that nothing else
  32. needs to be done.
  33.      However, if your processor is a sparc, ns32k or vax, you will need to 
  34. patch the machine dependent files. I strongly encourage you to contact me.
  35. By mail or voice. I will offer all the assistance I'm able to provide.
  36.  
  37.    . When the links are set up, edit the file Makefile.new according to you 
  38. system (BSD or USG). Refer to the original Makefile if more flags 
  39. or comments are needed.
  40.  
  41.    . Run make -f Makefile.new gas
  42.  
  43.    . Move gas to /usr/local/lib/gcc-as, i.e. a place where gcc can find it.
  44.  
  45.    If you are curious or plan to do some work on gas, read the file
  46. README.coff.
  47.  
  48.     I hope it will help,
  49.  
  50.                        Loic
  51.  
  52.  
  53. *** /dev/null    Mon Oct 15 09:51:48 1990
  54. --- Makefile.new    Mon Oct 15 19:38:09 1990
  55. ***************
  56. *** 0 ****
  57. --- 1,200 ----
  58. + # Makefile for GAS.
  59. + # Copyright (C) 1989, Free Software Foundation
  60. + # 
  61. + # This file is part of GAS, the GNU Assembler.
  62. + # 
  63. + # GAS is free software; you can redistribute it and/or modify
  64. + # it under the terms of the GNU General Public License as published by
  65. + # the Free Software Foundation; either version 1, or (at your option)
  66. + # any later version.
  67. + # 
  68. + # GAS is distributed in the hope that it will be useful,
  69. + # but WITHOUT ANY WARRANTY; without even the implied warranty of
  70. + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  71. + # GNU General Public License for more details.
  72. + # 
  73. + # You should have received a copy of the GNU General Public License
  74. + # along with GAS; see the file COPYING.  If not, write to
  75. + # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  76. + BINDIR = /usr/local/bin
  77. + BINARY = gas
  78. + #
  79. + # Add these flags to XCFLAGS below for specific use.
  80. + #
  81. + # If you machine does not have vfprintf, but does have _doprnt(),
  82. + # -DNO_VARARGS
  83. + #
  84. + # If the return-type of a signal-hander is void (instead of int),
  85. + # -DSIGTY
  86. + #
  87. + # To include the mc68851 mmu coprocessor instructions in the 68020 assembler,
  88. + # -Dm68851 
  89. + #
  90. + # If you want the 80386 assembler to correctly handle fsub/fsubr and fdiv/fdivr
  91. + # opcodes (unlike most 80386 assemblers)
  92. + # -DNON_BROKEN_WORDS
  93. + #
  94. + XCFLAGS =
  95. + # Your favorite compiler
  96. + CC = gcc
  97. + # Uncomment the following lines if you use USG
  98. + INCLUDE_DIRS = -I.
  99. + COFF_OBJECTS = stack.o
  100. + CPPFLAGS = -DUSG
  101. + CFLAGS = -g $(CPPFLAGS) $(XCFLAGS)
  102. + LDFLAGS = 
  103. + LOADLIBES = -lPW
  104. + # Uncomment the following lines if you use BSD
  105. + #INCLUDE_DIRS = -I.
  106. + #CPPFLAGS = 
  107. + #CFLAGS = -g $(CPPFLAGS) $(XCFLAGS)
  108. + #LDFLAGS = 
  109. + #LOADLIBES =
  110. + CONFIG_FILES = \
  111. +     machine.c machine.h atof.c oformat.c oformat.h opcode.h
  112. + OBJECTS = \
  113. +     as.o xrealloc.o xmalloc.o hash.o hex-value.o \
  114. +     atof-generic.o append.o messages.o expr.o app.o \
  115. +     frags.o input-file.o input-scrub.o output-file.o \
  116. +     subsegs.o symbols.o version.o flonum-const.o flonum-copy.o \
  117. +     flonum-mult.o strstr.o bignum-copy.o obstack.o write.o read.o \
  118. +     oformat.o machine.o atof.o $(COFF_OBJECTS)
  119. + SOURCES = $(OBJECTS:.o=.c)
  120. + all : $(BINARY)
  121. + install : all
  122. +     cp $(BINARY) $(BINDIR)
  123. + clean : 
  124. +     rm -f $(OBJECTS)
  125. + clobber : clean
  126. +     rm -f $(BINARY) $(CONFIG_FILES) dependencies TAGS m68k.h
  127. + $(BINARY) : $(OBJECTS)
  128. +     $(CC) -o $(BINARY) $(LDFLAGS) $(OBJECTS) $(LOADLIBES)
  129. + TAGS : $(SOURCES)
  130. +     etags $(SOURCES) *.h
  131. + CXREF : $(SOURCES)
  132. +     cxref -c $(INCLUDE_DIRS) $(SOURCES)
  133. + atof.o: \
  134. +     flonum.h \
  135. +     bignum.h
  136. + oformat.o: \
  137. +     as.h \
  138. +     md.h \
  139. +     aout.h \
  140. +     a.out.h \
  141. +     struc-symbol.h \
  142. +     write.h \
  143. +     append.h
  144. + read.o: \
  145. +     oformat.h \
  146. +     a.out.h \
  147. +     as.h \
  148. +     read.h \
  149. +     md.h \
  150. +     hash.h \
  151. +     obstack.h \
  152. +     frags.h \
  153. +     flonum.h \
  154. +     bignum.h \
  155. +     struc-symbol.h \
  156. +     expr.h \
  157. +     symbols.h \
  158. +     sparc.h
  159. + write.o: \
  160. +     oformat.h \
  161. +     a.out.h \
  162. +     as.h \
  163. +     md.h \
  164. +     subsegs.h \
  165. +     obstack.h \
  166. +     struc-symbol.h \
  167. +     write.h \
  168. +     symbols.h \
  169. +     append.h \
  170. +     sparc.h
  171. + obstack.o: \
  172. +     obstack.h
  173. + bignum-copy.o: \
  174. +     bignum.h
  175. + flonum-mult.o: \
  176. +     flonum.h \
  177. +     bignum.h
  178. + flonum-copy.o: \
  179. +     flonum.h \
  180. +     bignum.h
  181. + flonum-const.o: \
  182. +     flonum.h \
  183. +     bignum.h
  184. + symbols.o: \
  185. +     oformat.h \
  186. +     a.out.h \
  187. +     as.h \
  188. +     hash.h \
  189. +     obstack.h \
  190. +     struc-symbol.h \
  191. +     symbols.h \
  192. +     frags.h
  193. + subsegs.o: \
  194. +     oformat.h \
  195. +     a.out.h \
  196. +     as.h \
  197. +     subsegs.h \
  198. +     obstack.h \
  199. +     frags.h \
  200. +     struc-symbol.h \
  201. +     write.h
  202. + input-scrub.o: \
  203. +     as.h \
  204. +     read.h \
  205. +     input-file.h
  206. + input-file.o: \
  207. +     input-file.h
  208. + frags.o: \
  209. +     oformat.h \
  210. +     a.out.h \
  211. +     as.h \
  212. +     subsegs.h \
  213. +     obstack.h \
  214. +     frags.h \
  215. +     struc-symbol.h
  216. + expr.o: \
  217. +     oformat.h \
  218. +     a.out.h \
  219. +     as.h \
  220. +     flonum.h \
  221. +     bignum.h \
  222. +     read.h \
  223. +     struc-symbol.h \
  224. +     expr.h \
  225. +     obstack.h \
  226. +     symbols.h
  227. + messages.o: \
  228. +     as.h
  229. + atof-generic.o: \
  230. +     flonum.h \
  231. +     bignum.h
  232. + hash.o: \
  233. +     hash.h
  234. + as.o: \
  235. +     oformat.h \
  236. +     a.out.h \
  237. +     as.h \
  238. +     struc-symbol.h \
  239. +     write.h
  240. *** /dev/null    Mon Oct 15 09:51:48 1990
  241. --- aout.h    Mon Oct 15 10:22:20 1990
  242. ***************
  243. *** 0 ****
  244. --- 1,160 ----
  245. + #ifndef AOUT_H
  246. + #define AOUT_H
  247. + #include "a.out.h"
  248. + /* Tag to validate a.out object file format processing */
  249. + #define aout
  250. + /* RELOCATION INFORMATION */
  251. + #define relocation_type struct relocation_info    /* Relocation table entry */
  252. + #define RELSZ sizeof(relocation_type)        /* For coff compatibility */
  253. +  
  254. + /* SYMBOL TABLE */
  255. + /* Symbol table entry data type */
  256. + #define symbol_type struct nlist    /* Symbol table entry */
  257. + /* If compiler generate leading underscores, remove them. */
  258. + #ifndef STRIP_UNDERSCORE
  259. + #define STRIP_UNDERSCORE 0
  260. + #endif /* STRIP_UNDERSCORE */
  261. + /* Symbol table macros and constants */
  262. + /*
  263. +  *  Macros to extract information from a symbol table entry.
  264. +  *  This syntaxic indirection allows independence regarding a.out or coff.
  265. +  *  The argument (s) of all these macros is a pointer to a symbol table entry.
  266. +  */
  267. + /* Predicates */
  268. + /* True if in text segment */
  269. + #define S_IS_TEXT(s)        (((s)->sy_type & N_TYPE) == N_TEXT)
  270. + /* True if in data segment */
  271. + #define S_IS_DATA(s)        (((s)->sy_type & N_TYPE) == N_DATA)
  272. + /* True if in bss segment */
  273. + #define S_IS_BSS(s)        (((s)->sy_type & N_TYPE) == N_BSS)
  274. + /* True if in abs segment */
  275. + #define S_IS_ABS(s)        (((s)->sy_type & N_TYPE) == N_ABS)
  276. + /* True if the symbol is external */
  277. + #define S_IS_EXTERNAL(s)    ((s)->sy_type & N_EXT)
  278. + /* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
  279. + #define S_IS_DEFINED(s)        (((s)->sy_type & N_TYPE) != N_UNDF)
  280. + /* True if a debug special symbol entry */
  281. + #define S_IS_DEBUG(s)        ((s)->sy_type & N_STAB)
  282. + /* True if a symbol is local symbol name */
  283. + /* A symbol name whose name begin with ^A is a gas internal pseudo symbol
  284. +    nameless symbols come from .stab directives. */
  285. + #define S_IS_LOCAL(s)        (S_GET_NAME(s) && \
  286. +                  !S_IS_DEBUG(s) && \
  287. +                  (S_GET_NAME(s)[0] == '\001' || \
  288. +                   (S_GET_NAME(s)[0] == 'L' && !flagseen['L'])))
  289. + /* True if a symbol is not defined in this file */
  290. + #define S_IS_EXTERN(s)        ((s)->sy_type & N_EXT)
  291. + /* True if the symbol has been generated because of a .stabd directive */
  292. + #define S_IS_STABD(s)        ((s)->sy_name == (char *)0)
  293. + /* Accessors */
  294. + /* The value of the symbol */
  295. + #define S_GET_VALUE(s)        ((s)->sy_value)
  296. + /* The name of the symbol */
  297. + #define S_GET_NAME(s)        ((s)->sy_name)
  298. + /* The pointer to the string table */
  299. + #define S_GET_OFFSET(s)        ((s)->sy_strx)
  300. + /* The numeric value of the segment */
  301. + #define S_GET_SEGMENT(s)    ((s)->sy_type & N_TYPE)
  302. + /* The n_other expression value */
  303. + #define S_GET_OTHER(s)        ((s)->sy_other)
  304. + /* The n_desc expression value */
  305. + #define S_GET_DESC(s)        ((s)->sy_desc)
  306. + /* Modifiers */
  307. + /* Set the value of the symbol */
  308. + #define S_SET_VALUE(s,v)    ((s)->sy_value = (v))
  309. + /* Assume that a symbol cannot be simultaneously in more than on segment */
  310. + /* Set the segment to text */
  311. + #define S_SET_TEXT(s)        ((s)->sy_type &= ~N_TYPE,(s)->sy_type|=N_TEXT)
  312. + /* Set the segment to data */
  313. + #define S_SET_DATA(s)        ((s)->sy_type &= ~N_TYPE,(s)->sy_type|=N_DATA)
  314. + /* Set the segment to bss */
  315. + #define S_SET_BSS(s)        ((s)->sy_type &= ~N_TYPE,(s)->sy_type|=N_BSS)
  316. + /* Set the segment to abs */
  317. + #define S_SET_ABS(s)        ((s)->sy_type &= ~N_TYPE,(s)->sy_type|=N_ABS)
  318. + /* The symbol is external */
  319. + #define S_SET_EXTERNAL(s)    ((s)->sy_type |= N_EXT)
  320. + /* The symbol is not external */
  321. + #define S_CLEAR_EXTERNAL(s)    ((s)->sy_type &= ~N_EXT)
  322. + /* Set the name of the symbol */
  323. + #define S_SET_NAME(s,v)        ((s)->sy_name = v)
  324. + /* Set the offset in the string table */
  325. + #define S_SET_OFFSET(s,v)    ((s)->sy_strx = v)
  326. + /* Set the n_other expression value */
  327. + #define S_SET_OTHER(s,v)    ((s)->sy_other = (v))
  328. + /* Set the n_desc expression value */
  329. + #define S_SET_DESC(s,v)        ((s)->sy_desc = (v))
  330. + /* File header macro and type definition */
  331. + #define H_GET_FILE_SIZE(h)    (sizeof(struct exec) + \
  332. +                  H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  333. +                  H_GET_SYMBOL_TABLE_SIZE(h) + \
  334. +                  H_GET_TEXT_RELOCATION_SIZE(h) + \
  335. +                  H_GET_DATA_RELOCATION_SIZE(h) + \
  336. +                  (h)->string_table_size)
  337. + #define H_GET_TEXT_SIZE(h)        ((h)->header.a_text)
  338. + #define H_GET_DATA_SIZE(h)        ((h)->header.a_data)
  339. + #define H_GET_BSS_SIZE(h)        ((h)->header.a_bss)
  340. + #define H_GET_TEXT_RELOCATION_SIZE(h)    ((h)->header.a_trsize)
  341. + #define H_GET_DATA_RELOCATION_SIZE(h)    ((h)->header.a_drsize)
  342. + #define H_GET_SYMBOL_TABLE_SIZE(h)    ((h)->header.a_syms)
  343. + #define H_GET_MAGIC_NUMBER(h)        ((h)->header.a_magic)
  344. + #define H_GET_ENTRY_POINT(h)        ((h)->header.a_entry)
  345. + #define H_GET_STRING_SIZE(h)        ((h)->string_table_size)
  346. + #ifdef EXEC_MACHINE_TYPE
  347. + #define H_GET_MACHINE_TYPE(h)        ((h)->header.a_machtype)
  348. + #endif /* EXEC_MACHINE_TYPE */
  349. + #ifdef EXEC_VERSION
  350. + #define H_GET_VERSION(h)        ((h)->header.a_version)
  351. + #endif /* EXEC_VERSION */
  352. + #define H_SET_TEXT_SIZE(h,v)        ((h)->header.a_text = (v))
  353. + #define H_SET_DATA_SIZE(h,v)        ((h)->header.a_data = (v))
  354. + #define H_SET_BSS_SIZE(h,v)        ((h)->header.a_bss = (v))
  355. + #define H_SET_RELOCATION_SIZE(h,t,d)    (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
  356. +                      H_SET_DATA_RELOCATION_SIZE((h),(d)))
  357. + #define H_SET_TEXT_RELOCATION_SIZE(h,v)    ((h)->header.a_trsize = (v))
  358. + #define H_SET_DATA_RELOCATION_SIZE(h,v)    ((h)->header.a_drsize = (v))
  359. + #define H_SET_SYMBOL_TABLE_SIZE(h,v)    ((h)->header.a_syms = (v) * \
  360. +                      sizeof(struct nlist))
  361. + #define H_SET_MAGIC_NUMBER(h,v)        ((h)->header.a_magic = (v))
  362. + #define H_SET_ENTRY_POINT(h,v)        ((h)->header.a_entry = (v))
  363. + #define H_SET_STRING_SIZE(h,v)        ((h)->string_table_size = (v))
  364. + #ifdef EXEC_MACHINE_TYPE
  365. + #define H_SET_MACHINE_TYPE(h,v)        ((h)->header.a_machtype = (v))
  366. + #endif /* EXEC_MACHINE_TYPE */
  367. + #ifdef EXEC_VERSION
  368. + #define H_SET_VERSION(h,v)        ((h)->header.a_version = (v))
  369. + #endif /* EXEC_VERSION */
  370. + /* Output the file(s) header(s) in a character array */
  371. + #define H_OUTPUT(h,where)    a_header_append(&(h)->header,(where))
  372. + /* Output a symbol entry */
  373. + #define SYMBOL_OUTPUT(s,w)    a_symbol_append((s), (w))
  374. + typedef struct {
  375. +     struct exec    header;            /* a.out header */
  376. +     long int    string_table_size;    /* names + '\0' + sizeof(int) */
  377. + } object_headers;
  378. + /* Format independent interface functions */
  379. + extern void        emit_relocations();
  380. + extern void        emit_symbols();
  381. + extern void        a_header_append();
  382. + extern void        a_symbol_append();
  383. + #endif /* AOUT_H */
  384. *** /dev/null    Mon Oct 15 09:51:48 1990
  385. --- coff.h    Mon Oct 15 09:59:28 1990
  386. ***************
  387. *** 0 ****
  388. --- 1,366 ----
  389. + #ifndef COFF_H
  390. + #define COFF_H
  391. + #include <filehdr.h>
  392. + #include <aouthdr.h>
  393. + #include <scnhdr.h>
  394. + #include <storclass.h>
  395. + #include <linenum.h>
  396. + #include <syms.h>
  397. + #include <reloc.h>
  398. + #include "machine.h"
  399. + #include "stack.h"
  400. + /* Tag to validate coff object file format processing */
  401. + #define coff
  402. + /* Define some processor dependent values according to the processor we are
  403. +    on. */
  404. + #if defined(PROCESSOR_68000)
  405. + #define BYTE_ORDERING        F_AR32W    /* See filehdr.h for more info. */
  406. + #define FILE_HEADER_MAGIC    MC68MAGIC  /* ... */
  407. + #elif defined(PROCESSOR_i386)
  408. + #define BYTE_ORDERING        F_AR32WR   /* See filehdr.h for more info. */
  409. + #define FILE_HEADER_MAGIC    I386MAGIC  /* ... */
  410. + #elif
  411. + you lose
  412. + #endif 
  413. + /* Magic number of paged executable. */
  414. + #define OMAGIC    0413
  415. + /* Add these definitions to have a consistent convention for all the
  416. +    types used in COFF format. */
  417. + #define AOUTHDR            struct aouthdr
  418. + #define AOUTHDRSZ        sizeof(AOUTHDR)
  419. + /* RELOCATION INFORMATION */
  420. + #define relocation_type RELOC    /* Relocation table entry */
  421. +  
  422. + /* SYMBOL TABLE */
  423. + /* Symbol table entry data type */
  424. + #define symbol_type SYMENT    /* Symbol table entry */
  425. + /* If compiler generate leading underscores, remove them. */
  426. + #ifndef STRIP_UNDERSCORE
  427. + #define STRIP_UNDERSCORE 0
  428. + #endif /* STRIP_UNDERSCORE */
  429. + #define DO_NOT_STRIP    0
  430. + #define DO_STRIP    1
  431. + /* Symbol table macros and constants */
  432. + /* Possible and usefull section number in symbol table 
  433. +  * The values of TEXT, DATA and BSS may not be portable.
  434. +  */
  435. + #define C_TEXT_SECTION        1
  436. + #define C_DATA_SECTION        2
  437. + #define C_BSS_SECTION        3
  438. + #define C_ABS_SECTION        N_ABS
  439. + #define C_UNDEF_SECTION        N_UNDEF
  440. + #define C_DEBUG_SECTION        N_DEBUG
  441. + #define C_NTV_SECTION        N_TV
  442. + #define C_PTV_SECTION        P_TV
  443. + /*
  444. +  *  Macros to extract information from a symbol table entry.
  445. +  *  This syntaxic indirection allows independence regarding a.out or coff.
  446. +  *  The argument (s) of all these macros is a pointer to a symbol table entry.
  447. +  */
  448. + /* Predicates */
  449. + /* True if in text segment */
  450. + #define S_IS_TEXT(s)        ((s)->sy_scnum == C_TEXT_SECTION)
  451. + /* True if in data segment */
  452. + #define S_IS_DATA(s)        ((s)->sy_scnum == C_DATA_SECTION)
  453. + /* True if in bss segment */
  454. + #define S_IS_BSS(s)        ((s)->sy_scnum == C_BSS_SECTION)
  455. + /* True if in bss segment */
  456. + #define S_IS_ABS(s)        ((s)->sy_scnum == C_ABS_SECTION)
  457. + /* True if the symbol is external */
  458. + #define S_IS_EXTERNAL(s)        ((s)->sy_scnum == C_UNDEF_SECTION)
  459. + /* True if symbol has been defined, ie :
  460. +   section > 0 (DATA, TEXT or BSS)
  461. +   section == 0 and value > 0 (external bss symbol) */
  462. + #define S_IS_DEFINED(s)         ((s)->sy_scnum > C_UNDEF_SECTION || \
  463. +                  ((s)->sy_scnum == C_UNDEF_SECTION && \
  464. +                   (s)->sy_value > 0))
  465. + /* True if a debug special symbol entry */
  466. + #define S_IS_DEBUG(s)        ((s)->sy_scnum == C_DEGUG_SECTION)
  467. + /* True if a symbol is local symbol name */
  468. + /* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
  469. + #define S_IS_LOCAL(s)        (S_GET_NAME(s)[0] == '\001' || \
  470. +                  (S_LOCAL_NAME(s) && !flagseen['L']))
  471. + /* True if a symbol is not defined in this file */
  472. + #define S_IS_EXTERN(s)        ((s)->sy_scnum == 0 && (s)->sy_value == 0)
  473. + /*
  474. +  * True if a symbol can be multiply defined (bss symbols have this def
  475. +  * though it is bad practice)
  476. +  */
  477. + #define S_IS_COMMON(s)        ((s)->sy_scnum == 0 && (s)->sy_value != 0)
  478. + /* True if a symbol name is in the string table, i.e. its length is > 8. */
  479. + #define S_IS_STRING(s)        (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
  480. + /* Accessors */
  481. + /* The name of the symbol */
  482. + #define S_GET_NAME(s)        ((char*)(s)->sy_offset)
  483. + /* The pointer to the string table */
  484. + #define S_GET_OFFSET(s)         ((s)->sy_offset)
  485. + /* The zeroes if symbol name is longer than 8 chars */
  486. + #define S_GET_ZEROES(s)        ((s)->sy_zeroes)
  487. + /* The value of the symbol */
  488. + #define S_GET_VALUE(s)        ((s)->sy_value)
  489. + /* The numeric value of the segment */
  490. + #define S_GET_SEGMENT(s)        ((s)->sy_scnum)
  491. + /* The data type */
  492. + #define S_GET_DATA_TYPE(s)    ((s)->sy_type)
  493. + /* The storage class */
  494. + #define S_GET_STORAGE_CLASS(s)    ((s)->sy_sclass)
  495. + /* The number of auxiliary entries */
  496. + #define S_GET_NUMBER_AUXILIARY(s)    ((s)->sy_numaux)
  497. + /* Modifiers */
  498. + /* Set the name of the symbol */
  499. + #define S_SET_NAME(s,v)        ((s)->sy_offset = (unsigned long)(v))
  500. + /* Set the offset of the symbol */
  501. + #define S_SET_OFFSET(s,v)    ((s)->sy_offset = (v))
  502. + /* The zeroes if symbol name is longer than 8 chars */
  503. + #define S_SET_ZEROES(s,v)        ((s)->sy_zeroes = (v))
  504. + /* Set the value of the symbol */
  505. + #define S_SET_VALUE(s,v)    ((s)->sy_value = (v))
  506. + /* The numeric value of the segment */
  507. + #define S_SET_SEGMENT(s,v)        ((s)->sy_scnum = (v))
  508. + /* The data type */
  509. + #define S_SET_DATA_TYPE(s,v)    ((s)->sy_type = (v))
  510. + /* The storage class */
  511. + #define S_SET_STORAGE_CLASS(s,v)    ((s)->sy_sclass = (v))
  512. + /* The number of auxiliary entries */
  513. + #define S_SET_NUMBER_AUXILIARY(s,v)    ((s)->sy_numaux = (v))
  514. + /* Additional modifiers */
  515. + /* Assume that a symbol cannot be simultaneously in more than on segment */
  516. + /* Set the segment to text */
  517. + #define S_SET_TEXT(s)        ((s)->sy_scnum = C_TEXT_SECTION)
  518. + /* Set the segment to data */
  519. + #define S_SET_DATA(s)        ((s)->sy_scnum = C_DATA_SECTION)
  520. + /* Set the segment to bss */
  521. + #define S_SET_BSS(s)        ((s)->sy_scnum = C_BSS_SECTION)
  522. + /* Set the segment to abs */
  523. + #define S_SET_ABS(s)        ((s)->sy_scnum = C_ABS_SECTION)
  524. + /* The symbol is external (does not mean undefined) */
  525. + #define S_SET_EXTERNAL(s)       S_SET_STORAGE_CLASS(s,C_EXT)
  526. + /* Auxiliary entry macros. SA_ stands for symbol auxiliary */
  527. + /* Omit the tv related fields */
  528. + /* Accessors */
  529. + #define SA_GET_SYM_TAGNDX(s)    ((s)->sy_auxent.x_sym.x_tagndx)
  530. + #define SA_GET_SYM_LNNO(s)    ((s)->sy_auxent.x_sym.x_misc.x_lnsz.x_lnno)
  531. + #define SA_GET_SYM_SIZE(s)    ((s)->sy_auxent.x_sym.x_misc.x_lnsz.x_size)
  532. + #define SA_GET_SYM_FSIZE(s)    ((s)->sy_auxent.x_sym.x_misc.x_fsize)
  533. + #define SA_GET_SYM_LNNOPTR(s)    ((s)->sy_auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr)
  534. + #define SA_GET_SYM_ENDNDX(s)    ((s)->sy_auxent.x_sym.x_fcnary.x_fcn.x_endndx)
  535. + #define SA_GET_SYM_DIMEN(s,i)    ((s)->sy_auxent.x_sym.x_fcnary.x_ary.x_dimen[(i)])
  536. + #define SA_GET_FILE_FNAME(s)    ((s)->sy_auxent.x_file.x_fname)
  537. + #define SA_GET_SCN_SCNLEN(s)    ((s)->sy_auxent.x_scn.x_scnlen)
  538. + #define SA_GET_SCN_NRELOC(s)    ((s)->sy_auxent.x_scn.x_nreloc)
  539. + #define SA_GET_SCN_NLINNO(s)    ((s)->sy_auxent.x_scn.x_nlinno)
  540. + /* Modifiers */
  541. + #define SA_SET_SYM_TAGNDX(s,v)    ((s)->sy_auxent.x_sym.x_tagndx=(v))
  542. + #define SA_SET_SYM_LNNO(s,v)    ((s)->sy_auxent.x_sym.x_misc.x_lnsz.x_lnno=(v))
  543. + #define SA_SET_SYM_SIZE(s,v)    ((s)->sy_auxent.x_sym.x_misc.x_lnsz.x_size=(v))
  544. + #define SA_SET_SYM_FSIZE(s,v)    ((s)->sy_auxent.x_sym.x_misc.x_fsize=(v))
  545. + #define SA_SET_SYM_LNNOPTR(s,v)    ((s)->sy_auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
  546. + #define SA_SET_SYM_ENDNDX(s,v)    ((s)->sy_auxent.x_sym.x_fcnary.x_fcn.x_endndx=(v))
  547. + #define SA_SET_SYM_DIMEN(s,i,v)    ((s)->sy_auxent.x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
  548. + #define SA_SET_FILE_FNAME(s,v)    strncpy((s)->sy_auxent.x_file.x_fname,(v),FILNMLEN)
  549. + #define SA_SET_SCN_SCNLEN(s,v)    ((s)->sy_auxent.x_scn.x_scnlen=(v))
  550. + #define SA_SET_SCN_NRELOC(s,v)    ((s)->sy_auxent.x_scn.x_nreloc=(v))
  551. + #define SA_SET_SCN_NLINNO(s,v)    ((s)->sy_auxent.x_scn.x_nlinno=(v))
  552. + /* Internal use only definitions. SF_ stands for symbol flags. */
  553. + /* These values can be assigned to sy_flags field of a symbolS */
  554. + /* The first 16 bits are general purpose. The last 16 bits are debug info */
  555. + #define SF_STATICS        0x00000001 /* Mark the .text & all symbols */
  556. + #define SF_DEFINED        0x00000002 /* Symbol is defined in this file */
  557. + #define SF_STRING        0x00000004 /* Symbol name length > 8 */
  558. + #define SF_LOCAL        0x00000008 /* Symbol must not be emitted */
  559. + #define SF_FUNCTION        0x00010000 /* The symbol is a function */
  560. + #define SF_PROCESS        0x00020000 /* Process symbol before write */
  561. + #define SF_TAGGED        0x00040000 /* Is associated with a tag */
  562. + #define SF_TAG            0x00080000 /* Is a tag */
  563. + #define SF_DEBUG        0x00100000 /* Is in debug or abs section */
  564. + /* Masks */
  565. + #define SF_NORMAL_MASK        0x0000ffff /* Non debug information */
  566. + #define SF_DEBUG_MASK        0xffff0000 /* Debug information */
  567. + /* Accessors */
  568. + #define SF_GET(s)        ((s)->sy_flags)
  569. + #define SF_GET_NORMAL_FIELD(s)    ((s)->sy_flags & SF_NORMAL_MASK)
  570. + #define SF_GET_DEBUG_FIELD(s)    ((s)->sy_flags & SF_DEBUG_MASK)
  571. + #define SF_GET_FILE(s)        ((s)->sy_flags & SF_FILE)
  572. + #define SF_GET_STATICS(s)    ((s)->sy_flags & SF_STATICS)
  573. + #define SF_GET_DEFINED(s)    ((s)->sy_flags & SF_DEFINED)
  574. + #define SF_GET_STRING(s)    ((s)->sy_flags & SF_STRING)
  575. + #define SF_GET_LOCAL(s)        ((s)->sy_flags & SF_LOCAL)
  576. + #define SF_GET_FUNCTION(s)      ((s)->sy_flags & SF_FUNCTION)
  577. + #define SF_GET_PROCESS(s)    ((s)->sy_flags & SF_PROCESS)
  578. + #define SF_GET_DEBUG(s)        ((s)->sy_flags & SF_DEBUG)
  579. + #define SF_GET_TAGGED(s)    ((s)->sy_flags & SF_TAGGED)
  580. + #define SF_GET_TAG(s)        ((s)->sy_flags & SF_TAG)
  581. + /* Modifiers */
  582. + #define SF_SET(s,v)        ((s)->sy_flags = (v))
  583. + #define SF_SET_NORMAL_FIELD(s,v)((s)->sy_flags |= ((v) & SF_NORMAL_MASK))
  584. + #define SF_SET_DEBUG_FIELD(s,v)    ((s)->sy_flags |= ((v) & SF_DEBUG_MASK))
  585. + #define SF_SET_FILE(s)        ((s)->sy_flags |= SF_FILE)
  586. + #define SF_SET_STATICS(s)    ((s)->sy_flags |= SF_STATICS)
  587. + #define SF_SET_DEFINED(s)    ((s)->sy_flags |= SF_DEFINED)
  588. + #define SF_SET_STRING(s)    ((s)->sy_flags |= SF_STRING)
  589. + #define SF_SET_LOCAL(s)        ((s)->sy_flags |= SF_LOCAL)
  590. + #define SF_SET_FUNCTION(s)      ((s)->sy_flags |= SF_FUNCTION)
  591. + #define SF_SET_PROCESS(s)    ((s)->sy_flags |= SF_PROCESS)
  592. + #define SF_SET_DEBUG(s)        ((s)->sy_flags |= SF_DEBUG)
  593. + #define SF_SET_TAGGED(s)    ((s)->sy_flags |= SF_TAGGED)
  594. + #define SF_SET_TAG(s)        ((s)->sy_flags |= SF_TAG)
  595. + /* File header macro and type definition */
  596. + /*
  597. +  * File position calculators. Beware to use them when all the
  598. +  * appropriate fields are set in the header.
  599. +  */
  600. + #define H_GET_FILE_SIZE(h) \
  601. +     (long)(FILHSZ + AOUTHDRSZ + \
  602. +        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  603. +        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  604. +        H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
  605. +        H_GET_SYMBOL_TABLE_SIZE(h) * SYMESZ + \
  606. +        (h)->string_table_size)
  607. + #define H_GET_TEXT_FILE_OFFSET(h) \
  608. +     (long)(FILHSZ + AOUTHDRSZ + \
  609. +        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
  610. + #define H_GET_DATA_FILE_OFFSET(h) \
  611. +     (long)(FILHSZ + AOUTHDRSZ + \
  612. +        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  613. +        H_GET_TEXT_SIZE(h))
  614. + #define H_GET_BSS_FILE_OFFSET(h) 0
  615. + #define H_GET_RELOCATION_FILE_OFFSET(h) \
  616. +     (long)(FILHSZ + AOUTHDRSZ + \
  617. +        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  618. +        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
  619. + #define H_GET_LINENO_FILE_OFFSET(h) \
  620. +     (long)(FILHSZ + AOUTHDRSZ + \
  621. +        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  622. +        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  623. +        H_GET_RELOCATION_SIZE(h))
  624. + #define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
  625. +     (long)(FILHSZ + AOUTHDRSZ + \
  626. +        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  627. +        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  628. +        H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
  629. + /* Accessors */
  630. + /* aouthdr */
  631. + #define H_GET_MAGIC_NUMBER(h)           ((h)->aouthdr.magic)
  632. + #define H_GET_VERSION_STAMP(h)        ((h)->aouthdr.vstamp)
  633. + #define H_GET_TEXT_SIZE(h)              ((h)->aouthdr.tsize)
  634. + #define H_GET_DATA_SIZE(h)              ((h)->aouthdr.dsize)
  635. + #define H_GET_BSS_SIZE(h)               ((h)->aouthdr.bsize)
  636. + #define H_GET_ENTRY_POINT(h)            ((h)->aouthdr.entry)
  637. + #define H_GET_TEXT_START(h)        ((h)->aouthdr.text_start)
  638. + #define H_GET_DATA_START(h)        ((h)->aouthdr.data_start)
  639. + /* filehdr */
  640. + #define H_GET_FILE_MAGIC_NUMBER(h)    ((h)->filehdr.f_magic)
  641. + #define H_GET_NUMBER_OF_SECTIONS(h)    ((h)->filehdr.f_nscns)
  642. + #define H_GET_TIME_STAMP(h)        ((h)->filehdr.f_timdat)
  643. + #define H_GET_SYMBOL_TABLE_POINTER(h)    ((h)->filehdr.f_symptr)
  644. + #define H_GET_SYMBOL_TABLE_SIZE(h)    ((h)->filehdr.f_nsyms)
  645. + #define H_GET_SIZEOF_OPTIONAL_HEADER(h)    ((h)->filehdr.f_opthdr)
  646. + #define H_GET_FLAGS(h)            ((h)->filehdr.f_flags)
  647. + /* Extra fields to achieve bsd a.out compatibility and for convinience */
  648. + #define H_GET_RELOCATION_SIZE(h)       ((h)->relocation_size)
  649. + #define H_GET_STRING_SIZE(h)            ((h)->string_table_size)
  650. + #define H_GET_LINENO_SIZE(h)            ((h)->lineno_size)
  651. + /* Modifiers */
  652. + /* aouthdr */
  653. + #define H_SET_MAGIC_NUMBER(h,v)         ((h)->aouthdr.magic = (v))
  654. + #define H_SET_VERSION_STAMP(h,v)    ((h)->aouthdr.vstamp = (v))
  655. + #define H_SET_TEXT_SIZE(h,v)            ((h)->aouthdr.tsize = (v))
  656. + #define H_SET_DATA_SIZE(h,v)            ((h)->aouthdr.dsize = (v))
  657. + #define H_SET_BSS_SIZE(h,v)             ((h)->aouthdr.bsize = (v))
  658. + #define H_SET_ENTRY_POINT(h,v)          ((h)->aouthdr.entry = (v))
  659. + #define H_SET_TEXT_START(h,v)        ((h)->aouthdr.text_start = (v))
  660. + #define H_SET_DATA_START(h,v)        ((h)->aouthdr.data_start = (v))
  661. + /* filehdr */
  662. + #define H_SET_FILE_MAGIC_NUMBER(h,v)    ((h)->filehdr.f_magic = (v))
  663. + #define H_SET_NUMBER_OF_SECTIONS(h,v)    ((h)->filehdr.f_nscns = (v))
  664. + #define H_SET_TIME_STAMP(h,v)        ((h)->filehdr.f_timdat = (v))
  665. + #define H_SET_SYMBOL_TABLE_POINTER(h,v)    ((h)->filehdr.f_symptr = (v))
  666. + #define H_SET_SYMBOL_TABLE_SIZE(h,v)    ((h)->filehdr.f_nsyms = (v))
  667. + #define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
  668. + #define H_SET_FLAGS(h,v)        ((h)->filehdr.f_flags = (v))
  669. + /* Extra fields to achieve bsd a.out compatibility and for convinience */
  670. + #define H_SET_RELOCATION_SIZE(h,t,d)     ((h)->relocation_size = (t)+(d))
  671. + #define H_SET_STRING_SIZE(h,v)          ((h)->string_table_size = (v))
  672. + #define H_SET_LINENO_SIZE(h,v)          ((h)->lineno_size = (v))
  673. + /* Output the file(s) header(s) in a character array */
  674. + #define H_OUTPUT(h,where) c_header_append(&(h)->aouthdr, &(h)->filehdr,(where))
  675. + /* Output a symbol entry */
  676. + #define SYMBOL_OUTPUT(s,w)    c_symbol_append((s), (w))
  677. + typedef struct {
  678. +     AOUTHDR       aouthdr;             /* a.out header */
  679. +     FILHDR       filehdr;        /* File header, not machine dep. */
  680. +     long int       string_table_size;   /* names + '\0' + sizeof(int) */
  681. +     long int       relocation_size;    /* Cumulated size of relocation
  682. +                        information for all sections in
  683. +                        bytes. */
  684. +     long int       lineno_size;        /* Size of the line number information
  685. +                        table in bytes */
  686. + } object_headers;
  687. + /* Format independent interface functions */
  688. + extern void             emit_relocations();
  689. + extern void        emit_symbols();
  690. + extern void        c_symbol_merge();
  691. + extern void             c_header_append();
  692. + extern void             c_symbol_append();
  693. + extern void        c_section_header_append();
  694. + extern char*        c_section_symbol();
  695. + extern void        c_section_header();
  696. + /* --------------  Line number handling ------- */
  697. + extern int        text_lineno_number;
  698. + typedef struct internal_lineno {
  699. +     LINENO line;            /* The lineno structure itself */
  700. +     char* frag;                /* Frag the line number is related to*/
  701. +     struct internal_lineno* next;    /* Forward chain pointer */
  702. + } lineno;
  703. + extern lineno* c_new_file();
  704. + extern void    emit_lineno();
  705. + extern lineno* lineno_rootP;
  706. + extern lineno* lineno_lastP;
  707. + #endif /* COFF_H */
  708. *** /dev/null    Mon Oct 15 09:51:48 1990
  709. --- m-motor.h    Mon Oct 15 08:12:50 1990
  710. ***************
  711. *** 0 ****
  712. --- 1,10 ----
  713. + /* Machine specific defines for the unisoft 680x0 V.3.2 version 1.3 */
  714. + #define unisoft
  715. + #define PROCESSOR_68000
  716. + /* Return true if s (a non null string pointer), points to a local variable
  717. +    name. */
  718. + #define S_LOCAL_NAME(s)  (S_GET_NAME(s)[0] == 'L')
  719. + /* Remove leading underscore from the gcc generated symbol names */
  720. + #define STRIP_UNDERSCORE 1
  721. *** /dev/null    Mon Oct 15 09:51:48 1990
  722. --- README.coff    Mon Oct 15 17:42:45 1990
  723. ***************
  724. *** 0 ****
  725. --- 1,79 ----
  726. + The coff patches intend to do the following :
  727. +    . Generate coff files very compatible with vanilla linker.
  728. +    . Understands coff debug directives.
  729. + Here are the guidelines of the work I have done :
  730. +    . Encapsulate format dependent code in macros where it is possible.
  731. +    . Where not possible differenciate with #ifdef
  732. +    . try not to change the calling conventions of the existing functions. 
  733. +     I made one exception : symbol_new. I would be pleased to hear about
  734. +     a better solution. (symbols.c)
  735. +    . Extend the use of N_TYPE_seg seg_N_TYPE tables so that segments can
  736. +     be manipulated without using their format dependent name. (subsegs.c)
  737. +    . Write a function to parse the .def debug directives
  738. +    . Write two small peaces of code to handle the .ln directive.
  739. +    . In write.c try to move all the cross compilation specifics (md_..) to
  740. +      format dependent files.
  741. +    . Encapsulate the data structures using generic types, macros calls.
  742. +    . Added too much code to resolve the complexity of the symbol table
  743. +      generated. Most of the code deals with debug stuff.
  744. +    . Create another makefile, shorter, cleaner.
  745. +    . Create a config.gas shell script to mimic the gcc,gdb... configuration
  746. +     mechanism. This reduce the complexity of the makefile.
  747. +    . Isolate the format dependent code in two files 
  748. +     coff.c coff.h
  749. +     aout.c aout.h
  750. +     elf.c elf.h    [ Not yet ;-]
  751. +    . added a little stack management routine for coff in file stack.c
  752. +    . isolate os specific flags in m- files
  753. + If further development is planed on it is should solve the following problems :
  754. +    . Encapsulate DESC & OTHER tests in a macro call. I'm not aware
  755. +     of their exact semantics.
  756. +    . Clean up the seg_N_TYPE N_TYPE_seg naming scheme
  757. +    . Try to remove as much reference to segment dependent names as possible
  758. +    . Find a cleaner solution for symbol_new.
  759. +    . Report the modifications on vax, ns32k, sparc machine dependent files.
  760. +     To acheive this goal, search for \<N_, sy_, symbol_new and symbolS.
  761. +    . Allow an arbitrary number of segments (spare sections .ctor .dtor .bletch)
  762. +    . Find a way to extend the debug information without breaking sdb
  763. +      compatibility. Mainly intended for G++.
  764. +    . should it do something to generate shared libraries objects ?
  765. + I have tested this code on the following processor/os. gcc-1.37.1 was
  766. +    used for all the tests.
  767. + 386    SCO unix ODT
  768. +     gcc-1.37.1, gas, emacs-18.55
  769. + 386    Esix rev C
  770. +     gas-1.36/write.s
  771. + 386    Ix 2.02
  772. +     gas, all the X11R4 mit clients
  773. + 386    CTIX 3.2
  774. +     xsol (X11R4 solitary game), gas
  775. + 68030    unisoft 1.3    
  776. +     the kernel (V.3.2) + tcp/ip extensions
  777. +     bash-1.05, bison-1.11, compress-4.0, cproto, cshar, diff-1.14,
  778. +     dist-18.55, flex-2.3, gas-1.36, gcc-1.37.1, gdb-3.6, grep-1.5,
  779. +     kermit, make-3.58, makedep, patch, printf,
  780. +     tar-1.08, texi2roff, uuencode, uutraf-1.2
  781. + 68020    sunos 3.5 (no, not coff, just to be sure that I didn't
  782. +             introduce errors)
  783. +     gcc-1.37.1, gas, emacs-18.55, gdb-3.6, bison-1.11, diff-1.14, 
  784. +     make-3.58, tar-1.08
  785. + 68030   sunos 4.0.3 (idem)
  786. +     gas
  787. + I would be glad to hear about new experiences
  788. +     Loic  (loic@adesign.uucp or loic@afp.uucp)
  789. *** /dev/null    Mon Oct 15 09:51:48 1990
  790. --- append.h    Thu Aug  2 15:00:24 1990
  791. ***************
  792. *** 0 ****
  793. --- 1,1 ----
  794. + extern void    append();
  795. *** /dev/null    Mon Oct 15 09:51:48 1990
  796. --- config.gas    Mon Oct 15 17:22:59 1990
  797. ***************
  798. *** 0 ****
  799. --- 1,61 ----
  800. + # Set the appropriate links for machine dependent files
  801. +  
  802. + # Chose one of
  803. + #
  804. + # i386                for 386 box running SCO unix (ODT),
  805. + #                                Esix rev C
  806. + #                            Ix 2.02
  807. + #                            CTIX 3.2
  808. + #
  809. + # sun-3                for sun3 running SunOs 3.5
  810. + #                         SunOs 4.0.3
  811. + #                    
  812. + # motorola-3600-unisoft-1.3    for Motorola 3600 running Unisoft 1.3 (V.3.2)
  813. + # microlec-2030-lectra-1    for Microlec 2030 running Lectra 1.1
  814. + case $1 in
  815. +     default)
  816. +         cp /dev/null dependencies
  817. +         ln aout.h oformat.h
  818. +         exit
  819. +     ;;
  820. +     sun-3)
  821. +         [ -f m68k.h ] && rm -f m68k.h
  822. +         ln m-sun3.h m68k.h
  823. +         machine_file=m68k.c
  824. +         atof_file=atof-ieee.c
  825. +         machine_header=m-sun3.h
  826. +         opcode_header=m68k-opcode.h
  827. +         object_format=aout
  828. +     ;;
  829. +     motorola-3600-unisoft-1.3|microlec-2030-lectra-1.1)
  830. +         [ -f m68k.h ] && rm -f m68k.h
  831. +         ln m-sun3.h m68k.h
  832. +         machine_file=m68k.c
  833. +         atof_file=atof-ieee.c
  834. +         machine_header=m-motor.h
  835. +         opcode_header=m68k-opcode.h
  836. +         object_format=coff
  837. +     ;;
  838. +     i386)
  839. +         [ -f m68k.h ] && rm -f m68k.h
  840. +         machine_file=i386.c
  841. +         atof_file=atof-ieee.c
  842. +         machine_header=m-i386.h
  843. +         opcode_header=i386-opcode.h
  844. +         object_format=coff
  845. +     ;;
  846. +     *)
  847. +         echo $1 not a known configuration
  848. +         exit 1
  849. +     ;;
  850. + esac
  851. + rm -f machine.c atof.c machine.h oformat.h oformat.c opcode.h
  852. + set -x
  853. + ln $machine_file machine.c
  854. + ln $atof_file atof.c
  855. + ln $machine_header machine.h
  856. + ln ${object_format}.c oformat.c
  857. + ln ${object_format}.h oformat.h
  858. + ln ${opcode_header} opcode.h
  859. *** /dev/null    Mon Oct 15 09:51:48 1990
  860. --- stack.c    Wed Aug 29 13:22:32 1990
  861. ***************
  862. *** 0 ****
  863. --- 1,59 ----
  864. + #include "stack.h"
  865. + extern char* malloc();
  866. + extern char* realloc();
  867. + stack* stack_init(chunk_size, element_size)
  868. + unsigned long chunk_size;
  869. + unsigned long element_size;
  870. + {
  871. +     stack* st;
  872. +     if((st = (stack*)malloc(sizeof(stack))) == (stack*)0)
  873. +     return (stack*)0;
  874. +     if((st->data = malloc(chunk_size)) == (char*)0) {
  875. +     free(st);
  876. +     return (stack*)0;
  877. +     }
  878. +     st->pointer = 0;
  879. +     st->size = chunk_size;
  880. +     st->chunk_size = chunk_size;
  881. +     st->element_size = element_size;
  882. +     return st;
  883. + }
  884. + void stack_delete(st)
  885. + stack* st;
  886. + {
  887. +     free(st->data);
  888. +     free(st);
  889. + }
  890. + char* stack_push(st, element)
  891. + stack* st;
  892. + char* element;
  893. + {
  894. +     if(st->pointer + st->element_size >= st->size) {
  895. +     st->size += st->chunk_size;
  896. +     if((st->data = realloc(st->data, st->size)) == (char*)0)
  897. +         return (char*)0;
  898. +     }
  899. +     memcpy(st->data + st->pointer, element, st->element_size);
  900. +     st->pointer += st->element_size;
  901. +     return st->data + st->pointer;
  902. + }
  903. + char* stack_pop(st)
  904. + stack* st;
  905. + {
  906. +     if((st->pointer -= st->element_size) < 0) {
  907. +     st->pointer = 0;
  908. +     return (char*)0;
  909. +     }
  910. +     return st->data + st->pointer;
  911. + }
  912. + char* stack_top(st)
  913. + stack* st;
  914. + {
  915. +     return st->data + st->pointer - st->element_size;
  916. + }
  917. *** /dev/null    Mon Oct 15 09:51:48 1990
  918. --- aout.c    Mon Oct 15 08:53:32 1990
  919. ***************
  920. *** 0 ****
  921. --- 1,146 ----
  922. + #include "as.h"
  923. + #include "md.h"
  924. + #include "aout.h"
  925. + #include "struc-symbol.h"
  926. + #include "write.h"
  927. + #include "append.h"
  928. + /* Relocation. */
  929. + /*
  930. +  * In: length of relocation (or of address) in chars: 1, 2 or 4.
  931. +  * Out: GNU LD relocation length code: 0, 1, or 2.
  932. +  */
  933. + static unsigned char
  934. + nbytes_r_length [] = {
  935. +   42, 0, 1, 42, 2
  936. +   };
  937. + /* The sparc needs its own emit_relocations() */
  938. + #ifndef SPARC
  939. + /*
  940. +  *        emit_relocations()
  941. +  *
  942. +  * Crawl along a fixS chain. Emit the segment's relocations.
  943. +  */
  944. + void
  945. + emit_relocations (fixP, segment_address_in_file)
  946. +      register fixS *    fixP;    /* Fixup chain for this segment. */
  947. +      relax_addressT    segment_address_in_file;
  948. + {
  949. +   struct relocation_info    ri;
  950. +   register symbolS *        symbolP;
  951. +     /* JF this is for paranoia */
  952. +   bzero((char *)&ri,sizeof(ri));
  953. +   for ( ;  fixP;  fixP = fixP -> fx_next)
  954. +     {
  955. +       if (symbolP = fixP -> fx_addsy)
  956. +     {
  957. + #ifndef hpux
  958. +         /* These two 'cuz of NS32K */
  959. +       ri . r_bsr        = fixP -> fx_bsr;
  960. +       ri . r_disp        = fixP -> fx_im_disp;
  961. + #endif
  962. +       ri . r_length        = nbytes_r_length [fixP -> fx_size];
  963. +       ri . r_pcrel        = fixP -> fx_pcrel;
  964. +       ri . r_address    = fixP -> fx_frag -> fr_address
  965. +         +   fixP -> fx_where
  966. +           - segment_address_in_file;
  967. +       if ((symbolP -> sy_type & N_TYPE) == N_UNDF)
  968. +         {
  969. +           ri . r_extern    = 1;
  970. +           ri . r_symbolnum    = symbolP -> sy_number;
  971. +         }
  972. +       else
  973. +         {
  974. +           ri . r_extern    = 0;
  975. +           ri . r_symbolnum    = symbolP -> sy_type & N_TYPE;
  976. +         }
  977. +       /* 
  978. +         The 68k machines assign bit-fields from higher bits to 
  979. +         lower bits ("left-to-right") within the int.  VAXen assign 
  980. +         bit-fields from lower bits to higher bits ("right-to-left").
  981. +         Both handle multi-byte numbers in their usual fashion
  982. +         (Big-endian and little-endian stuff).
  983. +         Thus we need a machine dependent routine to make
  984. +         sure the structure is written out correctly.  FUN!
  985. +        */
  986. +       md_ri_to_chars((char *) &ri, ri); 
  987. +       append (&next_object_file_charP, (char *)& ri, (unsigned long)sizeof(ri));
  988. +     }
  989. +     }
  990. + }
  991. + #endif
  992. + /* Aout file generation & utilities */
  993. + /* Convert a lvalue to machine dependent data */
  994. + #define MD(v)    \
  995. +   md_number_to_chars((char *)&header->v,header->v, sizeof(header->v))
  996. + void a_header_append(header, where)
  997. + struct exec * header;
  998. + char** where;
  999. + {
  1000. +     MD(a_text);
  1001. +     MD(a_data);
  1002. +     MD(a_bss);
  1003. +     MD(a_trsize);
  1004. +     MD(a_drsize);
  1005. +     MD(a_syms);
  1006. +     MD(a_magic);
  1007. +     MD(a_entry);
  1008. + #ifdef EXEC_MACHINE_TYPE
  1009. +     MD(a_machtype);
  1010. + #endif /* EXEC_MACHINE_TYPE */
  1011. + #ifdef EXEC_VERSION
  1012. +     MD(a_version);
  1013. + #endif /* EXEC_VERSION */
  1014. +     append(where, (char *)header, sizeof(struct exec));
  1015. + }
  1016. + #undef MD
  1017. + /* Convert a lvalue to machine dependent data */
  1018. + #define MD(v)    \
  1019. +   md_number_to_chars((char *)&symbolP->v,symbolP->v, sizeof(symbolP->v))
  1020. + void a_symbol_append(symbolP, where)
  1021. + symbolS *    symbolP;
  1022. + char**         where;
  1023. + {
  1024. +     MD(sy_strx);
  1025. +     MD(sy_desc);
  1026. +     MD(sy_value);
  1027. +     append(where, (char *)&symbolP->sy_symbol, sizeof(symbol_type));
  1028. + }
  1029. + void emit_symbols(symbol_rootP, where)
  1030. + symbolS *    symbol_rootP;
  1031. + char**        where;
  1032. + {
  1033. +     symbolS *    symbolP;
  1034. +     /*
  1035. +      * Emit all symbols left in the symbol chain.
  1036. +      */
  1037. +     for(symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next) {
  1038. +     /* Used to save the offset of the name. It is used to point
  1039. +        to the string in memory but must be a file offset. */
  1040. +     register char *    temp;
  1041. +     temp = S_GET_NAME(symbolP);
  1042. +     S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
  1043. +     /* Any symbol still undefined is made N_EXT. */
  1044. +     if (!S_IS_DEFINED(symbolP))
  1045. +         S_SET_EXTERNAL(symbolP);
  1046. +     SYMBOL_OUTPUT(symbolP, where);
  1047. +     S_SET_NAME(symbolP,temp);
  1048. +     }
  1049. + }
  1050. --
  1051. Loic Dachary     loic@adesign.uucp or loic@afp.uucp 
  1052. Voice        +33 1 40 35 20 20
  1053.