gas-2.16-tigcc-patch.diff 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731
  1. diff -Naur binutils-2.16.1.orig/bfd/config.bfd binutils-2.16.1-src/bfd/config.bfd
  2. --- binutils-2.16.1.orig/bfd/config.bfd 2005-01-31 18:18:46.000000000 +0100
  3. +++ binutils-2.16.1-src/bfd/config.bfd 2005-07-01 00:40:16.000000000 +0200
  4. @@ -708,7 +708,6 @@
  5. ;;
  6. m68*-*-coff* | m68*-*-sysv*)
  7. targ_defvec=m68kcoff_vec
  8. - targ_selvecs="m68kcoff_vec versados_vec ieee_vec"
  9. ;;
  10. m68*-*-hpux*)
  11. targ_defvec=hp300hpux_vec
  12. diff -Naur binutils-2.16.1.orig/bfd/opncls.c binutils-2.16.1-src/bfd/opncls.c
  13. --- binutils-2.16.1.orig/bfd/opncls.c 2005-03-07 11:32:38.000000000 +0100
  14. +++ binutils-2.16.1-src/bfd/opncls.c 2007-10-02 16:12:11.000000000 +0200
  15. @@ -483,7 +483,7 @@
  16. nbfd->filename = filename;
  17. nbfd->direction = read_direction;
  18. - stream = open (nbfd, open_closure);
  19. + stream = (open) (nbfd, open_closure);
  20. if (stream == NULL)
  21. {
  22. _bfd_delete_bfd (nbfd);
  23. diff -Naur binutils-2.16.1.orig/gas/as.c binutils-2.16.1-src/gas/as.c
  24. --- binutils-2.16.1.orig/gas/as.c 2005-03-03 02:29:52.000000000 +0100
  25. +++ binutils-2.16.1-src/gas/as.c 2007-02-18 22:05:31.000000000 +0100
  26. @@ -251,6 +251,14 @@
  27. s include symbols\n\
  28. =FILE list to FILE (must be last sub-option)\n"));
  29. +/* (TIGCC 20050732) */
  30. + fprintf (stream, _("\
  31. + --a68k assemble in A68k compatibility mode\n"));
  32. +
  33. +/* (TIGCC 20030716) */
  34. + fprintf (stream, _("\
  35. + --all-relocs output all relocs, implies --keep-locals (-L)\n"));
  36. +
  37. fprintf (stream, _("\
  38. --alternate initially turn on alternate macro syntax\n"));
  39. fprintf (stream, _("\
  40. @@ -426,7 +434,10 @@
  41. OPTION_EXECSTACK,
  42. OPTION_NOEXECSTACK,
  43. OPTION_ALTERNATE,
  44. - OPTION_WARN_FATAL
  45. + OPTION_AL,
  46. + OPTION_WARN_FATAL,
  47. + OPTION_ALL_RELOCS, /* (TIGCC 20030716) */
  48. + OPTION_A68K /* (TIGCC 20050731) */
  49. /* When you add options here, check that they do
  50. not collide with OPTION_MD_BASE. See as.h. */
  51. };
  52. @@ -442,6 +453,12 @@
  53. necessary because -a=<FILE> is a valid switch but getopt would
  54. normally reject it since --alternate does not take an argument. */
  55. ,{"a", optional_argument, NULL, 'a'}
  56. + /* Handle -al=<FILE>. */
  57. + ,{"al", optional_argument, NULL, OPTION_AL}
  58. +/* (TIGCC 20050731) */
  59. + ,{"a68k", no_argument, NULL, OPTION_A68K}
  60. +/* (TIGCC 20030716) */
  61. + ,{"all-relocs", no_argument, NULL, OPTION_ALL_RELOCS}
  62. ,{"defsym", required_argument, NULL, OPTION_DEFSYM}
  63. ,{"dump-config", no_argument, NULL, OPTION_DUMPCONFIG}
  64. ,{"emulation", required_argument, NULL, OPTION_EMULATION}
  65. @@ -735,6 +752,9 @@
  66. listing_lhs_cont_lines = atoi (optarg);
  67. break;
  68. + case OPTION_A68K: /* (TIGCC 20050731) */
  69. + flag_a68k = 1;
  70. + /* fall through */
  71. case 'M':
  72. flag_mri = 1;
  73. #ifdef TC_M68K
  74. @@ -775,6 +795,12 @@
  75. flag_always_generate_output = 1;
  76. break;
  77. + case OPTION_AL:
  78. + listing |= LISTING_LISTING;
  79. + if (optarg)
  80. + listing_filename = xstrdup (optarg);
  81. + break;
  82. +
  83. case OPTION_ALTERNATE:
  84. optarg = old_argv [optind - 1];
  85. while (* optarg == '-')
  86. @@ -865,6 +891,12 @@
  87. case 'X':
  88. /* -X means treat warnings as errors. */
  89. break;
  90. +
  91. + /* (TIGCC 20030716) */
  92. + case OPTION_ALL_RELOCS:
  93. + flag_all_relocs = 1;
  94. + flag_keep_locals = 1; /* implies -L */
  95. + break;
  96. }
  97. }
  98. diff -Naur binutils-2.16.1.orig/gas/as.h binutils-2.16.1-src/gas/as.h
  99. --- binutils-2.16.1.orig/gas/as.h 2005-04-13 20:58:40.000000000 +0200
  100. +++ binutils-2.16.1-src/gas/as.h 2005-07-31 19:40:04.000000000 +0200
  101. @@ -244,16 +244,22 @@
  102. #ifdef MANY_SEGMENTS
  103. #include "bfd.h"
  104. -#define N_SEGMENTS 40
  105. -#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E39)
  106. -#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9,\
  107. - SEG_E10,SEG_E11,SEG_E12,SEG_E13,SEG_E14,SEG_E15,SEG_E16,SEG_E17,SEG_E18,SEG_E19,\
  108. - SEG_E20,SEG_E21,SEG_E22,SEG_E23,SEG_E24,SEG_E25,SEG_E26,SEG_E27,SEG_E28,SEG_E29,\
  109. - SEG_E30,SEG_E31,SEG_E32,SEG_E33,SEG_E34,SEG_E35,SEG_E36,SEG_E37,SEG_E38,SEG_E39
  110. +/* (TIGCC 20040625) 40 sections are definitely not enough for
  111. + -ffunction-sections, -fdata-sections and the like.
  112. + So I increased them to 120. -- Kevin Kofler
  113. + (TIGCC 20040905) And again to 1024. -- Kevin Kofler */
  114. +#define N_SEGMENTS 1024
  115. +#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_LAST)
  116. +#define LIST_10_(decade) decade##0,decade##1,decade##2,decade##3,decade##4,decade##5,decade##6,decade##7,decade##8,decade##9
  117. +#define LIST_FIRST_100_(century) LIST_10_(century),LIST_10_(century##1),LIST_10_(century##2),LIST_10_(century##3),LIST_10_(century##4),LIST_10_(century##5),LIST_10_(century##6),LIST_10_(century##7),LIST_10_(century##8),LIST_10_(century##9)
  118. +#define LIST_100_(century) LIST_10_(century##0),LIST_10_(century##1),LIST_10_(century##2),LIST_10_(century##3),LIST_10_(century##4),LIST_10_(century##5),LIST_10_(century##6),LIST_10_(century##7),LIST_10_(century##8),LIST_10_(century##9)
  119. +#define LIST_FIRST_1000_(millennium) LIST_FIRST_100_(millennium),LIST_100_(millennium##1),LIST_100_(millennium##2),LIST_100_(millennium##3),LIST_100_(millennium##4),LIST_100_(millennium##5),LIST_100_(millennium##6),LIST_100_(millennium##7),LIST_100_(millennium##8),LIST_100_(millennium##9)
  120. +#define SEG_LIST LIST_FIRST_1000_(SEG_E),LIST_10_(SEG_E100),LIST_10_(SEG_E101),\
  121. + SEG_E1020,SEG_E1021,SEG_E1022,SEG_E1023
  122. #define SEG_TEXT SEG_E0
  123. #define SEG_DATA SEG_E1
  124. #define SEG_BSS SEG_E2
  125. -#define SEG_LAST SEG_E39
  126. +#define SEG_LAST SEG_E1023
  127. #else
  128. #define N_SEGMENTS 3
  129. #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
  130. @@ -294,8 +300,13 @@
  131. #ifdef BFD_ASSEMBLER
  132. #define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
  133. #else
  134. +/* (TIGCC 20040905) Allow arbitrary number of sections here. -- Kevin Kofler */
  135. +#if 0
  136. extern char const *const seg_name[];
  137. -#define segment_name(SEG) seg_name[(int) (SEG)]
  138. +#define segment_name(SEG) seg_name[(int) (SEG)]*/
  139. +#else
  140. +char *segment_name PARAMS ((int));
  141. +#endif
  142. #endif
  143. #ifndef BFD_ASSEMBLER
  144. @@ -481,6 +492,12 @@
  145. extern enum debug_info_type debug_type;
  146. extern int use_gnu_debug_info_extensions;
  147. +
  148. +/* (TIGCC 20030716) True if all relocs should be retained. */
  149. +COMMON unsigned char flag_all_relocs; /* --all-relocs */
  150. +
  151. +/* (TIGCC 20050731) True if assembling in A68k compatibility mode. */
  152. +COMMON unsigned char flag_a68k; /* --a68k */
  153. /* Maximum level of macro nesting. */
  154. extern int max_macro_nest;
  155. diff -Naur binutils-2.16.1.orig/gas/config/obj-coff.c binutils-2.16.1-src/gas/config/obj-coff.c
  156. --- binutils-2.16.1.orig/gas/config/obj-coff.c 2005-03-01 12:24:30.000000000 +0100
  157. +++ binutils-2.16.1-src/gas/config/obj-coff.c 2006-11-18 19:31:57.000000000 +0100
  158. @@ -25,6 +25,7 @@
  159. #include "as.h"
  160. #include "obstack.h"
  161. #include "subsegs.h"
  162. +#include "dwarf2dbg.h"
  163. #ifdef TE_PE
  164. #include "coff/pe.h"
  165. @@ -1695,7 +1696,7 @@
  166. section alignment, then skip this step, as TICOFF does. */
  167. size = bfd_get_section_size (sec);
  168. mask = ((bfd_vma) 1 << align_power) - 1;
  169. -#if !defined(TICOFF)
  170. +#if 0 /*!defined(TICOFF)*/
  171. if (size & mask)
  172. {
  173. bfd_vma new_size;
  174. @@ -1834,14 +1835,20 @@
  175. /* This vector is used to turn a gas internal segment number into a
  176. section number suitable for insertion into a coff symbol table.
  177. This must correspond to seg_info_off_by_4. */
  178. +/* (TIGCC 20040625) 40 sections are definitely not enough for
  179. + -ffunction-sections, -fdata-sections and the like.
  180. + So I increased them to 120. -- Kevin Kofler */
  181. const short seg_N_TYPE[] =
  182. { /* in: segT out: N_TYPE bits */
  183. +/* (TIGCC 20040905) Allow arbitrary number of sections here. -- Kevin Kofler */
  184. +#if 0
  185. C_ABS_SECTION,
  186. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  187. 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  188. 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
  189. 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  190. +#endif /*0*/
  191. C_UNDEF_SECTION, /* SEG_UNKNOWN */
  192. C_UNDEF_SECTION, /* SEG_GOOF */
  193. C_UNDEF_SECTION, /* SEG_EXPR */
  194. @@ -1851,6 +1858,13 @@
  195. C_REGISTER_SECTION, /* SEG_REGISTER */
  196. };
  197. +short SEGMENT_TO_SYMBOL_TYPE (n) int n;
  198. +{
  199. + if (!n) return C_ABS_SECTION;
  200. + else if (SEG_NORMAL(n)) return n-SEG_E0+1;
  201. + else return seg_N_TYPE[n-(N_SEGMENTS+1)];
  202. +}
  203. +
  204. int function_lineoff = -1; /* Offset in line#s where the last function
  205. started (the odd entry for line #0) */
  206. @@ -1918,6 +1932,8 @@
  207. SEG_DEBUG,
  208. SEG_ABSOLUTE,
  209. SEG_UNKNOWN,
  210. +/* (TIGCC 20040905) Allow arbitrary number of sections here. -- Kevin Kofler */
  211. +#if 0
  212. SEG_E0, SEG_E1, SEG_E2, SEG_E3, SEG_E4,
  213. SEG_E5, SEG_E6, SEG_E7, SEG_E8, SEG_E9,
  214. SEG_E10, SEG_E11, SEG_E12, SEG_E13, SEG_E14,
  215. @@ -1936,9 +1952,19 @@
  216. (segT) 0,
  217. (segT) 0,
  218. SEG_REGISTER
  219. +#endif /*0*/
  220. };
  221. -#define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4])
  222. +static segT SEG_INFO_FROM_SECTION_NUMBER PARAMS ((int));
  223. +
  224. +static segT SEG_INFO_FROM_SECTION_NUMBER (n) int n;
  225. +{
  226. + if (n<=0) return seg_info_off_by_4[n+4];
  227. + else if (n<=N_SEGMENTS) return n-1+SEG_E0;
  228. + else if (n<=N_SEGMENTS+6) return n-1;
  229. + else if (n==C_REGISTER_SECTION) return SEG_REGISTER;
  230. + else return 0;
  231. +}
  232. static relax_addressT relax_align PARAMS ((relax_addressT, long));
  233. @@ -2010,6 +2036,12 @@
  234. size += off;
  235. }
  236. break;
  237. + case rs_cfa:
  238. + size += frag->fr_fix + eh_frame_estimate_size_before_relax (frag);
  239. + break;
  240. + case rs_dwarf2dbg:
  241. + size += frag->fr_fix + dwarf2dbg_estimate_size_before_relax (frag);
  242. + break;
  243. default:
  244. BAD_CASE (frag->fr_type);
  245. break;
  246. @@ -2159,8 +2191,11 @@
  247. S_GET_NAME (symbol_ptr));
  248. }
  249. +/* (TIGCC 20030715) Don't convert references to references to the section symbol.
  250. + (TIGCC 20030805) ... except for local symbols!
  251. + -- Kevin Kofler */
  252. dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot;
  253. - if (dot)
  254. + if (dot && S_IS_LOCAL(symbol_ptr))
  255. intr.r_symndx = dot->sy_number;
  256. else
  257. intr.r_symndx = symbol_ptr->sy_number;
  258. @@ -2309,6 +2344,16 @@
  259. }
  260. break;
  261. +
  262. + case rs_cfa:
  263. + eh_frame_convert_frag (frag);
  264. + goto have_converted_rs_fill;
  265. +
  266. + case rs_dwarf2dbg:
  267. + dwarf2dbg_convert_frag (frag);
  268. + /* fall through */
  269. +
  270. + have_converted_rs_fill:
  271. case rs_space:
  272. case rs_fill:
  273. case rs_align:
  274. @@ -3218,6 +3263,11 @@
  275. tc_frob_coff_symbol (symbolP);
  276. #endif
  277. + /* (TIGCC 20040725) Clear the SF_LOCAL flag if the symbol is in a
  278. + mergeable section. -- Kevin Kofler */
  279. + if (segment_info[S_GET_SEGMENT (symbolP)].scnhdr.s_flags & STYP_MERGEABLE)
  280. + SF_CLEAR_LOCAL (symbolP);
  281. +
  282. /* We must put the external symbols apart. The loader
  283. does not bomb if we do not. But the references in
  284. the endndx field for a .bb symbol are not corrected
  285. @@ -3559,7 +3609,7 @@
  286. (!(FRCHAIN)->frch_next || (FRCHAIN)->frch_next->frch_seg != (SEG) \
  287. ? get_recorded_alignment (SEG) : 0)
  288. #else
  289. -#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 1
  290. +#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0 /*1*/
  291. #endif
  292. #endif
  293. @@ -3767,7 +3817,9 @@
  294. {
  295. unsigned int i;
  296. -#ifndef COFF_LONG_SECTION_NAMES
  297. +/* (TIGCC 20040625) Use the full name, not the truncated name, for merging of
  298. + identically-named sections. -- Kevin Kofler */
  299. +#if 0 /*ndef COFF_LONG_SECTION_NAMES*/
  300. char buf[SCNNMLEN + 1];
  301. strncpy (buf, name, SCNNMLEN);
  302. @@ -3870,6 +3922,9 @@
  303. case 'w': flags |= STYP_DATA; break;
  304. case 'x': flags |= STYP_TEXT; break;
  305. case 'r': flags |= STYP_LIT; break;
  306. +/* (TIGCC 20040724) TIGCC COFF extensions for section flags -- Kevin Kofler */
  307. + case 'm': flags |= STYP_MERGEABLE; break;
  308. + case 'u': flags |= STYP_UNALIGNED; break;
  309. default:
  310. as_warn(_("unknown section attribute '%c'"),
  311. *input_line_pointer);
  312. @@ -4029,6 +4084,13 @@
  313. symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
  314. symbol_insert (symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
  315. }
  316. +
  317. + /* (TIGCC 20030717) In all-relocs mode, add an __ld_all_relocs symbol pointing
  318. + to a dummy label in the text section. -- Kevin Kofler */
  319. + if (flag_all_relocs) {
  320. + symbolP = symbol_new("__ld_all_relocs", SEG_TEXT, 0, &zero_address_frag);
  321. + S_SET_EXTERNAL(symbolP); /* make it an xdef */
  322. + }
  323. }
  324. /* Build a 'section static' symbol. */
  325. @@ -4344,10 +4406,13 @@
  326. #endif /* TC_I960 */
  327. add_number += S_GET_VALUE (add_symbolP) -
  328. S_GET_VALUE (sub_symbolP);
  329. - add_symbolP = NULL;
  330. if (!TC_FORCE_RELOCATION (fixP))
  331. {
  332. + /* (TIGCC 20030717) Zero out add_symbolP only if !TC_FORCE_RELOCATION.
  333. + -- Kevin Kofler */
  334. + add_symbolP = NULL;
  335. +
  336. fixP->fx_addsy = NULL;
  337. fixP->fx_subsy = NULL;
  338. fixP->fx_done = 1;
  339. @@ -4368,6 +4433,8 @@
  340. #ifdef DIFF_EXPR_OK
  341. else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type)
  342. {
  343. +/* (TIGCC 20030716) Take TC_FORCE_RELOCATION_SUB_LOCAL into account. -- Kevin Kofler */
  344. + if (!TC_FORCE_RELOCATION_SUB_LOCAL (fixP)) {
  345. /* Make it pc-relative. */
  346. add_number += (md_pcrel_from (fixP)
  347. - S_GET_VALUE (sub_symbolP));
  348. @@ -4375,15 +4442,19 @@
  349. fixP->fx_pcrel = 1;
  350. sub_symbolP = 0;
  351. fixP->fx_subsy = 0;
  352. + }
  353. }
  354. #endif
  355. else
  356. {
  357. +/* (TIGCC 20030716) Take UNDEFINED_DIFFERENCE_OK into account. -- Kevin Kofler */
  358. +#ifndef UNDEFINED_DIFFERENCE_OK
  359. as_bad_where (fixP->fx_file, fixP->fx_line,
  360. _("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %ld."),
  361. segment_name (S_GET_SEGMENT (sub_symbolP)),
  362. S_GET_NAME (sub_symbolP),
  363. (long) (fragP->fr_address + where));
  364. +#endif
  365. }
  366. }
  367. }
  368. @@ -4522,7 +4593,13 @@
  369. md_apply_fix3 (fixP, (valueT *) & add_number, this_segment_type);
  370. - if (!fixP->fx_bit_fixP && ! fixP->fx_no_overflow)
  371. +/* (TIGCC 20030716) Reuse fx_im_disp to turn off range checking on the 68k.
  372. + -- Kevin Kofler */
  373. + if (!fixP->fx_bit_fixP && ! fixP->fx_no_overflow
  374. +#ifdef TC_M68K
  375. + && !fixP->fx_im_disp
  376. +#endif
  377. + )
  378. {
  379. #ifndef TC_M88K
  380. /* The m88k uses the offset field of the reloc to get around
  381. diff -Naur binutils-2.16.1.orig/gas/config/obj-coff.h binutils-2.16.1-src/gas/config/obj-coff.h
  382. --- binutils-2.16.1.orig/gas/config/obj-coff.h 2005-03-03 12:47:48.000000000 +0100
  383. +++ binutils-2.16.1-src/gas/config/obj-coff.h 2005-07-01 00:40:16.000000000 +0200
  384. @@ -487,7 +487,8 @@
  385. #define C_DEBUG_SECTION N_DEBUG
  386. #define C_NTV_SECTION N_TV
  387. #define C_PTV_SECTION P_TV
  388. -#define C_REGISTER_SECTION 50
  389. +/* (TIGCC 20040905) Don't hardcode number of sections here. -- Kevin Kofler */
  390. +#define C_REGISTER_SECTION (N_SEGMENTS+10)
  391. /* Macros to extract information from a symbol table entry.
  392. This syntactic indirection allows independence regarding a.out or coff.
  393. @@ -510,20 +511,31 @@
  394. /* Return true for symbols that should not be reduced to section
  395. symbols or eliminated from expressions, because they may be
  396. overridden by the linker. */
  397. +/* (TIGCC 20030716) Never reduce or eliminate relocs in all-relocs mode.
  398. + (TIGCC 20040719) Don't force relocs for absolute symbols if !flag_all_relocs.
  399. + (TIGCC 20040725) Force relocs for symbols in mergeable sections.
  400. + -- Kevin Kofler */
  401. #define S_FORCE_RELOC(s, strict) \
  402. - (!SEG_NORMAL (S_GET_SEGMENT (s)) || (strict && S_IS_WEAK (s)))
  403. + ((!SEG_NORMAL (S_GET_SEGMENT (s)) && S_GET_SEGMENT (s) != absolute_section) \
  404. + || (strict && S_IS_WEAK (s)) || flag_all_relocs \
  405. + || (segment_info[S_GET_SEGMENT (s)].scnhdr.s_flags & STYP_MERGEABLE))
  406. /* True if a debug special symbol entry. */
  407. #define S_IS_DEBUG(s) \
  408. ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
  409. /* True if a symbol is local symbol name. */
  410. -/* A symbol name whose name includes ^A is a gas internal pseudo symbol. */
  411. +/* A symbol name whose name includes ^A is a gas internal pseudo symbol.
  412. + (TIGCC 20030716) However, we want them output when outputting local symbols.
  413. + (TIGCC 20040724) Also, we always want to output local symbols in mergeable
  414. + sections, because our linker relies on that.
  415. + -- Kevin Kofler */
  416. #define S_IS_LOCAL(s) \
  417. ((s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION \
  418. - || (S_LOCAL_NAME(s) && ! flag_keep_locals && ! S_IS_DEBUG (s)) \
  419. - || strchr (S_GET_NAME (s), '\001') != NULL \
  420. - || strchr (S_GET_NAME (s), '\002') != NULL \
  421. + || (S_LOCAL_NAME(s) && ! flag_keep_locals && ! S_IS_DEBUG (s) \
  422. + && !(segment_info[S_GET_SEGMENT (s)].scnhdr.s_flags & STYP_MERGEABLE)) \
  423. + || (strchr (S_GET_NAME (s), '\001') != NULL && ! flag_keep_locals) \
  424. + || (strchr (S_GET_NAME (s), '\002') != NULL && ! flag_keep_locals) \
  425. || (flag_strip_local_absolute \
  426. && !S_IS_EXTERNAL(s) \
  427. && (s)->sy_symbol.ost_entry.n_scnum == C_ABS_SECTION))
  428. diff -Naur binutils-2.16.1.orig/gas/config/tc-m68k.c binutils-2.16.1-src/gas/config/tc-m68k.c
  429. --- binutils-2.16.1.orig/gas/config/tc-m68k.c 2005-03-22 16:31:48.000000000 +0100
  430. +++ binutils-2.16.1-src/gas/config/tc-m68k.c 2006-11-18 18:09:33.000000000 +0100
  431. @@ -79,6 +79,7 @@
  432. int flag_want_pic;
  433. static int flag_short_refs; /* -l option. */
  434. +static int flag_short_jumps; /* --short-jumps option */
  435. static int flag_long_jumps; /* -S option. */
  436. static int flag_keep_pcrel; /* --pcrel option. */
  437. @@ -579,6 +580,10 @@
  438. {"extend", float_cons, 'x'},
  439. {"ldouble", float_cons, 'x'},
  440. + /* Dwarf2 support for Gcc. */
  441. + {"file", (void (*) PARAMS ((int))) dwarf2_directive_file, 0},
  442. + {"loc", dwarf2_directive_loc, 0},
  443. +
  444. /* The following pseudo-ops are supported for MRI compatibility. */
  445. {"chip", s_chip, 0},
  446. {"comline", s_space, 1},
  447. @@ -777,15 +782,24 @@
  448. short
  449. tc_coff_fix2rtype (fixS *fixP)
  450. {
  451. +/* (TIGCC 20040920) Handle unoptimizable relocs. -- Kevin Kofler */
  452. + short isunopt;
  453. + isunopt = (fixP->fx_unoptimizable) ? R_UNOPTIMIZABLE : 0;
  454. +
  455. if (fixP->fx_tcbit && fixP->fx_size == 4)
  456. - return R_RELLONG_NEG;
  457. + return isunopt | R_RELLONG_NEG;
  458. +/* (TIGCC 20030716) Handle word and byte negative relocs. -- Kevin Kofler */
  459. + if (fixP->fx_tcbit && fixP->fx_size == 2)
  460. + return isunopt | R_RELWORD_NEG;
  461. + if (fixP->fx_tcbit && fixP->fx_size == 1)
  462. + return isunopt | R_RELBYTE_NEG;
  463. #ifdef NO_PCREL_RELOCS
  464. know (fixP->fx_pcrel == 0);
  465. - return (fixP->fx_size == 1 ? R_RELBYTE
  466. + return isunopt | (fixP->fx_size == 1 ? R_RELBYTE
  467. : fixP->fx_size == 2 ? R_DIR16
  468. : R_DIR32);
  469. #else
  470. - return (fixP->fx_pcrel
  471. + return isunopt | (fixP->fx_pcrel
  472. ? (fixP->fx_size == 1 ? R_PCRBYTE
  473. : fixP->fx_size == 2 ? R_PCRWORD
  474. : R_PCRLONG)
  475. @@ -1089,6 +1103,7 @@
  476. char c;
  477. int losing;
  478. int opsfound;
  479. + struct m68k_op operands_backup[6];
  480. LITTLENUM_TYPE words[6];
  481. LITTLENUM_TYPE *wordp;
  482. unsigned long ok_arch = 0;
  483. @@ -1213,7 +1228,15 @@
  484. ++losing;
  485. else
  486. {
  487. - for (s = opcode->m_operands, opP = &the_ins.operands[0];
  488. + int i;
  489. +
  490. + /* Make a copy of the operands of this insn so that
  491. + we can modify them safely, should we want to. */
  492. + assert (opsfound <= (int) ARRAY_SIZE (operands_backup));
  493. + for (i = 0; i < opsfound; i++)
  494. + operands_backup[i] = the_ins.operands[i];
  495. +
  496. + for (s = opcode->m_operands, opP = &operands_backup[0];
  497. *s && !losing;
  498. s += 2, opP++)
  499. {
  500. @@ -1974,6 +1997,12 @@
  501. if (losing)
  502. break;
  503. }
  504. +
  505. + /* Since we have found the correct instruction, copy
  506. + in the modifications that we may have made. */
  507. + if (!losing)
  508. + for (i = 0; i < opsfound; i++)
  509. + the_ins.operands[i] = operands_backup[i];
  510. }
  511. if (!losing)
  512. @@ -2759,6 +2788,7 @@
  513. add_fix ('B', &opP->disp, 1, -1);
  514. break;
  515. case 'W':
  516. + word_branch: /* (TIGCC 20050130) */
  517. add_fix ('w', &opP->disp, 1, 0);
  518. addword (0);
  519. break;
  520. @@ -2771,6 +2801,20 @@
  521. addword (0);
  522. addword (0);
  523. break;
  524. + case 'G': /* (TIGCC 20050130) */
  525. + /* (TIGCC 20050130) We want only branches (word). -- Kevin Kofler */
  526. + if (subs (&opP->disp)) /* We can't relax it. */
  527. + goto word_branch;
  528. +
  529. +#ifdef OBJ_ELF
  530. + /* If the displacement needs pic relocation it cannot be
  531. + relaxed. */
  532. + if (opP->disp.pic_reloc != pic_none)
  533. + goto word_branch;
  534. +#endif
  535. + add_frag (adds (&opP->disp), offs (&opP->disp),
  536. + TAB (BRANCHBW, SZ_UNDEF));
  537. + break;
  538. case 'g':
  539. if (subs (&opP->disp)) /* We can't relax it. */
  540. goto long_branch;
  541. @@ -2793,8 +2837,15 @@
  542. the_ins.opcode[0] = 0x4EB9;
  543. else /* jCC */
  544. {
  545. + /* (TIGCC 20030902) Add a PC-relative reloc (unconditionally, because
  546. + it will be removed later on if not in all-relocs
  547. + mode). -- Kevin Kofler */
  548. + struct m68k_exp temp_expr = {SIZE_UNSPEC,
  549. + {symbol_new (FAKE_LABEL_NAME, now_seg, (valueT) frag_now_fix () + 8, frag_now),
  550. + NULL, 0, O_symbol, 0, 0}};
  551. the_ins.opcode[0] ^= 0x0100;
  552. the_ins.opcode[0] |= 0x0006;
  553. + add_fix ('B' /*case-sensitive!*/, &temp_expr, 1 /*PCREL*/, -1 /*PCREL fix for bytes*/);
  554. addword (0x4EF9);
  555. }
  556. add_fix ('l', &opP->disp, 0, 0);
  557. @@ -3955,7 +4006,7 @@
  558. current_label = NULL;
  559. }
  560. -#ifdef OBJ_ELF
  561. +#if 1 /*def OBJ_ELF*/
  562. /* Tie dwarf2 debug info to the address at the start of the insn. */
  563. dwarf2_emit_insn (0);
  564. #endif
  565. @@ -4008,6 +4059,13 @@
  566. fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix;
  567. if (the_ins.reloc[m].wid == 'B')
  568. fixP->fx_signed = 1;
  569. + /* (TIGCC 20050130) These relocs are by definition the ones which cannot
  570. + be "relaxed" - or "optimized" in ld-tigcc terms.
  571. + Excepted from this are byte branches because the
  572. + linker must be able to remove them entirely.
  573. + -- Kevin Kofler */
  574. + else
  575. + fixP->fx_unoptimizable = 1;
  576. }
  577. return;
  578. }
  579. @@ -4068,6 +4126,10 @@
  580. get_reloc_code (wid, the_ins.reloc[m].pcrel,
  581. the_ins.reloc[m].pic_reloc));
  582. fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix;
  583. + /* (TIGCC 20050130) These relocs are by definition the ones which cannot
  584. + be "relaxed" - or "optimized" in ld-tigcc terms.
  585. + -- Kevin Kofler */
  586. + fixP->fx_unoptimizable = 1;
  587. }
  588. (void) frag_var (rs_machine_dependent, 10, 0,
  589. (relax_substateT) (the_ins.fragb[n].fragty),
  590. @@ -4105,6 +4167,10 @@
  591. get_reloc_code (wid, the_ins.reloc[m].pcrel,
  592. the_ins.reloc[m].pic_reloc));
  593. fixP->fx_pcrel_adjust = the_ins.reloc[m].pcrel_fix;
  594. + /* (TIGCC 20050130) These relocs are by definition the ones which cannot
  595. + be "relaxed" - or "optimized" in ld-tigcc terms.
  596. + -- Kevin Kofler */
  597. + fixP->fx_unoptimizable = 1;
  598. }
  599. }
  600. @@ -4126,6 +4192,8 @@
  601. return ret;
  602. if (op1 < op2)
  603. return -1;
  604. + if (op1 > op2)
  605. + return 1; /* (TIGCC 200505611) This is required for Windows. -- Kevin Kofler */
  606. return 0;
  607. }
  608. @@ -4160,7 +4228,7 @@
  609. m68k_sorted_opcodes = xmalloc (m68k_numopcodes * sizeof (* m68k_sorted_opcodes));
  610. if (!m68k_sorted_opcodes)
  611. as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
  612. - m68k_numopcodes * sizeof (* m68k_sorted_opcodes));
  613. + m68k_numopcodes * ((int) sizeof (* m68k_sorted_opcodes)));
  614. for (i = m68k_numopcodes; i--;)
  615. m68k_sorted_opcodes[i] = m68k_opcodes + i;
  616. @@ -4619,7 +4687,9 @@
  617. val = SEXT (val);
  618. - if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
  619. +/* (TIGCC 20030716) We aren't done when we still have something to subtract.
  620. + -- Kevin Kofler */
  621. + if (fixP->fx_addsy == NULL && fixP->fx_subsy == NULL && fixP->fx_pcrel == 0)
  622. fixP->fx_done = 1;
  623. #ifdef OBJ_ELF
  624. @@ -4642,6 +4712,55 @@
  625. return;
  626. #endif
  627. + /* Fix up a negative reloc. */
  628. + if (fixP->fx_addsy == NULL && fixP->fx_subsy != NULL)
  629. + {
  630. + fixP->fx_addsy = fixP->fx_subsy;
  631. + fixP->fx_subsy = NULL;
  632. + fixP->fx_tcbit = 1;
  633. + val = -val; /* (TIGCC 20030716) */
  634. + }
  635. + /* (TIGCC 20030716) Fix up an address difference by splitting it into its
  636. + components.
  637. + Fix up subtraction of the dot symbol by changing the reloc
  638. + to PC-relative (disabled 20030717). -- Kevin Kofler
  639. + (TIGCC 20040807) For common symbols, the value is the size, not the
  640. + position, so don't use it. -- Kevin Kofler */
  641. + else if (fixP->fx_addsy != NULL && fixP->fx_subsy != NULL)
  642. + {
  643. +#if 0 /* (TIGCC 20030717) This is unnecessary (see expr.c fix) and probably wrong. */
  644. + if (!~fixP->fx_subsy->sy_number) { /* detect the dot symbol */
  645. + /* make the reloc PC-relative: */
  646. + val += md_pcrel_from (fixP);
  647. + fixP->fx_offset = *valP = val;
  648. + fixP->fx_pcrel = 1;
  649. + fixP->fx_subsy = NULL;
  650. + } else {
  651. +#endif
  652. + fixS *negreloc = fix_new (fixP->fx_frag, fixP->fx_where, fixP->fx_size,
  653. + fixP->fx_subsy, fixP->fx_offset
  654. + + (S_IS_COMMON (fixP->fx_addsy) ? 0 : S_GET_VALUE (fixP->fx_addsy))
  655. + + segment_info[S_GET_SEGMENT (fixP->fx_addsy)].scnhdr.s_paddr
  656. + - (((S_IS_COMMON (fixP->fx_subsy) ? 0 : S_GET_VALUE (fixP->fx_subsy))
  657. + + segment_info[S_GET_SEGMENT (fixP->fx_subsy)].scnhdr.s_paddr)
  658. + << 1) /* (TIGCC 20030717) Yes, we need to subtract this twice!
  659. + This kludge compensates for later incorrect
  660. + computations in obj-coff.c. -- Kevin Kofler */,
  661. + 0, 0);
  662. + if (negreloc) {
  663. + fixP->fx_offset = 0; /* We have transferred the offset to the negative reloc. */
  664. + fixP->fx_pcrel = 0;
  665. + fixP->fx_subsy = NULL;
  666. + negreloc->fx_tcbit = 1;
  667. + /* turn off range checking for both relocs: */
  668. + fixP->fx_im_disp = negreloc->fx_im_disp = 1;
  669. + }
  670. +#if 0
  671. + }
  672. +#endif
  673. + }
  674. +
  675. + /* (TIGCC 20030716) Moved this down so val can be adjusted. -- Kevin Kofler */
  676. switch (fixP->fx_size)
  677. {
  678. /* The cast to offsetT below are necessary to make code
  679. @@ -4669,13 +4788,8 @@
  680. BAD_CASE (fixP->fx_size);
  681. }
  682. - /* Fix up a negative reloc. */
  683. - if (fixP->fx_addsy == NULL && fixP->fx_subsy != NULL)
  684. - {
  685. - fixP->fx_addsy = fixP->fx_subsy;
  686. - fixP->fx_subsy = NULL;
  687. - fixP->fx_tcbit = 1;
  688. - }
  689. + /* (TIGCC 20030716) Reuse fx_im_disp to turn off range checking. -- Kevin Kofler */
  690. + if (fixP->fx_im_disp) return;
  691. /* For non-pc-relative values, it's conceivable we might get something
  692. like "0xff" for a byte field. So extend the upper part of the range
  693. @@ -4684,7 +4798,17 @@
  694. if (! fixP->fx_pcrel && ! fixP->fx_signed)
  695. upper_limit = upper_limit * 2 + 1;
  696. - if ((addressT) val > upper_limit
  697. + /* (TIGCC 20050507) We can't properly range-check PC-relative relocs in
  698. + all-relocs mode because of COFF VMA annoyances. Ideally, the section
  699. + contents should be just unrelocated offsets which can be properly
  700. + range-checked, but unfortunately COFF is designed with unrelocated use in
  701. + mind and relocation as an afterthought. And moreover, we need to
  702. + range-check in the linker anyway, as only the linker knows the final
  703. + section disposition. So let's just let the linker worry about
  704. + range-checking. */
  705. + if (fixP->fx_pcrel)
  706. + fixP->fx_im_disp = 1;
  707. + else if ((addressT) val > upper_limit
  708. && (val > 0 || val < lower_limit))
  709. as_bad_where (fixP->fx_file, fixP->fx_line, _("value out of range"));
  710. @@ -4795,6 +4919,27 @@
  711. fragP->fr_opcode[0] ^= 0x01; /* Invert bcc. */
  712. fragP->fr_opcode[1] = 0x06; /* Branch offset = 6. */
  713. + /* (TIGCC 20030902) Add a PC-relative reloc (unconditionally, because
  714. + it will be removed later on if not in all-relocs
  715. + mode). -- Kevin Kofler
  716. + (TIGCC 20030908) Unfortunately, we cannot create symbols here for some
  717. + reason, so we create the symbol in advance in
  718. + md_estimate_size_before_relax and store it into the
  719. + frag structure of the next frag. Here, we only have to
  720. + read it. -- Kevin Kofler, patch by Sebastian Reichelt
  721. + */
  722. + {
  723. + fragS *nextFragP = fragP->fr_next;
  724. + symbolS *symbolP = NULL;
  725. + if (nextFragP)
  726. + symbolP = nextFragP->fr_start_symbol;
  727. +
  728. + if (symbolP)
  729. + fix_new (fragP, fragP->fr_fix - 1, 1, symbolP, -1, 1, RELAX_RELOC_PC8);
  730. + else
  731. + as_warn_where (fragP->fr_file, fragP->fr_line, _("no symbol available for pseudo-op code"));
  732. + }
  733. +
  734. /* JF: these used to be fr_opcode[2,3], but they may be in a
  735. different frag, in which case referring to them is a no-no.
  736. Only fr_opcode[0,1] are guaranteed to work. */
  737. @@ -4963,8 +5108,17 @@
  738. && relaxable_symbol (fragP->fr_symbol))
  739. {
  740. fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE);
  741. + /* (TIGCC 20030909) Create a symbol at the beginning of the next frag
  742. + and store it into the frag structure, because
  743. + md_convert_frag_1 might need a symbol there, but
  744. + can't create it itself. This is necessary only for
  745. + conditional jumps. -- Kevin Kofler */
  746. + if ((TABTYPE (fragP->fr_subtype) == BRABSJCOND) && fragP->fr_next)
  747. + {
  748. + fragP->fr_next->fr_start_symbol = symbol_new (FAKE_LABEL_NAME, segment, fragP->fr_next->fr_address, fragP->fr_next);
  749. + }
  750. }
  751. - else if (flag_short_refs)
  752. + else if (flag_short_jumps)
  753. {
  754. /* Symbol is undefined and we want short ref. */
  755. fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
  756. @@ -4973,6 +5127,17 @@
  757. {
  758. /* Symbol is still undefined. Make it LONG. */
  759. fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), LONG);
  760. + /* (TIGCC 20030908) Create a symbol at the beginning of the next frag
  761. + and store it into the frag structure, because
  762. + md_convert_frag_1 might need a symbol there, but
  763. + can't create it itself.
  764. + -- Kevin Kofler, patch by Sebastian Reichelt
  765. + (TIGCC 20030909) This is necessary only for conditional jumps.
  766. + -- Kevin Kofler */
  767. + if ((TABTYPE (fragP->fr_subtype) == BRABSJCOND) && fragP->fr_next)
  768. + {
  769. + fragP->fr_next->fr_start_symbol = symbol_new (FAKE_LABEL_NAME, segment, fragP->fr_next->fr_address, fragP->fr_next);
  770. + }
  771. }
  772. break;
  773. }
  774. @@ -4999,7 +5164,7 @@
  775. {
  776. if ((S_GET_SEGMENT (fragP->fr_symbol) == segment
  777. && relaxable_symbol (fragP->fr_symbol))
  778. - || flag_short_refs)
  779. + || flag_short_jumps)
  780. {
  781. fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
  782. }
  783. @@ -5025,7 +5190,8 @@
  784. case TAB (ABSTOPCREL, SZ_UNDEF):
  785. {
  786. if ((S_GET_SEGMENT (fragP->fr_symbol) == segment
  787. - && relaxable_symbol (fragP->fr_symbol)))
  788. + && relaxable_symbol (fragP->fr_symbol))
  789. + || flag_short_refs)
  790. {
  791. fragP->fr_subtype = TAB (ABSTOPCREL, SHORT);
  792. }
  793. @@ -5069,6 +5235,7 @@
  794. }
  795. }
  796. break;
  797. +
  798. default:
  799. break;
  800. }
  801. @@ -5292,7 +5459,7 @@
  802. subs (exp) = 0;
  803. offs (exp) = (ok == 10) ? 1 : 0;
  804. as_warn (_("Can't deal with expression; defaulting to %ld"),
  805. - offs (exp));
  806. + (long) offs (exp));
  807. }
  808. }
  809. else
  810. @@ -5304,7 +5471,7 @@
  811. subs (exp) = 0;
  812. offs (exp) = (ok == 10) ? 1 : 0;
  813. as_warn (_("Can't deal with expression; defaulting to %ld"),
  814. - offs (exp));
  815. + (long) offs (exp));
  816. }
  817. }
  818. @@ -7067,6 +7234,8 @@
  819. {"disp-size-default-32", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_32},
  820. #define OPTION_PCREL (OPTION_MD_BASE + 7)
  821. {"pcrel", no_argument, NULL, OPTION_PCREL},
  822. +#define OPTION_SHORT_JUMPS (OPTION_MD_BASE + 8)
  823. + {"short-jumps", no_argument, NULL, OPTION_SHORT_JUMPS},
  824. {NULL, no_argument, NULL, 0}
  825. };
  826. size_t md_longopts_size = sizeof (md_longopts);
  827. @@ -7079,6 +7248,12 @@
  828. case 'l': /* -l means keep external to 2 bit offset
  829. rather than 16 bit one. */
  830. flag_short_refs = 1;
  831. + flag_short_jumps = 1;
  832. + break;
  833. +
  834. + case OPTION_SHORT_JUMPS: /* --short-jumps is like -l only for
  835. + jumps. */
  836. + flag_short_jumps = 1;
  837. break;
  838. case 'S': /* -S means that jbsr's always turn into
  839. @@ -7255,6 +7430,7 @@
  840. fprintf (stream, _("\
  841. 680X0 options:\n\
  842. -l use 1 word for refs to undefined symbols [default 2]\n\
  843. +--short-jumps use 1 word for jumps to undefined symbols [default 2]\n\
  844. -m68000 | -m68008 | -m68010 | -m68020 | -m68030 | -m68040 | -m68060 |\n\
  845. -m68302 | -m68331 | -m68332 | -m68333 | -m68340 | -m68360 | -mcpu32 |\n\
  846. -m5200 | -m5202 | -m5204 | -m5206 | -m5206e | -m521x | -m5249 |\n\
  847. diff -Naur binutils-2.16.1.orig/gas/config/tc-m68k.h binutils-2.16.1-src/gas/config/tc-m68k.h
  848. --- binutils-2.16.1.orig/gas/config/tc-m68k.h 2005-03-01 23:35:20.000000000 +0100
  849. +++ binutils-2.16.1-src/gas/config/tc-m68k.h 2005-07-01 00:40:16.000000000 +0200
  850. @@ -234,3 +234,20 @@
  851. #define tc_cfi_frame_initial_instructions tc_m68k_frame_initial_instructions
  852. extern void tc_m68k_frame_initial_instructions (void);
  853. +
  854. +/* (TIGCC 20030716) Allow difference of undefined symbols. -- Kevin Kofler */
  855. +#define UNDEFINED_DIFFERENCE_OK
  856. +
  857. +/* (TIGCC 20030716) Force relocs in all-relocs mode. -- Kevin Kofler */
  858. +#define TC_FORCE_RELOCATION(FIX) \
  859. + (generic_force_reloc (FIX))
  860. +#define TC_FORCE_RELOCATION_ABS(FIX) \
  861. + (0)
  862. +#define TC_FORCE_RELOCATION_LOCAL(FIX) \
  863. + (TC_FORCE_RELOCATION (FIX))
  864. +#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
  865. + (! SEG_NORMAL (SEG) || TC_FORCE_RELOCATION (FIX))
  866. +#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX) \
  867. + (TC_FORCE_RELOCATION (FIX))
  868. +/* (END TIGCC 20030716) */
  869. +
  870. diff -Naur binutils-2.16.1.orig/gas/configure binutils-2.16.1-src/gas/configure
  871. --- binutils-2.16.1.orig/gas/configure 2005-03-01 01:43:50.000000000 +0100
  872. +++ binutils-2.16.1-src/gas/configure 2005-07-01 00:40:16.000000000 +0200
  873. @@ -10839,7 +10839,7 @@
  874. - ac_config_files="$ac_config_files Makefile doc/Makefile po/Makefile.in:po/Make-in"
  875. + ac_config_files="$ac_config_files Makefile"
  876. ac_config_commands="$ac_config_commands default"
  877. diff -Naur binutils-2.16.1.orig/gas/dwarf2dbg.c binutils-2.16.1-src/gas/dwarf2dbg.c
  878. --- binutils-2.16.1.orig/gas/dwarf2dbg.c 2005-03-03 02:29:52.000000000 +0100
  879. +++ binutils-2.16.1-src/gas/dwarf2dbg.c 2005-07-01 00:40:16.000000000 +0200
  880. @@ -53,7 +53,15 @@
  881. # define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8)
  882. #endif
  883. -#ifdef BFD_ASSEMBLER
  884. +#ifndef BFD_ASSEMBLER
  885. +# define section_symbol(SEC) seg_info(SEC)->dwarf2_secsym
  886. +#endif
  887. +
  888. +#ifdef __MINGW32__
  889. +# define ffs __builtin_ffs
  890. +#endif
  891. +
  892. +#if 1 /*def BFD_ASSEMBLER*/
  893. #include "subsegs.h"
  894. @@ -331,6 +339,13 @@
  895. dwarf2_gen_line_info (frag_now_fix () - size, &loc);
  896. }
  897. +void
  898. +dwarf2_emit_insn_if_loc_seen (int size)
  899. +{
  900. + if (loc_directive_seen)
  901. + dwarf2_emit_insn (size);
  902. +}
  903. +
  904. /* Get a .debug_line file number for FILENAME. If NUM is nonzero,
  905. allocate it on that file table slot, otherwise return the first
  906. empty one. */
  907. @@ -962,7 +977,9 @@
  908. if (1 /* line != e->loc.line || changed */)
  909. {
  910. int line_delta = e->loc.line - line;
  911. - if (frag == NULL)
  912. + /* (TIGCC 20050415) Always use DW_LNE_set_address, as everything else is
  913. + incompatible with linker optimization. -- Kevin Kofler */
  914. + if (1 /*frag == NULL*/)
  915. {
  916. out_set_addr (seg, e->frag, e->frag_ofs);
  917. out_inc_line_addr (line_delta, 0);
  918. @@ -992,11 +1009,16 @@
  919. /* Emit a DW_LNE_end_sequence for the end of the section. */
  920. last_frag = last_frag_for_seg (seg);
  921. last_frag_ofs = get_frag_fix (last_frag);
  922. +#if 0 /* (TIGCC 20050419) */
  923. if (frag == last_frag)
  924. out_inc_line_addr (INT_MAX, last_frag_ofs - frag_ofs);
  925. else
  926. relax_inc_line_addr (INT_MAX, seg, last_frag, last_frag_ofs,
  927. frag, frag_ofs);
  928. +#else
  929. + out_set_addr (seg, last_frag, last_frag_ofs);
  930. + out_inc_line_addr (INT_MAX, 0);
  931. +#endif
  932. }
  933. /* Emit the directory and file tables for .debug_line. */
  934. @@ -1057,6 +1079,7 @@
  935. subseg_set (line_seg, 0);
  936. line_start = symbol_temp_new_now ();
  937. + seg_info (line_seg)->dwarf2_secsym = line_start; /* (TIGCC 20050407) */
  938. prologue_end = symbol_temp_make ();
  939. line_end = symbol_temp_make ();
  940. @@ -1212,15 +1235,19 @@
  941. {
  942. subseg_set (abbrev_seg, 0);
  943. + seg_info (abbrev_seg)->dwarf2_secsym = symbol_temp_new_now (); /* (TIGCC 20050407) */
  944. +
  945. out_uleb128 (1);
  946. out_uleb128 (DW_TAG_compile_unit);
  947. out_byte (DW_CHILDREN_no);
  948. out_abbrev (DW_AT_stmt_list, DW_FORM_data4);
  949. +#if 0 /* (TIGCC 20050407) */
  950. if (all_segs->next == NULL)
  951. {
  952. out_abbrev (DW_AT_low_pc, DW_FORM_addr);
  953. out_abbrev (DW_AT_high_pc, DW_FORM_addr);
  954. }
  955. +#endif
  956. out_abbrev (DW_AT_name, DW_FORM_string);
  957. out_abbrev (DW_AT_comp_dir, DW_FORM_string);
  958. out_abbrev (DW_AT_producer, DW_FORM_string);
  959. @@ -1249,6 +1276,7 @@
  960. subseg_set (info_seg, 0);
  961. info_start = symbol_temp_new_now ();
  962. + seg_info (info_seg)->dwarf2_secsym = info_start; /* (TIGCC 20050407) */
  963. info_end = symbol_temp_make ();
  964. /* Compilation Unit length. */
  965. @@ -1297,6 +1325,7 @@
  966. /* ??? sizeof_offset */
  967. TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg), 4);
  968. +#if 0 /* (TIGCC 20050407) */
  969. /* These two attributes may only be emitted if all of the code is
  970. contiguous. Multiple sections are not that. */
  971. if (all_segs->next == NULL)
  972. @@ -1313,6 +1342,7 @@
  973. expr.X_add_number = 0;
  974. emit_expr (&expr, sizeof_address);
  975. }
  976. +#endif
  977. /* DW_AT_name. We don't have the actual file name that was present
  978. on the command line, so assume files[1] is the main input file.
  979. @@ -1366,8 +1396,37 @@
  980. segT info_seg;
  981. int emit_other_sections = 0;
  982. +#ifdef BFD_ASSEMBLER
  983. info_seg = bfd_get_section_by_name (stdoutput, ".debug_info");
  984. emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg);
  985. +#else
  986. +/* (TIGCC 20050403) Yes, this is ugly, it is mostly copied out of subseg_new and
  987. + should be in its own function. -- Kevin Kofler */
  988. + int i;
  989. + info_seg = (segT)(-1);
  990. + for (i = 0; i < (int) SEG_MAXIMUM_ORDINAL; i++)
  991. + {
  992. + const char *s;
  993. +
  994. + s = segment_name ((segT) i);
  995. + if (strcmp (".debug_info", s) == 0
  996. + || (strcmp ("debug_info", s) == 0))
  997. + {
  998. + info_seg = (segT) i;
  999. + break;
  1000. + }
  1001. +#ifdef obj_segment_name
  1002. + s = obj_segment_name ((segT) i);
  1003. + if (strcmp (".debug_info", s) == 0
  1004. + || (strcmp ("debug_info", s) == 0))
  1005. + {
  1006. + info_seg = (segT) i;
  1007. + break;
  1008. + }
  1009. +#endif
  1010. + }
  1011. + emit_other_sections = info_seg == (segT)(-1) || !seg_not_empty_p (info_seg);
  1012. +#endif
  1013. if (!all_segs && emit_other_sections)
  1014. /* There is no line information and no non-empty .debug_info
  1015. @@ -1375,11 +1434,17 @@
  1016. return;
  1017. /* Calculate the size of an address for the target machine. */
  1018. +#ifdef BFD_ASSEMBLER
  1019. sizeof_address = DWARF2_ADDR_SIZE (stdoutput);
  1020. +#else
  1021. + sizeof_address = 4;
  1022. +#endif
  1023. /* Create and switch to the line number section. */
  1024. line_seg = subseg_new (".debug_line", 0);
  1025. +#ifdef BFD_ASSEMBLER
  1026. bfd_set_section_flags (stdoutput, line_seg, SEC_READONLY | SEC_DEBUGGING);
  1027. +#endif
  1028. /* For each subsection, chain the debug entries together. */
  1029. for (s = all_segs; s; s = s->next)
  1030. @@ -1410,12 +1475,14 @@
  1031. abbrev_seg = subseg_new (".debug_abbrev", 0);
  1032. aranges_seg = subseg_new (".debug_aranges", 0);
  1033. +#ifdef BFD_ASSEMBLER
  1034. bfd_set_section_flags (stdoutput, info_seg,
  1035. SEC_READONLY | SEC_DEBUGGING);
  1036. bfd_set_section_flags (stdoutput, abbrev_seg,
  1037. SEC_READONLY | SEC_DEBUGGING);
  1038. bfd_set_section_flags (stdoutput, aranges_seg,
  1039. SEC_READONLY | SEC_DEBUGGING);
  1040. +#endif
  1041. record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1);
  1042. diff -Naur binutils-2.16.1.orig/gas/dwarf2dbg.h binutils-2.16.1-src/gas/dwarf2dbg.h
  1043. --- binutils-2.16.1.orig/gas/dwarf2dbg.h 2005-03-03 02:29:52.000000000 +0100
  1044. +++ binutils-2.16.1-src/gas/dwarf2dbg.h 2005-07-01 00:40:16.000000000 +0200
  1045. @@ -61,6 +61,7 @@
  1046. /* Must be called for each generated instruction. */
  1047. extern void dwarf2_emit_insn (int);
  1048. +extern void dwarf2_emit_insn_if_loc_seen (int);
  1049. extern void dwarf2_finish (void);
  1050. diff -Naur binutils-2.16.1.orig/gas/expr.c binutils-2.16.1-src/gas/expr.c
  1051. --- binutils-2.16.1.orig/gas/expr.c 2005-03-03 18:22:12.000000000 +0100
  1052. +++ binutils-2.16.1-src/gas/expr.c 2006-11-18 18:21:12.000000000 +0100
  1053. @@ -1,6 +1,6 @@
  1054. /* expr.c -operands, expressions-
  1055. Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  1056. - 1999, 2000, 2001, 2002, 2003, 2004, 2005
  1057. + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
  1058. Free Software Foundation, Inc.
  1059. This file is part of GAS, the GNU Assembler.
  1060. @@ -1620,16 +1620,18 @@
  1061. return ret;
  1062. case '!':
  1063. - /* We accept !! as equivalent to ^ for MRI compatibility. */
  1064. - if (input_line_pointer[1] != '!')
  1065. - {
  1066. + switch (input_line_pointer[1]) {
  1067. + default:
  1068. if (flag_m68k_mri)
  1069. return O_bit_inclusive_or;
  1070. return op_encoding[c];
  1071. - }
  1072. + case '!': /* We accept !! as equivalent to ^ for MRI compatibility. */
  1073. *num_chars = 2;
  1074. return O_bit_exclusive_or;
  1075. -
  1076. + case '=': /* We accept != as equivalent to <> */
  1077. + *num_chars = 2;
  1078. + return O_ne;
  1079. + }
  1080. case '|':
  1081. if (input_line_pointer[1] != '|')
  1082. return op_encoding[c];
  1083. @@ -1676,6 +1678,7 @@
  1084. while (op_left != O_illegal && op_rank[(int) op_left] > rank)
  1085. {
  1086. segT rightseg;
  1087. + bfd_vma frag_off;
  1088. input_line_pointer += op_chars; /* -> after operator. */
  1089. @@ -1751,16 +1754,22 @@
  1090. /* X + constant. */
  1091. resultP->X_add_number += right.X_add_number;
  1092. }
  1093. - /* This case comes up in PIC code. */
  1094. - else if (op_left == O_subtract
  1095. + /* This case comes up in PIC code.
  1096. + (TIGCC 20040719) This optimization isn't valid in all-relocs mode.
  1097. + -- Kevin Kofler */
  1098. + else if (!flag_all_relocs
  1099. + && op_left == O_subtract
  1100. && right.X_op == O_symbol
  1101. && resultP->X_op == O_symbol
  1102. - && (symbol_get_frag (right.X_add_symbol)
  1103. - == symbol_get_frag (resultP->X_add_symbol))
  1104. + && retval == rightseg
  1105. && (SEG_NORMAL (rightseg)
  1106. - || right.X_add_symbol == resultP->X_add_symbol))
  1107. + || right.X_add_symbol == resultP->X_add_symbol)
  1108. + && frag_offset_fixed_p (symbol_get_frag (resultP->X_add_symbol),
  1109. + symbol_get_frag (right.X_add_symbol),
  1110. + &frag_off))
  1111. {
  1112. resultP->X_add_number -= right.X_add_number;
  1113. + resultP->X_add_number -= frag_off / OCTETS_PER_BYTE;
  1114. resultP->X_add_number += (S_GET_VALUE (resultP->X_add_symbol)
  1115. - S_GET_VALUE (right.X_add_symbol));
  1116. resultP->X_op = O_constant;
  1117. @@ -1848,6 +1857,15 @@
  1118. && right.X_add_number == 0)))
  1119. {
  1120. /* Symbol OP symbol. */
  1121. +
  1122. + /* (TIGCC 20030717) Optimize .set sym2,sym3+c; sym1-sym2 to
  1123. + .set sym2,sym3+c; sym1-(sym3+c). The code below will further change
  1124. + this to .set sym2,sym3+c; (sym1-c)-sym3. -- Kevin Kofler */
  1125. + if (!right.X_add_number && right.X_add_symbol->sy_value.X_op == O_symbol) {
  1126. + resolve_symbol_value(right.X_add_symbol);
  1127. + memcpy(&right, &right.X_add_symbol->sy_value, sizeof(expressionS));
  1128. + }
  1129. +
  1130. resultP->X_op = op_left;
  1131. resultP->X_op_symbol = right.X_add_symbol;
  1132. if (op_left == O_add)
  1133. diff -Naur binutils-2.16.1.orig/gas/frags.c binutils-2.16.1-src/gas/frags.c
  1134. --- binutils-2.16.1.orig/gas/frags.c 2005-03-03 02:29:52.000000000 +0100
  1135. +++ binutils-2.16.1-src/gas/frags.c 2006-11-18 18:30:19.000000000 +0100
  1136. @@ -1,6 +1,6 @@
  1137. /* frags.c - manage frags -
  1138. Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  1139. - 1999, 2000, 2001, 2003, 2004
  1140. + 1999, 2000, 2001, 2003, 2004, 2005, 2006
  1141. Free Software Foundation, Inc.
  1142. This file is part of GAS, the GNU Assembler.
  1143. @@ -376,3 +376,56 @@
  1144. }
  1145. obstack_1grow (&frchain_now->frch_obstack, datum);
  1146. }
  1147. +
  1148. +/* Return TRUE if FRAG1 and FRAG2 have a fixed relationship between
  1149. + their start addresses. Set OFFSET to the difference in address
  1150. + not already accounted for in the frag FR_ADDRESS. */
  1151. +
  1152. +bfd_boolean
  1153. +frag_offset_fixed_p (fragS *frag1, fragS *frag2, bfd_vma *offset)
  1154. +{
  1155. + fragS *frag;
  1156. + bfd_vma off;
  1157. +
  1158. + /* Start with offset initialised to difference between the two frags.
  1159. + Prior to assigning frag addresses this will be zero. */
  1160. + off = frag1->fr_address - frag2->fr_address;
  1161. + if (frag1 == frag2)
  1162. + {
  1163. + *offset = off;
  1164. + return TRUE;
  1165. + }
  1166. +
  1167. + /* Maybe frag2 is after frag1. */
  1168. + frag = frag1;
  1169. + while (frag->fr_type == rs_fill)
  1170. + {
  1171. + off += frag->fr_fix + frag->fr_offset * frag->fr_var;
  1172. + frag = frag->fr_next;
  1173. + if (frag == NULL)
  1174. + break;
  1175. + if (frag == frag2)
  1176. + {
  1177. + *offset = off;
  1178. + return TRUE;
  1179. + }
  1180. + }
  1181. +
  1182. + /* Maybe frag1 is after frag2. */
  1183. + off = frag1->fr_address - frag2->fr_address;
  1184. + frag = frag2;
  1185. + while (frag->fr_type == rs_fill)
  1186. + {
  1187. + off -= frag->fr_fix + frag->fr_offset * frag->fr_var;
  1188. + frag = frag->fr_next;
  1189. + if (frag == NULL)
  1190. + break;
  1191. + if (frag == frag1)
  1192. + {
  1193. + *offset = off;
  1194. + return TRUE;
  1195. + }
  1196. + }
  1197. +
  1198. + return FALSE;
  1199. +}
  1200. diff -Naur binutils-2.16.1.orig/gas/frags.h binutils-2.16.1-src/gas/frags.h
  1201. --- binutils-2.16.1.orig/gas/frags.h 2005-03-03 02:29:52.000000000 +0100
  1202. +++ binutils-2.16.1-src/gas/frags.h 2006-11-18 18:20:53.000000000 +0100
  1203. @@ -1,6 +1,6 @@
  1204. /* frags.h - Header file for the frag concept.
  1205. Copyright 1987, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
  1206. - 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  1207. + 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  1208. This file is part of GAS, the GNU Assembler.
  1209. @@ -66,6 +66,9 @@
  1210. char *fr_file;
  1211. unsigned int fr_line;
  1212. + /* (TIGCC) Symbol at the beginning of the frag. May be NULL. */
  1213. + symbolS *fr_start_symbol;
  1214. +
  1215. #ifndef NO_LISTING
  1216. struct list_info_struct *line;
  1217. #endif
  1218. @@ -150,4 +153,6 @@
  1219. offsetT offset,
  1220. char *opcode);
  1221. +bfd_boolean frag_offset_fixed_p (fragS *, fragS *, bfd_vma *);
  1222. +
  1223. #endif /* FRAGS_H */
  1224. diff -Naur binutils-2.16.1.orig/gas/listing.c binutils-2.16.1-src/gas/listing.c
  1225. --- binutils-2.16.1.orig/gas/listing.c 2005-03-03 02:29:52.000000000 +0100
  1226. +++ binutils-2.16.1-src/gas/listing.c 2005-07-01 00:40:16.000000000 +0200
  1227. @@ -944,7 +944,8 @@
  1228. int show_listing = 1;
  1229. unsigned int width;
  1230. - buffer = xmalloc (listing_rhs_width);
  1231. + buffer = xmalloc (listing_rhs_width + 1); /* (TIGCC 20030901) Add 1 for the
  1232. + terminating '\0' character. -- Kevin Kofler */
  1233. data_buffer = xmalloc (MAX_BYTES);
  1234. eject = 1;
  1235. list = head;
  1236. @@ -962,8 +963,8 @@
  1237. {
  1238. unsigned int list_line;
  1239. - width = listing_rhs_width > paper_width ? paper_width :
  1240. - listing_rhs_width;
  1241. + width = (listing_rhs_width > paper_width ? paper_width :
  1242. + listing_rhs_width) + 1; /* (TIGCC 20030901) See above. */
  1243. list_line = list->line;
  1244. switch (list->edict)
  1245. diff -Naur binutils-2.16.1.orig/gas/read.c binutils-2.16.1-src/gas/read.c
  1246. --- binutils-2.16.1.orig/gas/read.c 2005-04-13 20:58:40.000000000 +0200
  1247. +++ binutils-2.16.1-src/gas/read.c 2007-02-18 22:45:10.000000000 +0100
  1248. @@ -40,6 +40,7 @@
  1249. #include "obstack.h"
  1250. #include "listing.h"
  1251. #include "ecoff.h"
  1252. +#include "dwarf2dbg.h"
  1253. #include "dw2gencfi.h"
  1254. #ifndef TC_START_LABEL
  1255. @@ -3273,6 +3274,14 @@
  1256. {
  1257. symbolS *s = exp.X_add_symbol;
  1258. + /* (TIGCC 20050611) Don't evaluate defined+const here, as this breaks
  1259. + all-relocs mode. -- Kevin Kofler */
  1260. + if (exp.X_add_number != 0)
  1261. + {
  1262. + symbol_set_value_expression (symbolP, &exp);
  1263. + break;
  1264. + }
  1265. +
  1266. S_SET_SEGMENT (symbolP, seg);
  1267. S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (s));
  1268. symbol_set_frag (symbolP, symbol_get_frag (s));
  1269. @@ -3427,7 +3436,13 @@
  1270. void
  1271. cons (int size)
  1272. {
  1273. + /* (TIGCC 20050603) Call dwarf2_emit_insn_if_loc_seen unless we are in a
  1274. + debugging info section. -- Kevin Kofler */
  1275. + const char *segname;
  1276. cons_worker (size, 0);
  1277. + segname = seg_info (now_seg)->scnhdr.s_name;
  1278. + if (strncmp (segname, ".debug_", 7) && strncmp (segname, ".eh_", 4))
  1279. + dwarf2_emit_insn_if_loc_seen (size);
  1280. }
  1281. void
  1282. @@ -3768,8 +3783,9 @@
  1283. #define TC_CONS_RELOC 0
  1284. #endif
  1285. #endif
  1286. + /* (TIGCC 20040920) Constants aren't optimizable relocs. -- Kevin Kofler */
  1287. fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
  1288. - TC_CONS_RELOC);
  1289. + TC_CONS_RELOC) -> fx_unoptimizable = 1;
  1290. #endif /* TC_CONS_FIX_NEW */
  1291. #endif /* BFD_ASSEMBLER */
  1292. }
  1293. @@ -4638,6 +4654,14 @@
  1294. {
  1295. register unsigned int c;
  1296. + /* (TIGCC 20070218) input_line_pointer can overflow, catch that. */
  1297. + if (input_line_pointer >= buffer_limit)
  1298. + {
  1299. + buffer_limit = input_scrub_next_buffer (&input_line_pointer);
  1300. + if (buffer_limit == 0)
  1301. + return NOT_A_CHAR;
  1302. + }
  1303. +
  1304. c = *input_line_pointer++ & CHAR_MASK;
  1305. switch (c)
  1306. {
  1307. diff -Naur binutils-2.16.1.orig/gas/subsegs.c binutils-2.16.1-src/gas/subsegs.c
  1308. --- binutils-2.16.1.orig/gas/subsegs.c 2005-03-03 12:47:44.000000000 +0100
  1309. +++ binutils-2.16.1-src/gas/subsegs.c 2005-07-01 00:40:16.000000000 +0200
  1310. @@ -41,6 +41,8 @@
  1311. #endif /* MANY_SEGMENTS */
  1312. char const *const seg_name[] = {
  1313. +/* (TIGCC 20040905) Allow arbitrary number of sections here. -- Kevin Kofler */
  1314. +#if 0
  1315. "absolute",
  1316. #ifdef MANY_SEGMENTS
  1317. "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9",
  1318. @@ -52,6 +54,7 @@
  1319. "data",
  1320. "bss",
  1321. #endif /* MANY_SEGMENTS */
  1322. +#endif /* 0 */
  1323. "unknown",
  1324. "ASSEMBLER-INTERNAL-LOGIC-ERROR!",
  1325. "expr",
  1326. @@ -61,6 +64,17 @@
  1327. "register",
  1328. "",
  1329. }; /* Used by error reporters, dumpers etc. */
  1330. +
  1331. +char *segment_name (n) int n;
  1332. +{
  1333. + if (!n) return "absolute";
  1334. + else if (SEG_NORMAL(n)) {
  1335. + static char s[8];
  1336. + sprintf(s,"e%d",n-SEG_E0);
  1337. + return s;
  1338. + } else return seg_name[n-(N_SEGMENTS+1)];
  1339. +}
  1340. +
  1341. #else /* BFD_ASSEMBLER */
  1342. /* Gas segment information for bfd_abs_section_ptr and
  1343. diff -Naur binutils-2.16.1.orig/gas/subsegs.h binutils-2.16.1-src/gas/subsegs.h
  1344. --- binutils-2.16.1.orig/gas/subsegs.h 2005-02-17 14:46:00.000000000 +0100
  1345. +++ binutils-2.16.1-src/gas/subsegs.h 2005-07-01 00:40:16.000000000 +0200
  1346. @@ -89,6 +89,7 @@
  1347. #endif
  1348. symbolS *dot;
  1349. + symbolS *dwarf2_secsym; /* (TIGCC 20050407) */
  1350. struct lineno_list *lineno_list_head;
  1351. struct lineno_list *lineno_list_tail;
  1352. diff -Naur binutils-2.16.1.orig/gas/symbols.c binutils-2.16.1-src/gas/symbols.c
  1353. --- binutils-2.16.1.orig/gas/symbols.c 2005-04-13 20:58:40.000000000 +0200
  1354. +++ binutils-2.16.1-src/gas/symbols.c 2005-07-01 00:40:16.000000000 +0200
  1355. @@ -1143,6 +1143,14 @@
  1356. || add_symbol == op_symbol)))
  1357. report_op_error (symp, add_symbol, op_symbol);
  1358. + /* (TIGCC 20040719) In all-relocs mode, we can't apply operations other
  1359. + than + or - on an address or address difference.
  1360. + -- Kevin Kofler */
  1361. + if (flag_all_relocs && finalize_syms
  1362. + && !(op == O_subtract || op == O_add)
  1363. + && final_seg == undefined_section)
  1364. + report_op_error (symp, add_symbol, op_symbol);
  1365. +
  1366. if (final_seg == expr_section || final_seg == undefined_section)
  1367. final_seg = absolute_section;
  1368. diff -Naur binutils-2.16.1.orig/gas/symbols.h binutils-2.16.1-src/gas/symbols.h
  1369. --- binutils-2.16.1.orig/gas/symbols.h 2005-04-13 20:58:40.000000000 +0200
  1370. +++ binutils-2.16.1-src/gas/symbols.h 2005-07-01 00:40:16.000000000 +0200
  1371. @@ -144,11 +144,16 @@
  1372. /*
  1373. * Current means for getting from symbols to segments and vice verse.
  1374. * This will change for infinite-segments support (e.g. COFF).
  1375. + * (TIGCC 20040905) And indeed it does. -- Kevin Kofler
  1376. */
  1377. extern const segT N_TYPE_seg[]; /* subseg.c */
  1378. +#if 0
  1379. #define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] )
  1380. extern const short seg_N_TYPE[];/* subseg.c */
  1381. +#else
  1382. +short SEGMENT_TO_SYMBOL_TYPE PARAMS ((int seg));
  1383. +#endif
  1384. #define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */
  1385. diff -Naur binutils-2.16.1.orig/gas/write.c binutils-2.16.1-src/gas/write.c
  1386. --- binutils-2.16.1.orig/gas/write.c 2005-03-03 02:29:52.000000000 +0100
  1387. +++ binutils-2.16.1-src/gas/write.c 2005-07-01 00:40:16.000000000 +0200
  1388. @@ -217,6 +217,7 @@
  1389. #if defined(NEED_FX_R_TYPE) || defined (BFD_ASSEMBLER)
  1390. fixP->fx_r_type = r_type;
  1391. #endif
  1392. + fixP->fx_unoptimizable = 0; /* (TIGCC 20040920) */
  1393. fixP->fx_im_disp = 0;
  1394. fixP->fx_pcrel_adjust = 0;
  1395. fixP->fx_bit_fixP = 0;
  1396. @@ -831,6 +832,11 @@
  1397. continue;
  1398. }
  1399. + /* (TIGCC 20030716) Only reduce relocs which refer to local symbols we
  1400. + aren't going to output. -- Kevin Kofler */
  1401. + if (! S_IS_LOCAL (sym))
  1402. + continue;
  1403. +
  1404. /* Don't try to reduce relocs which refer to non-local symbols
  1405. in .linkonce sections. It can lead to confusion when a
  1406. debugging section refers to a .linkonce section. I hope
  1407. @@ -1381,7 +1387,7 @@
  1408. /* This now gets called even if we had errors. In that case,
  1409. any alignment is meaningless, and, moreover, will look weird
  1410. if we are generating a listing. */
  1411. - if (!had_errors ())
  1412. + if (0 /*!had_errors ()*/)
  1413. {
  1414. alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
  1415. #ifdef BFD_ASSEMBLER
  1416. diff -Naur binutils-2.16.1.orig/gas/write.h binutils-2.16.1-src/gas/write.h
  1417. --- binutils-2.16.1.orig/gas/write.h 2005-03-03 02:29:52.000000000 +0100
  1418. +++ binutils-2.16.1-src/gas/write.h 2005-07-01 00:40:16.000000000 +0200
  1419. @@ -71,9 +71,12 @@
  1420. look into it for version 2.6. */
  1421. unsigned fx_plt : 1;
  1422. + /* (TIGCC 20040920) Is this an unoptimizable reloc? -- Kevin Kofler */
  1423. + unsigned fx_unoptimizable : 1;
  1424. +
  1425. /* Is this value an immediate displacement? */
  1426. /* Only used on i960 and ns32k; merge it into TC_FIX_TYPE sometime. */
  1427. - unsigned fx_im_disp : 2;
  1428. + unsigned fx_im_disp : 1;
  1429. /* A bit for the CPU specific code.
  1430. This probably can be folded into tc_fix_data, below. */
  1431. diff -Naur binutils-2.16.1.orig/include/coff/internal.h binutils-2.16.1-src/include/coff/internal.h
  1432. --- binutils-2.16.1.orig/include/coff/internal.h 2005-03-03 12:58:04.000000000 +0100
  1433. +++ binutils-2.16.1-src/include/coff/internal.h 2005-07-01 00:40:16.000000000 +0200
  1434. @@ -350,6 +350,9 @@
  1435. #define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */
  1436. +/* (TIGCC 20040724) TIGCC COFF extensions for section flags -- Kevin Kofler */
  1437. +#define STYP_MERGEABLE 0x1000000
  1438. +#define STYP_UNALIGNED 0x2000000
  1439. /********************** LINE NUMBERS **********************/
  1440. @@ -744,4 +747,9 @@
  1441. #define R_W65_DP 10 /* direct page 8 bits only */
  1442. +/* (TIGCC 20030716, 20040920) TIGCC COFF extensions -- Kevin Kofler */
  1443. +#define R_RELWORD_NEG 0x7161
  1444. +#define R_RELBYTE_NEG 0x7162
  1445. +#define R_UNOPTIMIZABLE 0x8000
  1446. +
  1447. #endif /* GNU_COFF_INTERNAL_H */
  1448. diff -Naur binutils-2.16.1.orig/opcodes/configure binutils-2.16.1-src/opcodes/configure
  1449. --- binutils-2.16.1.orig/opcodes/configure 2005-01-31 21:30:36.000000000 +0100
  1450. +++ binutils-2.16.1-src/opcodes/configure 2005-07-01 00:40:16.000000000 +0200
  1451. @@ -271,7 +271,7 @@
  1452. PACKAGE_STRING=
  1453. PACKAGE_BUGREPORT=
  1454. -ac_unique_file="z8k-dis.c"
  1455. +ac_unique_file="m68k-dis.c"
  1456. # Factoring default headers for most tests.
  1457. ac_includes_default="\
  1458. #include <stdio.h>
  1459. diff -Naur binutils-2.16.1.orig/opcodes/configure.in binutils-2.16.1-src/opcodes/configure.in
  1460. --- binutils-2.16.1.orig/opcodes/configure.in 2004-11-08 14:17:36.000000000 +0100
  1461. +++ binutils-2.16.1-src/opcodes/configure.in 2005-07-01 00:40:16.000000000 +0200
  1462. @@ -3,7 +3,7 @@
  1463. AC_PREREQ(2.59)
  1464. AC_INIT
  1465. -AC_CONFIG_SRCDIR([z8k-dis.c])
  1466. +AC_CONFIG_SRCDIR([m68k-dis.c])
  1467. AC_CANONICAL_TARGET
  1468. AC_ISC_POSIX
  1469. diff -Naur binutils-2.16.1.orig/opcodes/m68k-opc.c binutils-2.16.1-src/opcodes/m68k-opc.c
  1470. --- binutils-2.16.1.orig/opcodes/m68k-opc.c 2004-05-24 17:33:22.000000000 +0200
  1471. +++ binutils-2.16.1-src/opcodes/m68k-opc.c 2005-07-01 00:40:16.000000000 +0200
  1472. @@ -116,6 +116,22 @@
  1473. {"asrl", 2, one(0160200), one(0170770), "QdDs", m68000up | mcfisa_a },
  1474. {"asrl", 2, one(0160240), one(0170770), "DdDs", m68000up | mcfisa_a },
  1475. +/* (TIGCC 20050130) New branch type: variable-size, word by default. */
  1476. +{"bhi", 2, one(0061000), one(0177777), "BG", m68000up | mcfisa_a },
  1477. +{"bls", 2, one(0061400), one(0177777), "BG", m68000up | mcfisa_a },
  1478. +{"bcc", 2, one(0062000), one(0177777), "BG", m68000up | mcfisa_a },
  1479. +{"bcs", 2, one(0062400), one(0177777), "BG", m68000up | mcfisa_a },
  1480. +{"bne", 2, one(0063000), one(0177777), "BG", m68000up | mcfisa_a },
  1481. +{"beq", 2, one(0063400), one(0177777), "BG", m68000up | mcfisa_a },
  1482. +{"bvc", 2, one(0064000), one(0177777), "BG", m68000up | mcfisa_a },
  1483. +{"bvs", 2, one(0064400), one(0177777), "BG", m68000up | mcfisa_a },
  1484. +{"bpl", 2, one(0065000), one(0177777), "BG", m68000up | mcfisa_a },
  1485. +{"bmi", 2, one(0065400), one(0177777), "BG", m68000up | mcfisa_a },
  1486. +{"bge", 2, one(0066000), one(0177777), "BG", m68000up | mcfisa_a },
  1487. +{"blt", 2, one(0066400), one(0177777), "BG", m68000up | mcfisa_a },
  1488. +{"bgt", 2, one(0067000), one(0177777), "BG", m68000up | mcfisa_a },
  1489. +{"ble", 2, one(0067400), one(0177777), "BG", m68000up | mcfisa_a },
  1490. +
  1491. {"bhiw", 2, one(0061000), one(0177777), "BW", m68000up | mcfisa_a },
  1492. {"blsw", 2, one(0061400), one(0177777), "BW", m68000up | mcfisa_a },
  1493. {"bccw", 2, one(0062000), one(0177777), "BW", m68000up | mcfisa_a },
  1494. @@ -199,6 +215,8 @@
  1495. {"bkpt", 2, one(0044110), one(0177770), "ts", m68010up },
  1496. +/* (TIGCC 20050130) New branch type: variable-size, word by default. */
  1497. +{"bra", 2, one(0060000), one(0177777), "BG", m68000up | mcfisa_a },
  1498. {"braw", 2, one(0060000), one(0177777), "BW", m68000up | mcfisa_a },
  1499. {"bral", 2, one(0060377), one(0177777), "BL", m68020up | cpu32 | mcfisa_b},
  1500. {"bras", 2, one(0060000), one(0177400), "BB", m68000up | mcfisa_a },
  1501. @@ -208,6 +226,8 @@
  1502. {"bset", 4, one(0004300), one(0177700), "#b$s", m68000up },
  1503. {"bset", 4, one(0004300), one(0177700), "#bqs", mcfisa_a },
  1504. +/* (TIGCC 20050130) New branch type: variable-size, word by default. */
  1505. +{"bsr", 2, one(0060400), one(0177777), "BG", m68000up | mcfisa_a },
  1506. {"bsrw", 2, one(0060400), one(0177777), "BW", m68000up | mcfisa_a },
  1507. {"bsrl", 2, one(0060777), one(0177777), "BL", m68020up | cpu32 | mcfisa_b},
  1508. {"bsrs", 2, one(0060400), one(0177400), "BB", m68000up | mcfisa_a },
  1509. @@ -254,6 +274,7 @@
  1510. {"clrb", 2, one(0041000), one(0177700), "$s", m68000up | mcfisa_a },
  1511. {"clrw", 2, one(0041100), one(0177700), "$s", m68000up | mcfisa_a },
  1512. +{"clrl", 2, one(0070000), one(0170477), "Dd", m68000 },
  1513. {"clrl", 2, one(0041200), one(0177700), "$s", m68000up | mcfisa_a },
  1514. {"cmp2b", 4, two(0000300,0), two(0177700,07777), "!sR1", m68020up | cpu32 },
  1515. @@ -263,11 +284,11 @@
  1516. {"cmpaw", 2, one(0130300), one(0170700), "*wAd", m68000up },
  1517. {"cmpal", 2, one(0130700), one(0170700), "*lAd", m68000up | mcfisa_a },
  1518. -{"cmpib", 4, one(0006000), one(0177700), "#b@s", m68000up },
  1519. +{"cmpib", 4, one(0006000), one(0177700), "#b$s", m68000up },
  1520. {"cmpib", 4, one(0006000), one(0177700), "#bDs", mcfisa_b },
  1521. -{"cmpiw", 4, one(0006100), one(0177700), "#w@s", m68000up },
  1522. +{"cmpiw", 4, one(0006100), one(0177700), "#w$s", m68000up },
  1523. {"cmpiw", 4, one(0006100), one(0177700), "#wDs", mcfisa_b },
  1524. -{"cmpil", 6, one(0006200), one(0177700), "#l@s", m68000up },
  1525. +{"cmpil", 6, one(0006200), one(0177700), "#l$s", m68000up },
  1526. {"cmpil", 6, one(0006200), one(0177700), "#lDs", mcfisa_a },
  1527. {"cmpmb", 2, one(0130410), one(0170770), "+s+d", m68000up },
  1528. @@ -275,18 +296,18 @@
  1529. {"cmpml", 2, one(0130610), one(0170770), "+s+d", m68000up },
  1530. /* The cmp opcode can generate the cmpa, cmpm, and cmpi instructions. */
  1531. -{"cmpb", 4, one(0006000), one(0177700), "#b@s", m68000up },
  1532. +{"cmpb", 4, one(0006000), one(0177700), "#b$s", m68000up },
  1533. {"cmpb", 4, one(0006000), one(0177700), "#bDs", mcfisa_b },
  1534. {"cmpb", 2, one(0130410), one(0170770), "+s+d", m68000up },
  1535. {"cmpb", 2, one(0130000), one(0170700), ";bDd", m68000up },
  1536. {"cmpb", 2, one(0130000), one(0170700), "*bDd", mcfisa_b },
  1537. {"cmpw", 2, one(0130300), one(0170700), "*wAd", m68000up },
  1538. -{"cmpw", 4, one(0006100), one(0177700), "#w@s", m68000up },
  1539. +{"cmpw", 4, one(0006100), one(0177700), "#w$s", m68000up },
  1540. {"cmpw", 4, one(0006100), one(0177700), "#wDs", mcfisa_b },
  1541. {"cmpw", 2, one(0130510), one(0170770), "+s+d", m68000up },
  1542. {"cmpw", 2, one(0130100), one(0170700), "*wDd", m68000up | mcfisa_b },
  1543. {"cmpl", 2, one(0130700), one(0170700), "*lAd", m68000up | mcfisa_a },
  1544. -{"cmpl", 6, one(0006200), one(0177700), "#l@s", m68000up },
  1545. +{"cmpl", 6, one(0006200), one(0177700), "#l$s", m68000up },
  1546. {"cmpl", 6, one(0006200), one(0177700), "#lDs", mcfisa_a },
  1547. {"cmpl", 2, one(0130610), one(0170770), "+s+d", m68000up },
  1548. {"cmpl", 2, one(0130200), one(0170700), "*lDd", m68000up | mcfisa_a },
  1549. @@ -2181,6 +2202,7 @@
  1550. const struct m68k_opcode_alias m68k_opcode_aliases[] =
  1551. {
  1552. + { "abcdb", "abcd", }, /* (TIGCC 20030901) */
  1553. { "add", "addw", },
  1554. { "adda", "addaw", },
  1555. { "addi", "addiw", },
  1556. @@ -2188,22 +2210,6 @@
  1557. { "addx", "addxw", },
  1558. { "asl", "aslw", },
  1559. { "asr", "asrw", },
  1560. - { "bhi", "bhiw", },
  1561. - { "bls", "blsw", },
  1562. - { "bcc", "bccw", },
  1563. - { "bcs", "bcsw", },
  1564. - { "bne", "bnew", },
  1565. - { "beq", "beqw", },
  1566. - { "bvc", "bvcw", },
  1567. - { "bvs", "bvsw", },
  1568. - { "bpl", "bplw", },
  1569. - { "bmi", "bmiw", },
  1570. - { "bge", "bgew", },
  1571. - { "blt", "bltw", },
  1572. - { "bgt", "bgtw", },
  1573. - { "ble", "blew", },
  1574. - { "bra", "braw", },
  1575. - { "bsr", "bsrw", },
  1576. { "bhib", "bhis", },
  1577. { "blsb", "blss", },
  1578. { "bccb", "bccs", },
  1579. @@ -2220,17 +2226,17 @@
  1580. { "bleb", "bles", },
  1581. { "brab", "bras", },
  1582. { "bsrb", "bsrs", },
  1583. - { "bhs", "bccw" },
  1584. + { "bhs", "bcc" }, /* (TIGCC 20050130) No 'w'. */
  1585. { "bhss", "bccs" },
  1586. { "bhsb", "bccs" },
  1587. { "bhsw", "bccw" },
  1588. { "bhsl", "bccl" },
  1589. - { "blo", "bcsw" },
  1590. + { "blo", "bcs" }, /* (TIGCC 20050130) No 'w'. */
  1591. { "blos", "bcss" },
  1592. { "blob", "bcss" },
  1593. { "blow", "bcsw" },
  1594. { "blol", "bcsl" },
  1595. - { "br", "braw", },
  1596. + { "br", "bra", }, /* (TIGCC 20050130) No 'w'. */
  1597. { "brs", "bras", },
  1598. { "brb", "bras", },
  1599. { "brw", "braw", },
  1600. @@ -2279,6 +2285,7 @@
  1601. { "tdivsl", "divsl", },
  1602. { "divs", "divsw", },
  1603. { "divu", "divuw", },
  1604. + { "exgl", "exg", }, /* (TIGCC 20020512, 20030901) */
  1605. { "ext", "extw", },
  1606. { "extbw", "extw", },
  1607. { "extwl", "extl", },