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

  1. From: loic@adesign.uucp (Loic Dachary)
  2. Newsgroups: alt.sources
  3. Subject: gas-1.36 patches for COFF generation patch01
  4. Message-ID: <LOIC.90Oct23011902@adesign.uucp>
  5. Date: 23 Oct 90 00:19:02 GMT
  6.  
  7.  
  8.     Here is the first bug fix to gas-coff patches (gas-coff/patch01).
  9.  
  10. . Special conditions where not tested when manipulating the double linked list
  11.   of symbols. This was not very clean but harmless. However the code has
  12.   been changed.
  13. . The c_dot_file_symbol function messed up the symbol list if called by
  14.   write_object instead of s_file. I.e. if .file was missing, gas bombed.
  15.  
  16. *** coff.c    Mon Oct 15 08:53:16 1990
  17. --- /spare/usenet/port/gas-1.36/coff.c    Tue Oct 23 00:06:12 1990
  18. ***************
  19. *** 242,250 ****
  20.   char*    filename;
  21.   {
  22.       symbolS* symbolP;
  23. -     symbolS* ante_lastP;
  24. -     ante_lastP = symbol_lastP;
  25.       
  26.       symbolP = symbol_new(".file", SEG_DEBUG, 0,
  27.                      C_FILE, &zero_address_frag);
  28. --- 242,247 ----
  29. ***************
  30. *** 254,262 ****
  31.   
  32.       /* Make sure that the symbol is first on the symbol chain */
  33.       if(symbol_rootP != symbolP) {
  34. !     symbol_lastP = ante_lastP;
  35. !     symbol_lastP->sy_next = NULL;
  36. !     symbolP->sy_next = symbol_rootP;
  37.       symbol_rootP = symbolP;
  38.       }
  39.   }
  40. --- 251,259 ----
  41.   
  42.       /* Make sure that the symbol is first on the symbol chain */
  43.       if(symbol_rootP != symbolP) {
  44. !     symbol_lastP = symbol_lastP->sy_previous;
  45. !     DL_REMOVE(symbolP);
  46. !     DL_INSERT(symbolP, symbol_rootP);
  47.       symbol_rootP = symbolP;
  48.       }
  49.   }
  50. *** coff.h    Mon Oct 15 09:59:28 1990
  51. --- /spare/usenet/port/gas-1.36/coff.h    Mon Oct 22 17:29:56 1990
  52. ***************
  53. *** 57,62 ****
  54. --- 57,88 ----
  55.   #define DO_NOT_STRIP    0
  56.   #define DO_STRIP    1
  57.   
  58. + /* Double linked list manipulations macros. */
  59. + /* See struc-symbol.h for a definition of symbolS. */
  60. + /* Remove the argument from the list. */
  61. + #define DL_REMOVE(p)    \
  62. +     (((p)->sy_next && ((p)->sy_next->sy_previous = (p)->sy_previous)),\
  63. +      ((p)->sy_previous && ((p)->sy_previous->sy_next = (p)->sy_next)))
  64. + /* Set the chain symbols to null. */
  65. + #define DL_CLEAR(p)    \
  66. +     ((p)->sy_next = (symbolS*)0, (p)->sy_previous = (symbolS*)0)
  67. + /* Link symbol p after symbol w in the chain. */
  68. + #define DL_APPEND(p,w)    \
  69. +     (((w)->sy_next && ((w)->sy_next->sy_previous = (p))),    \
  70. +      ((p)->sy_next = (w)->sy_next),                \
  71. +      ((w)->sy_next = (p)),                       \
  72. +      ((p)->sy_previous = (w)))
  73. + /* Link symbol p before symbol w in the chain. */
  74. + #define DL_INSERT(p,w)    \
  75. +     (((w)->sy_previous && ((w)->sy_previous->sy_next = (p))),    \
  76. +      ((p)->sy_previous = (w)->sy_previous),            \
  77. +      ((w)->sy_previous = (p)),                    \
  78. +      ((p)->sy_next = (w)))
  79.   /* Symbol table macros and constants */
  80.   
  81.   /* Possible and usefull section number in symbol table 
  82. *** read.c    Mon Oct 22 22:35:07 1990
  83. --- /spare/usenet/port/gas-1.36/read.c    Mon Oct 22 22:39:11 1990
  84. ***************
  85. *** 1395,1402 ****
  86.       symbolP = (symbolS *)obstack_alloc(¬es, sizeof(symbolS));
  87.       memcpy((char*)symbolP, &symbol, sizeof(symbolS));
  88.   
  89. !     symbol_lastP->sy_next = symbolP;
  90. !     symbolP->sy_previous = symbol_lastP;
  91.       symbol_lastP = symbolP;
  92.   
  93.       } else {
  94. --- 1395,1401 ----
  95.       symbolP = (symbolS *)obstack_alloc(¬es, sizeof(symbolS));
  96.       memcpy((char*)symbolP, &symbol, sizeof(symbolS));
  97.   
  98. !     DL_APPEND(symbolP, symbol_lastP);
  99.       symbol_lastP = symbolP;
  100.   
  101.       } else {
  102. ***************
  103. *** 1408,1424 ****
  104.       c_symbol_merge(&symbol, symbolP);
  105.       /* For the function, the symbol *must* be were the debug symbol
  106.          appear. Move the existing symbol to the current place. */
  107. -     /* Do not take in account special cases where symbolP is first 
  108. -        in the list. It is always after a .bf */
  109.       if(SF_GET_FUNCTION(symbolP)) {
  110.           /* If it already is at the end of the symbol list, do nothing */
  111.           if(symbolP != symbol_lastP) {
  112. !         /* Remove from the list */
  113. !         symbolP->sy_next->sy_previous = symbolP->sy_previous;
  114. !         symbolP->sy_previous->sy_next = symbolP->sy_next;
  115. !         /* Append at the end of the list */
  116. !         symbol_lastP->sy_next = symbolP;
  117. !         symbolP->sy_previous = symbol_lastP;
  118.           symbol_lastP = symbolP;
  119.           }
  120.       } else
  121. --- 1407,1417 ----
  122.       c_symbol_merge(&symbol, symbolP);
  123.       /* For the function, the symbol *must* be were the debug symbol
  124.          appear. Move the existing symbol to the current place. */
  125.       if(SF_GET_FUNCTION(symbolP)) {
  126.           /* If it already is at the end of the symbol list, do nothing */
  127.           if(symbolP != symbol_lastP) {
  128. !         DL_REMOVE(symbolP);
  129. !         DL_APPEND(symbolP, symbol_lastP);
  130.           symbol_lastP = symbolP;
  131.           }
  132.       } else
  133. *** symbols.c    Mon Oct 22 22:35:10 1990
  134. --- /spare/usenet/port/gas-1.36/symbols.c    Mon Oct 22 22:38:42 1990
  135. ***************
  136. *** 220,227 ****
  137.        * Link to end of symbol chain .
  138.        */
  139.       if (symbol_lastP) {
  140. !     symbol_lastP->sy_next = symbolP;
  141. !     symbolP->sy_previous = symbol_lastP;
  142.       } else {
  143.       symbol_rootP = symbolP;
  144.       }
  145. --- 220,226 ----
  146.        * Link to end of symbol chain .
  147.        */
  148.       if (symbol_lastP) {
  149. !     DL_APPEND(symbolP, symbol_lastP);
  150.       } else {
  151.       symbol_rootP = symbolP;
  152.       }
  153. *** write.c    Mon Oct 22 22:35:15 1990
  154. --- /spare/usenet/port/gas-1.36/write.c    Mon Oct 22 22:38:18 1990
  155. ***************
  156. *** 405,416 ****
  157.                 /* The symbols will never be the last or the first
  158.                because : 1st symbol is .file and 3 last symbols are
  159.                .text, .data, .bss */
  160. !               real_symbolP->sy_previous->sy_next = real_symbolP->sy_next;
  161. !               real_symbolP->sy_next->sy_previous = real_symbolP->sy_previous;
  162. !               symbolP->sy_previous->sy_next = real_symbolP;
  163. !               symbolP->sy_next->sy_previous = real_symbolP;
  164. !               real_symbolP->sy_next = symbolP->sy_next;
  165. !               real_symbolP->sy_previous = symbolP->sy_previous;
  166.                 symbolP = real_symbolP;
  167.             }
  168.             if(flagseen['R'] && S_IS_DATA(symbolP))
  169. --- 405,413 ----
  170.                 /* The symbols will never be the last or the first
  171.                because : 1st symbol is .file and 3 last symbols are
  172.                .text, .data, .bss */
  173. !               DL_REMOVE(real_symbolP);
  174. !               DL_INSERT(real_symbolP, symbolP);
  175. !               DL_REMOVE(symbolP);
  176.                 symbolP = real_symbolP;
  177.             }
  178.             if(flagseen['R'] && S_IS_DATA(symbolP))
  179. ***************
  180. *** 488,510 ****
  181.   
  182.             symbolP = thisP->sy_next;
  183.             /* remove C_EFCN and LOCAL (L...) symbols */
  184. !           if(SF_GET_LOCAL(thisP)) {
  185. !               thisP->sy_next->sy_previous = thisP->sy_previous;
  186. !               thisP->sy_previous->sy_next = thisP->sy_next;
  187. !           } else {
  188.                 if(S_GET_STORAGE_CLASS(thisP) == C_EXT &&
  189.                !SF_GET_FUNCTION(thisP)) {
  190.                 /* Remove from the list */
  191. !               thisP->sy_next->sy_previous = thisP->sy_previous;
  192. !               thisP->sy_previous->sy_next = thisP->sy_next;
  193.                 /* Move at the end of the list */
  194. !               if (symbol_extern_lastP) {
  195. !                   symbol_extern_lastP->sy_next = thisP;
  196. !                   thisP->sy_previous = symbol_extern_lastP;
  197. !               } else {
  198.                     symbol_externP = thisP;
  199. !               }
  200. !               thisP->sy_next = (symbolS*)0;
  201.                 symbol_extern_lastP = thisP;
  202.                 } else {
  203.                 if(SF_GET_STRING(thisP)) {
  204. --- 485,503 ----
  205.   
  206.             symbolP = thisP->sy_next;
  207.             /* remove C_EFCN and LOCAL (L...) symbols */
  208. !           if(SF_GET_LOCAL(thisP))
  209. !               DL_REMOVE(thisP);
  210. !           else {
  211.                 if(S_GET_STORAGE_CLASS(thisP) == C_EXT &&
  212.                !SF_GET_FUNCTION(thisP)) {
  213.                 /* Remove from the list */
  214. !               DL_REMOVE(thisP);
  215. !               DL_CLEAR(thisP);
  216.                 /* Move at the end of the list */
  217. !               if (symbol_extern_lastP == (symbolS*)0)
  218.                     symbol_externP = thisP;
  219. !               else
  220. !                   DL_APPEND(thisP, symbol_extern_lastP);
  221.                 symbol_extern_lastP = thisP;
  222.                 } else {
  223.                 if(SF_GET_STRING(thisP)) {
  224. --
  225. Loic Dachary     loic@adesign.uucp or loic@afp.uucp 
  226. Voice        +33 1 40 35 20 20
  227.