obj-coff.c 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939
  1. /* coff object file format
  2. Copyright (C) 1989-2022 Free Software Foundation, Inc.
  3. This file is part of GAS.
  4. GAS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GAS is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GAS; see the file COPYING. If not, write to the Free
  14. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  15. 02110-1301, USA. */
  16. #define OBJ_HEADER "obj-coff.h"
  17. #include "as.h"
  18. #include "safe-ctype.h"
  19. #include "subsegs.h"
  20. #ifdef TE_PE
  21. #include "coff/pe.h"
  22. #endif
  23. #ifdef OBJ_XCOFF
  24. #include "coff/xcoff.h"
  25. #endif
  26. #define streq(a,b) (strcmp ((a), (b)) == 0)
  27. /* I think this is probably always correct. */
  28. #ifndef KEEP_RELOC_INFO
  29. #define KEEP_RELOC_INFO
  30. #endif
  31. /* obj_coff_section will use this macro to set a new section's
  32. attributes when a directive has no valid flags or the "w" flag is
  33. used. This default should be appropriate for most. */
  34. #ifndef TC_COFF_SECTION_DEFAULT_ATTRIBUTES
  35. #define TC_COFF_SECTION_DEFAULT_ATTRIBUTES (SEC_LOAD | SEC_DATA)
  36. #endif
  37. /* This is used to hold the symbol built by a sequence of pseudo-ops
  38. from .def and .endef. */
  39. static symbolS *def_symbol_in_progress;
  40. #ifdef TE_PE
  41. /* PE weak alternate symbols begin with this string. */
  42. static const char weak_altprefix[] = ".weak.";
  43. #endif /* TE_PE */
  44. #include "obj-coff-seh.c"
  45. typedef struct
  46. {
  47. unsigned long chunk_size;
  48. unsigned long element_size;
  49. unsigned long size;
  50. char *data;
  51. unsigned long pointer;
  52. }
  53. stack;
  54. /* Stack stuff. */
  55. static stack *
  56. stack_init (unsigned long chunk_size,
  57. unsigned long element_size)
  58. {
  59. stack *st;
  60. st = XNEW (stack);
  61. st->data = XNEWVEC (char, chunk_size);
  62. if (!st->data)
  63. {
  64. free (st);
  65. return NULL;
  66. }
  67. st->pointer = 0;
  68. st->size = chunk_size;
  69. st->chunk_size = chunk_size;
  70. st->element_size = element_size;
  71. return st;
  72. }
  73. static char *
  74. stack_push (stack *st, char *element)
  75. {
  76. if (st->pointer + st->element_size >= st->size)
  77. {
  78. st->size += st->chunk_size;
  79. st->data = XRESIZEVEC (char, st->data, st->size);
  80. }
  81. memcpy (st->data + st->pointer, element, st->element_size);
  82. st->pointer += st->element_size;
  83. return st->data + st->pointer;
  84. }
  85. static char *
  86. stack_pop (stack *st)
  87. {
  88. if (st->pointer < st->element_size)
  89. {
  90. st->pointer = 0;
  91. return NULL;
  92. }
  93. st->pointer -= st->element_size;
  94. return st->data + st->pointer;
  95. }
  96. /* Maintain a list of the tagnames of the structures. */
  97. static htab_t tag_hash;
  98. static void
  99. tag_init (void)
  100. {
  101. tag_hash = str_htab_create ();
  102. }
  103. static void
  104. tag_insert (const char *name, symbolS *symbolP)
  105. {
  106. str_hash_insert (tag_hash, name, symbolP, 1);
  107. }
  108. static symbolS *
  109. tag_find (char *name)
  110. {
  111. return (symbolS *) str_hash_find (tag_hash, name);
  112. }
  113. static symbolS *
  114. tag_find_or_make (char *name)
  115. {
  116. symbolS *symbolP;
  117. if ((symbolP = tag_find (name)) == NULL)
  118. {
  119. symbolP = symbol_new (name, undefined_section, &zero_address_frag, 0);
  120. tag_insert (S_GET_NAME (symbolP), symbolP);
  121. symbol_table_insert (symbolP);
  122. }
  123. return symbolP;
  124. }
  125. /* We accept the .bss directive to set the section for backward
  126. compatibility with earlier versions of gas. */
  127. static void
  128. obj_coff_bss (int ignore ATTRIBUTE_UNUSED)
  129. {
  130. if (*input_line_pointer == '\n')
  131. subseg_new (".bss", get_absolute_expression ());
  132. else
  133. s_lcomm (0);
  134. }
  135. #ifdef TE_PE
  136. /* Called from read.c:s_comm after we've parsed .comm symbol, size.
  137. Parse a possible alignment value. */
  138. static symbolS *
  139. obj_coff_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP, addressT size)
  140. {
  141. addressT align = 0;
  142. if (*input_line_pointer == ',')
  143. {
  144. align = parse_align (0);
  145. if (align == (addressT) -1)
  146. return NULL;
  147. }
  148. S_SET_VALUE (symbolP, size);
  149. S_SET_EXTERNAL (symbolP);
  150. S_SET_SEGMENT (symbolP, bfd_com_section_ptr);
  151. symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT;
  152. /* There is no S_SET_ALIGN (symbolP, align) in COFF/PE.
  153. Instead we must add a note to the .drectve section. */
  154. if (align)
  155. {
  156. segT current_seg = now_seg;
  157. subsegT current_subseg = now_subseg;
  158. flagword oldflags;
  159. asection *sec;
  160. size_t pfxlen, numlen;
  161. char *frag;
  162. char numbuff[20];
  163. sec = subseg_new (".drectve", 0);
  164. oldflags = bfd_section_flags (sec);
  165. if (oldflags == SEC_NO_FLAGS)
  166. {
  167. if (!bfd_set_section_flags (sec, TC_COFF_SECTION_DEFAULT_ATTRIBUTES))
  168. as_warn (_("error setting flags for \"%s\": %s"),
  169. bfd_section_name (sec),
  170. bfd_errmsg (bfd_get_error ()));
  171. }
  172. /* Emit a string. Note no NUL-termination. */
  173. pfxlen = strlen (" -aligncomm:") + 2 + strlen (S_GET_NAME (symbolP)) + 1;
  174. numlen = snprintf (numbuff, sizeof (numbuff), "%d", (int) align);
  175. frag = frag_more (pfxlen + numlen);
  176. (void) sprintf (frag, " -aligncomm:\"%s\",", S_GET_NAME (symbolP));
  177. memcpy (frag + pfxlen, numbuff, numlen);
  178. /* Restore original subseg. */
  179. subseg_set (current_seg, current_subseg);
  180. }
  181. return symbolP;
  182. }
  183. static void
  184. obj_coff_comm (int ignore ATTRIBUTE_UNUSED)
  185. {
  186. s_comm_internal (ignore, obj_coff_common_parse);
  187. }
  188. #endif /* TE_PE */
  189. /* @@ Ick. */
  190. static segT
  191. fetch_coff_debug_section (void)
  192. {
  193. static segT debug_section;
  194. if (!debug_section)
  195. {
  196. const asymbol *s;
  197. s = bfd_make_debug_symbol (stdoutput, NULL, 0);
  198. gas_assert (s != 0);
  199. debug_section = s->section;
  200. }
  201. return debug_section;
  202. }
  203. void
  204. SA_SET_SYM_ENDNDX (symbolS *sym, symbolS *val)
  205. {
  206. combined_entry_type *entry, *p;
  207. entry = &coffsymbol (symbol_get_bfdsym (sym))->native[1];
  208. p = coffsymbol (symbol_get_bfdsym (val))->native;
  209. entry->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = p;
  210. entry->fix_end = 1;
  211. }
  212. static void
  213. SA_SET_SYM_TAGNDX (symbolS *sym, symbolS *val)
  214. {
  215. combined_entry_type *entry, *p;
  216. entry = &coffsymbol (symbol_get_bfdsym (sym))->native[1];
  217. p = coffsymbol (symbol_get_bfdsym (val))->native;
  218. entry->u.auxent.x_sym.x_tagndx.p = p;
  219. entry->fix_tag = 1;
  220. }
  221. static int
  222. S_GET_DATA_TYPE (symbolS *sym)
  223. {
  224. return coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_type;
  225. }
  226. int
  227. S_SET_DATA_TYPE (symbolS *sym, int val)
  228. {
  229. coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_type = val;
  230. return val;
  231. }
  232. int
  233. S_GET_STORAGE_CLASS (symbolS *sym)
  234. {
  235. return coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_sclass;
  236. }
  237. int
  238. S_SET_STORAGE_CLASS (symbolS *sym, int val)
  239. {
  240. coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_sclass = val;
  241. return val;
  242. }
  243. /* Merge a debug symbol containing debug information into a normal symbol. */
  244. static void
  245. c_symbol_merge (symbolS *debug, symbolS *normal)
  246. {
  247. S_SET_DATA_TYPE (normal, S_GET_DATA_TYPE (debug));
  248. S_SET_STORAGE_CLASS (normal, S_GET_STORAGE_CLASS (debug));
  249. if (S_GET_NUMBER_AUXILIARY (debug) > S_GET_NUMBER_AUXILIARY (normal))
  250. /* Take the most we have. */
  251. S_SET_NUMBER_AUXILIARY (normal, S_GET_NUMBER_AUXILIARY (debug));
  252. if (S_GET_NUMBER_AUXILIARY (debug) > 0)
  253. /* Move all the auxiliary information. */
  254. memcpy (SYM_AUXINFO (normal), SYM_AUXINFO (debug),
  255. (S_GET_NUMBER_AUXILIARY (debug)
  256. * sizeof (*SYM_AUXINFO (debug))));
  257. /* Move the debug flags. */
  258. SF_SET_DEBUG_FIELD (normal, SF_GET_DEBUG_FIELD (debug));
  259. }
  260. void
  261. c_dot_file_symbol (const char *filename, int appfile ATTRIBUTE_UNUSED)
  262. {
  263. symbolS *symbolP;
  264. /* BFD converts filename to a .file symbol with an aux entry. It
  265. also handles chaining. */
  266. symbolP = symbol_new (filename, bfd_abs_section_ptr, &zero_address_frag, 0);
  267. S_SET_STORAGE_CLASS (symbolP, C_FILE);
  268. S_SET_NUMBER_AUXILIARY (symbolP, 1);
  269. symbol_get_bfdsym (symbolP)->flags = BSF_DEBUGGING;
  270. #ifndef NO_LISTING
  271. {
  272. extern int listing;
  273. if (listing)
  274. listing_source_file (filename);
  275. }
  276. #endif
  277. /* Make sure that the symbol is first on the symbol chain. */
  278. if (symbol_rootP != symbolP)
  279. {
  280. symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
  281. symbol_insert (symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
  282. }
  283. }
  284. /* Line number handling. */
  285. struct line_no
  286. {
  287. struct line_no *next;
  288. fragS *frag;
  289. alent l;
  290. };
  291. int coff_line_base;
  292. /* Symbol of last function, which we should hang line#s off of. */
  293. static symbolS *line_fsym;
  294. #define in_function() (line_fsym != 0)
  295. #define clear_function() (line_fsym = 0)
  296. #define set_function(F) (line_fsym = (F), coff_add_linesym (F))
  297. void
  298. coff_obj_symbol_new_hook (symbolS *symbolP)
  299. {
  300. long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
  301. char * s = XNEWVEC (char, sz);
  302. memset (s, 0, sz);
  303. coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s;
  304. coffsymbol (symbol_get_bfdsym (symbolP))->native->is_sym = true;
  305. S_SET_DATA_TYPE (symbolP, T_NULL);
  306. S_SET_STORAGE_CLASS (symbolP, 0);
  307. S_SET_NUMBER_AUXILIARY (symbolP, 0);
  308. if (S_IS_STRING (symbolP))
  309. SF_SET_STRING (symbolP);
  310. if (S_IS_LOCAL (symbolP))
  311. SF_SET_LOCAL (symbolP);
  312. }
  313. void
  314. coff_obj_symbol_clone_hook (symbolS *newsymP, symbolS *orgsymP)
  315. {
  316. long elts = OBJ_COFF_MAX_AUXENTRIES + 1;
  317. combined_entry_type * s = XNEWVEC (combined_entry_type, elts);
  318. memcpy (s, coffsymbol (symbol_get_bfdsym (orgsymP))->native,
  319. elts * sizeof (combined_entry_type));
  320. coffsymbol (symbol_get_bfdsym (newsymP))->native = s;
  321. SF_SET (newsymP, SF_GET (orgsymP));
  322. }
  323. /* Handle .ln directives. */
  324. static symbolS *current_lineno_sym;
  325. static struct line_no *line_nos;
  326. /* FIXME: Blindly assume all .ln directives will be in the .text section. */
  327. int coff_n_line_nos;
  328. static void
  329. add_lineno (fragS * frag, addressT offset, int num)
  330. {
  331. struct line_no * new_line = XNEW (struct line_no);
  332. if (!current_lineno_sym)
  333. abort ();
  334. #ifndef OBJ_XCOFF
  335. /* The native aix assembler accepts negative line number. */
  336. if (num <= 0)
  337. {
  338. /* Zero is used as an end marker in the file. */
  339. as_warn (_("Line numbers must be positive integers\n"));
  340. num = 1;
  341. }
  342. #endif /* OBJ_XCOFF */
  343. new_line->next = line_nos;
  344. new_line->frag = frag;
  345. new_line->l.line_number = num;
  346. new_line->l.u.offset = offset;
  347. line_nos = new_line;
  348. coff_n_line_nos++;
  349. }
  350. void
  351. coff_add_linesym (symbolS *sym)
  352. {
  353. if (line_nos)
  354. {
  355. coffsymbol (symbol_get_bfdsym (current_lineno_sym))->lineno =
  356. (alent *) line_nos;
  357. coff_n_line_nos++;
  358. line_nos = 0;
  359. }
  360. current_lineno_sym = sym;
  361. }
  362. static void
  363. obj_coff_ln (int appline)
  364. {
  365. int l;
  366. if (! appline && def_symbol_in_progress != NULL)
  367. {
  368. as_warn (_(".ln pseudo-op inside .def/.endef: ignored."));
  369. demand_empty_rest_of_line ();
  370. return;
  371. }
  372. l = get_absolute_expression ();
  373. /* If there is no lineno symbol, treat a .ln
  374. directive as if it were a .appline directive. */
  375. if (appline || current_lineno_sym == NULL)
  376. new_logical_line ((char *) NULL, l - 1);
  377. else
  378. add_lineno (frag_now, frag_now_fix (), l);
  379. #ifndef NO_LISTING
  380. {
  381. extern int listing;
  382. if (listing)
  383. {
  384. if (! appline)
  385. l += coff_line_base - 1;
  386. listing_source_line (l);
  387. }
  388. }
  389. #endif
  390. demand_empty_rest_of_line ();
  391. }
  392. /* .loc is essentially the same as .ln; parse it for assembler
  393. compatibility. */
  394. static void
  395. obj_coff_loc (int ignore ATTRIBUTE_UNUSED)
  396. {
  397. int lineno;
  398. /* FIXME: Why do we need this check? We need it for ECOFF, but why
  399. do we need it for COFF? */
  400. if (now_seg != text_section)
  401. {
  402. as_warn (_(".loc outside of .text"));
  403. demand_empty_rest_of_line ();
  404. return;
  405. }
  406. if (def_symbol_in_progress != NULL)
  407. {
  408. as_warn (_(".loc pseudo-op inside .def/.endef: ignored."));
  409. demand_empty_rest_of_line ();
  410. return;
  411. }
  412. /* Skip the file number. */
  413. SKIP_WHITESPACE ();
  414. get_absolute_expression ();
  415. SKIP_WHITESPACE ();
  416. lineno = get_absolute_expression ();
  417. #ifndef NO_LISTING
  418. {
  419. extern int listing;
  420. if (listing)
  421. {
  422. lineno += coff_line_base - 1;
  423. listing_source_line (lineno);
  424. }
  425. }
  426. #endif
  427. demand_empty_rest_of_line ();
  428. add_lineno (frag_now, frag_now_fix (), lineno);
  429. }
  430. /* Handle the .ident pseudo-op. */
  431. static void
  432. obj_coff_ident (int ignore ATTRIBUTE_UNUSED)
  433. {
  434. segT current_seg = now_seg;
  435. subsegT current_subseg = now_subseg;
  436. #ifdef TE_PE
  437. {
  438. segT sec;
  439. /* We could put it in .comment, but that creates an extra section
  440. that shouldn't be loaded into memory, which requires linker
  441. changes... For now, until proven otherwise, use .rdata. */
  442. sec = subseg_new (".rdata$zzz", 0);
  443. bfd_set_section_flags (sec,
  444. ((SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA)
  445. & bfd_applicable_section_flags (stdoutput)));
  446. }
  447. #else
  448. subseg_new (".comment", 0);
  449. #endif
  450. stringer (8 + 1);
  451. subseg_set (current_seg, current_subseg);
  452. }
  453. /* Handle .def directives.
  454. One might ask : why can't we symbol_new if the symbol does not
  455. already exist and fill it with debug information. Because of
  456. the C_EFCN special symbol. It would clobber the value of the
  457. function symbol before we have a chance to notice that it is
  458. a C_EFCN. And a second reason is that the code is more clear this
  459. way. (at least I think it is :-). */
  460. #define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
  461. #define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
  462. *input_line_pointer == '\t') \
  463. input_line_pointer++;
  464. static void
  465. obj_coff_def (int what ATTRIBUTE_UNUSED)
  466. {
  467. char name_end; /* Char after the end of name. */
  468. char *symbol_name; /* Name of the debug symbol. */
  469. char *symbol_name_copy; /* Temporary copy of the name. */
  470. if (def_symbol_in_progress != NULL)
  471. {
  472. as_warn (_(".def pseudo-op used inside of .def/.endef: ignored."));
  473. demand_empty_rest_of_line ();
  474. return;
  475. }
  476. SKIP_WHITESPACES ();
  477. name_end = get_symbol_name (&symbol_name);
  478. symbol_name_copy = xstrdup (symbol_name);
  479. #ifdef tc_canonicalize_symbol_name
  480. symbol_name_copy = tc_canonicalize_symbol_name (symbol_name_copy);
  481. #endif
  482. /* Initialize the new symbol. */
  483. def_symbol_in_progress = symbol_make (symbol_name_copy);
  484. symbol_set_frag (def_symbol_in_progress, &zero_address_frag);
  485. S_SET_VALUE (def_symbol_in_progress, 0);
  486. if (S_IS_STRING (def_symbol_in_progress))
  487. SF_SET_STRING (def_symbol_in_progress);
  488. (void) restore_line_pointer (name_end);
  489. demand_empty_rest_of_line ();
  490. }
  491. static void
  492. obj_coff_endef (int ignore ATTRIBUTE_UNUSED)
  493. {
  494. symbolS *symbolP = NULL;
  495. if (def_symbol_in_progress == NULL)
  496. {
  497. as_warn (_(".endef pseudo-op used outside of .def/.endef: ignored."));
  498. demand_empty_rest_of_line ();
  499. return;
  500. }
  501. /* Set the section number according to storage class. */
  502. switch (S_GET_STORAGE_CLASS (def_symbol_in_progress))
  503. {
  504. case C_STRTAG:
  505. case C_ENTAG:
  506. case C_UNTAG:
  507. SF_SET_TAG (def_symbol_in_progress);
  508. /* Fall through. */
  509. case C_FILE:
  510. case C_TPDEF:
  511. SF_SET_DEBUG (def_symbol_in_progress);
  512. S_SET_SEGMENT (def_symbol_in_progress, fetch_coff_debug_section ());
  513. break;
  514. case C_EFCN:
  515. SF_SET_LOCAL (def_symbol_in_progress); /* Do not emit this symbol. */
  516. /* Fall through. */
  517. case C_BLOCK:
  518. SF_SET_PROCESS (def_symbol_in_progress); /* Will need processing before writing. */
  519. /* Fall through. */
  520. case C_FCN:
  521. {
  522. const char *name;
  523. S_SET_SEGMENT (def_symbol_in_progress, text_section);
  524. name = S_GET_NAME (def_symbol_in_progress);
  525. if (name[0] == '.' && name[2] == 'f' && name[3] == '\0')
  526. {
  527. switch (name[1])
  528. {
  529. case 'b':
  530. /* .bf */
  531. if (! in_function ())
  532. as_warn (_("`%s' symbol without preceding function"), name);
  533. /* Will need relocating. */
  534. SF_SET_PROCESS (def_symbol_in_progress);
  535. clear_function ();
  536. break;
  537. #ifdef TE_PE
  538. case 'e':
  539. /* .ef */
  540. /* The MS compilers output the actual endline, not the
  541. function-relative one... we want to match without
  542. changing the assembler input. */
  543. SA_SET_SYM_LNNO (def_symbol_in_progress,
  544. (SA_GET_SYM_LNNO (def_symbol_in_progress)
  545. + coff_line_base));
  546. break;
  547. #endif
  548. }
  549. }
  550. }
  551. break;
  552. #ifdef C_AUTOARG
  553. case C_AUTOARG:
  554. #endif /* C_AUTOARG */
  555. case C_AUTO:
  556. case C_REG:
  557. case C_ARG:
  558. case C_REGPARM:
  559. case C_FIELD:
  560. /* According to the COFF documentation:
  561. http://osr5doc.sco.com:1996/topics/COFF_SectNumFld.html
  562. A special section number (-2) marks symbolic debugging symbols,
  563. including structure/union/enumeration tag names, typedefs, and
  564. the name of the file. A section number of -1 indicates that the
  565. symbol has a value but is not relocatable. Examples of
  566. absolute-valued symbols include automatic and register variables,
  567. function arguments, and .eos symbols.
  568. But from Ian Lance Taylor:
  569. http://sources.redhat.com/ml/binutils/2000-08/msg00202.html
  570. the actual tools all marked them as section -1. So the GNU COFF
  571. assembler follows historical COFF assemblers.
  572. However, it causes problems for djgpp
  573. http://sources.redhat.com/ml/binutils/2000-08/msg00210.html
  574. By defining STRICTCOFF, a COFF port can make the assembler to
  575. follow the documented behavior. */
  576. #ifdef STRICTCOFF
  577. case C_MOS:
  578. case C_MOE:
  579. case C_MOU:
  580. case C_EOS:
  581. #endif
  582. SF_SET_DEBUG (def_symbol_in_progress);
  583. S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
  584. break;
  585. #ifndef STRICTCOFF
  586. case C_MOS:
  587. case C_MOE:
  588. case C_MOU:
  589. case C_EOS:
  590. S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
  591. break;
  592. #endif
  593. case C_EXT:
  594. case C_WEAKEXT:
  595. #ifdef TE_PE
  596. case C_NT_WEAK:
  597. #endif
  598. case C_STAT:
  599. case C_LABEL:
  600. /* Valid but set somewhere else (s_comm, s_lcomm, colon). */
  601. break;
  602. default:
  603. case C_USTATIC:
  604. case C_EXTDEF:
  605. case C_ULABEL:
  606. as_warn (_("unexpected storage class %d"),
  607. S_GET_STORAGE_CLASS (def_symbol_in_progress));
  608. break;
  609. }
  610. /* Now that we have built a debug symbol, try to find if we should
  611. merge with an existing symbol or not. If a symbol is C_EFCN or
  612. absolute_section or untagged SEG_DEBUG it never merges. We also
  613. don't merge labels, which are in a different namespace, nor
  614. symbols which have not yet been defined since they are typically
  615. unique, nor do we merge tags with non-tags. */
  616. /* Two cases for functions. Either debug followed by definition or
  617. definition followed by debug. For definition first, we will
  618. merge the debug symbol into the definition. For debug first, the
  619. lineno entry MUST point to the definition function or else it
  620. will point off into space when obj_crawl_symbol_chain() merges
  621. the debug symbol into the real symbol. Therefor, let's presume
  622. the debug symbol is a real function reference. */
  623. /* FIXME-SOON If for some reason the definition label/symbol is
  624. never seen, this will probably leave an undefined symbol at link
  625. time. */
  626. if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN
  627. || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_LABEL
  628. || (streq (bfd_section_name (S_GET_SEGMENT (def_symbol_in_progress)),
  629. "*DEBUG*")
  630. && !SF_GET_TAG (def_symbol_in_progress))
  631. || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section
  632. || ! symbol_constant_p (def_symbol_in_progress)
  633. || (symbolP = symbol_find (S_GET_NAME (def_symbol_in_progress))) == NULL
  634. || SF_GET_TAG (def_symbol_in_progress) != SF_GET_TAG (symbolP))
  635. {
  636. /* If it already is at the end of the symbol list, do nothing */
  637. if (def_symbol_in_progress != symbol_lastP)
  638. {
  639. symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
  640. symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP,
  641. &symbol_lastP);
  642. }
  643. }
  644. else
  645. {
  646. /* This symbol already exists, merge the newly created symbol
  647. into the old one. This is not mandatory. The linker can
  648. handle duplicate symbols correctly. But I guess that it save
  649. a *lot* of space if the assembly file defines a lot of
  650. symbols. [loic] */
  651. /* The debug entry (def_symbol_in_progress) is merged into the
  652. previous definition. */
  653. c_symbol_merge (def_symbol_in_progress, symbolP);
  654. symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
  655. def_symbol_in_progress = symbolP;
  656. if (SF_GET_FUNCTION (def_symbol_in_progress)
  657. || SF_GET_TAG (def_symbol_in_progress)
  658. || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_STAT)
  659. {
  660. /* For functions, and tags, and static symbols, the symbol
  661. *must* be where the debug symbol appears. Move the
  662. existing symbol to the current place. */
  663. /* If it already is at the end of the symbol list, do nothing. */
  664. if (def_symbol_in_progress != symbol_lastP)
  665. {
  666. symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
  667. symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
  668. }
  669. }
  670. }
  671. if (SF_GET_TAG (def_symbol_in_progress))
  672. {
  673. symbolS *oldtag;
  674. oldtag = symbol_find (S_GET_NAME (def_symbol_in_progress));
  675. if (oldtag == NULL || ! SF_GET_TAG (oldtag))
  676. tag_insert (S_GET_NAME (def_symbol_in_progress),
  677. def_symbol_in_progress);
  678. }
  679. if (SF_GET_FUNCTION (def_symbol_in_progress))
  680. {
  681. set_function (def_symbol_in_progress);
  682. SF_SET_PROCESS (def_symbol_in_progress);
  683. if (symbolP == NULL)
  684. /* That is, if this is the first time we've seen the
  685. function. */
  686. symbol_table_insert (def_symbol_in_progress);
  687. }
  688. def_symbol_in_progress = NULL;
  689. demand_empty_rest_of_line ();
  690. }
  691. static void
  692. obj_coff_dim (int ignore ATTRIBUTE_UNUSED)
  693. {
  694. int d_index;
  695. if (def_symbol_in_progress == NULL)
  696. {
  697. as_warn (_(".dim pseudo-op used outside of .def/.endef: ignored."));
  698. demand_empty_rest_of_line ();
  699. return;
  700. }
  701. S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
  702. for (d_index = 0; d_index < DIMNUM; d_index++)
  703. {
  704. SKIP_WHITESPACES ();
  705. SA_SET_SYM_DIMEN (def_symbol_in_progress, d_index,
  706. get_absolute_expression ());
  707. switch (*input_line_pointer)
  708. {
  709. case ',':
  710. input_line_pointer++;
  711. break;
  712. default:
  713. as_warn (_("badly formed .dim directive ignored"));
  714. /* Fall through. */
  715. case '\n':
  716. case ';':
  717. d_index = DIMNUM;
  718. break;
  719. }
  720. }
  721. demand_empty_rest_of_line ();
  722. }
  723. static void
  724. obj_coff_line (int ignore ATTRIBUTE_UNUSED)
  725. {
  726. int this_base;
  727. if (def_symbol_in_progress == NULL)
  728. {
  729. /* Probably stabs-style line? */
  730. obj_coff_ln (0);
  731. return;
  732. }
  733. this_base = get_absolute_expression ();
  734. if (streq (".bf", S_GET_NAME (def_symbol_in_progress)))
  735. coff_line_base = this_base;
  736. S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
  737. SA_SET_SYM_LNNO (def_symbol_in_progress, this_base);
  738. demand_empty_rest_of_line ();
  739. #ifndef NO_LISTING
  740. if (streq (".bf", S_GET_NAME (def_symbol_in_progress)))
  741. {
  742. extern int listing;
  743. if (listing)
  744. listing_source_line ((unsigned int) this_base);
  745. }
  746. #endif
  747. }
  748. static void
  749. obj_coff_size (int ignore ATTRIBUTE_UNUSED)
  750. {
  751. if (def_symbol_in_progress == NULL)
  752. {
  753. as_warn (_(".size pseudo-op used outside of .def/.endef: ignored."));
  754. demand_empty_rest_of_line ();
  755. return;
  756. }
  757. S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
  758. SA_SET_SYM_SIZE (def_symbol_in_progress, get_absolute_expression ());
  759. demand_empty_rest_of_line ();
  760. }
  761. static void
  762. obj_coff_scl (int ignore ATTRIBUTE_UNUSED)
  763. {
  764. if (def_symbol_in_progress == NULL)
  765. {
  766. as_warn (_(".scl pseudo-op used outside of .def/.endef: ignored."));
  767. demand_empty_rest_of_line ();
  768. return;
  769. }
  770. S_SET_STORAGE_CLASS (def_symbol_in_progress, get_absolute_expression ());
  771. demand_empty_rest_of_line ();
  772. }
  773. static void
  774. obj_coff_tag (int ignore ATTRIBUTE_UNUSED)
  775. {
  776. char *symbol_name;
  777. char name_end;
  778. if (def_symbol_in_progress == NULL)
  779. {
  780. as_warn (_(".tag pseudo-op used outside of .def/.endef: ignored."));
  781. demand_empty_rest_of_line ();
  782. return;
  783. }
  784. S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
  785. name_end = get_symbol_name (&symbol_name);
  786. #ifdef tc_canonicalize_symbol_name
  787. symbol_name = tc_canonicalize_symbol_name (symbol_name);
  788. #endif
  789. /* Assume that the symbol referred to by .tag is always defined.
  790. This was a bad assumption. I've added find_or_make. xoxorich. */
  791. SA_SET_SYM_TAGNDX (def_symbol_in_progress,
  792. tag_find_or_make (symbol_name));
  793. if (SA_GET_SYM_TAGNDX (def_symbol_in_progress) == 0L)
  794. as_warn (_("tag not found for .tag %s"), symbol_name);
  795. SF_SET_TAGGED (def_symbol_in_progress);
  796. (void) restore_line_pointer (name_end);
  797. demand_empty_rest_of_line ();
  798. }
  799. static void
  800. obj_coff_type (int ignore ATTRIBUTE_UNUSED)
  801. {
  802. if (def_symbol_in_progress == NULL)
  803. {
  804. as_warn (_(".type pseudo-op used outside of .def/.endef: ignored."));
  805. demand_empty_rest_of_line ();
  806. return;
  807. }
  808. S_SET_DATA_TYPE (def_symbol_in_progress, get_absolute_expression ());
  809. if (ISFCN (S_GET_DATA_TYPE (def_symbol_in_progress)) &&
  810. S_GET_STORAGE_CLASS (def_symbol_in_progress) != C_TPDEF)
  811. SF_SET_FUNCTION (def_symbol_in_progress);
  812. demand_empty_rest_of_line ();
  813. }
  814. static void
  815. obj_coff_val (int ignore ATTRIBUTE_UNUSED)
  816. {
  817. if (def_symbol_in_progress == NULL)
  818. {
  819. as_warn (_(".val pseudo-op used outside of .def/.endef: ignored."));
  820. demand_empty_rest_of_line ();
  821. return;
  822. }
  823. if (is_name_beginner (*input_line_pointer))
  824. {
  825. char *symbol_name;
  826. char name_end = get_symbol_name (&symbol_name);
  827. #ifdef tc_canonicalize_symbol_name
  828. symbol_name = tc_canonicalize_symbol_name (symbol_name);
  829. #endif
  830. if (streq (symbol_name, "."))
  831. {
  832. /* If the .val is != from the .def (e.g. statics). */
  833. symbol_set_frag (def_symbol_in_progress, frag_now);
  834. S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
  835. }
  836. else if (! streq (S_GET_NAME (def_symbol_in_progress), symbol_name))
  837. {
  838. expressionS exp;
  839. exp.X_op = O_symbol;
  840. exp.X_add_symbol = symbol_find_or_make (symbol_name);
  841. exp.X_op_symbol = NULL;
  842. exp.X_add_number = 0;
  843. symbol_set_value_expression (def_symbol_in_progress, &exp);
  844. /* If the segment is undefined when the forward reference is
  845. resolved, then copy the segment id from the forward
  846. symbol. */
  847. SF_SET_GET_SEGMENT (def_symbol_in_progress);
  848. /* FIXME: gcc can generate address expressions here in
  849. unusual cases (search for "obscure" in sdbout.c). We
  850. just ignore the offset here, thus generating incorrect
  851. debugging information. We ignore the rest of the line
  852. just below. */
  853. }
  854. /* Otherwise, it is the name of a non debug symbol and its value
  855. will be calculated later. */
  856. (void) restore_line_pointer (name_end);
  857. }
  858. else
  859. {
  860. S_SET_VALUE (def_symbol_in_progress, get_absolute_expression ());
  861. }
  862. demand_empty_rest_of_line ();
  863. }
  864. #ifdef TE_PE
  865. /* Return nonzero if name begins with weak alternate symbol prefix. */
  866. static int
  867. weak_is_altname (const char * name)
  868. {
  869. return startswith (name, weak_altprefix);
  870. }
  871. /* Return the name of the alternate symbol
  872. name corresponding to a weak symbol's name. */
  873. static const char *
  874. weak_name2altname (const char * name)
  875. {
  876. return concat (weak_altprefix, name, (char *) NULL);
  877. }
  878. /* Return the name of the weak symbol corresponding to an
  879. alternate symbol. */
  880. static const char *
  881. weak_altname2name (const char * name)
  882. {
  883. gas_assert (weak_is_altname (name));
  884. return xstrdup (name + 6);
  885. }
  886. /* Make a weak symbol name unique by
  887. appending the name of an external symbol. */
  888. static const char *
  889. weak_uniquify (const char * name)
  890. {
  891. const char * unique = "";
  892. #ifdef TE_PE
  893. if (an_external_name != NULL)
  894. unique = an_external_name;
  895. #endif
  896. gas_assert (weak_is_altname (name));
  897. return concat (name, ".", unique, (char *) NULL);
  898. }
  899. void
  900. pecoff_obj_set_weak_hook (symbolS *symbolP)
  901. {
  902. symbolS *alternateP;
  903. /* See _Microsoft Portable Executable and Common Object
  904. File Format Specification_, section 5.5.3.
  905. Create a symbol representing the alternate value.
  906. coff_frob_symbol will set the value of this symbol from
  907. the value of the weak symbol itself. */
  908. S_SET_STORAGE_CLASS (symbolP, C_NT_WEAK);
  909. S_SET_NUMBER_AUXILIARY (symbolP, 1);
  910. SA_SET_SYM_FSIZE (symbolP, IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY);
  911. alternateP = symbol_find_or_make (weak_name2altname (S_GET_NAME (symbolP)));
  912. S_SET_EXTERNAL (alternateP);
  913. S_SET_STORAGE_CLASS (alternateP, C_NT_WEAK);
  914. SA_SET_SYM_TAGNDX (symbolP, alternateP);
  915. }
  916. void
  917. pecoff_obj_clear_weak_hook (symbolS *symbolP)
  918. {
  919. symbolS *alternateP;
  920. S_SET_STORAGE_CLASS (symbolP, 0);
  921. SA_SET_SYM_FSIZE (symbolP, 0);
  922. alternateP = symbol_find (weak_name2altname (S_GET_NAME (symbolP)));
  923. S_CLEAR_EXTERNAL (alternateP);
  924. }
  925. #endif /* TE_PE */
  926. /* Handle .weak. This is a GNU extension in formats other than PE. */
  927. static void
  928. obj_coff_weak (int ignore ATTRIBUTE_UNUSED)
  929. {
  930. char *name;
  931. int c;
  932. symbolS *symbolP;
  933. do
  934. {
  935. c = get_symbol_name (&name);
  936. if (*name == 0)
  937. {
  938. as_warn (_("badly formed .weak directive ignored"));
  939. ignore_rest_of_line ();
  940. return;
  941. }
  942. c = 0;
  943. symbolP = symbol_find_or_make (name);
  944. *input_line_pointer = c;
  945. SKIP_WHITESPACE_AFTER_NAME ();
  946. S_SET_WEAK (symbolP);
  947. if (c == ',')
  948. {
  949. input_line_pointer++;
  950. SKIP_WHITESPACE ();
  951. if (*input_line_pointer == '\n')
  952. c = '\n';
  953. }
  954. }
  955. while (c == ',');
  956. demand_empty_rest_of_line ();
  957. }
  958. void
  959. coff_obj_read_begin_hook (void)
  960. {
  961. /* These had better be the same. Usually 18 bytes. */
  962. know (sizeof (SYMENT) == sizeof (AUXENT));
  963. know (SYMESZ == AUXESZ);
  964. tag_init ();
  965. }
  966. symbolS *coff_last_function;
  967. #ifndef OBJ_XCOFF
  968. static symbolS *coff_last_bf;
  969. #endif
  970. void
  971. coff_frob_symbol (symbolS *symp, int *punt)
  972. {
  973. static symbolS *last_tagP;
  974. static stack *block_stack;
  975. static symbolS *set_end;
  976. symbolS *next_set_end = NULL;
  977. if (symp == &abs_symbol)
  978. {
  979. *punt = 1;
  980. return;
  981. }
  982. if (current_lineno_sym)
  983. coff_add_linesym (NULL);
  984. if (!block_stack)
  985. block_stack = stack_init (512, sizeof (symbolS*));
  986. #ifdef TE_PE
  987. if (S_GET_STORAGE_CLASS (symp) == C_NT_WEAK
  988. && ! S_IS_WEAK (symp)
  989. && weak_is_altname (S_GET_NAME (symp)))
  990. {
  991. /* This is a weak alternate symbol. All processing of
  992. PECOFFweak symbols is done here, through the alternate. */
  993. symbolS *weakp = symbol_find_noref (weak_altname2name
  994. (S_GET_NAME (symp)), 1);
  995. gas_assert (weakp);
  996. gas_assert (S_GET_NUMBER_AUXILIARY (weakp) == 1);
  997. if (! S_IS_WEAK (weakp))
  998. {
  999. /* The symbol was turned from weak to strong. Discard altname. */
  1000. *punt = 1;
  1001. return;
  1002. }
  1003. else if (symbol_equated_p (weakp))
  1004. {
  1005. /* The weak symbol has an alternate specified; symp is unneeded. */
  1006. S_SET_STORAGE_CLASS (weakp, C_NT_WEAK);
  1007. SA_SET_SYM_TAGNDX (weakp,
  1008. symbol_get_value_expression (weakp)->X_add_symbol);
  1009. S_CLEAR_EXTERNAL (symp);
  1010. *punt = 1;
  1011. return;
  1012. }
  1013. else
  1014. {
  1015. /* The weak symbol has been assigned an alternate value.
  1016. Copy this value to symp, and set symp as weakp's alternate. */
  1017. if (S_GET_STORAGE_CLASS (weakp) != C_NT_WEAK)
  1018. {
  1019. S_SET_STORAGE_CLASS (symp, S_GET_STORAGE_CLASS (weakp));
  1020. S_SET_STORAGE_CLASS (weakp, C_NT_WEAK);
  1021. }
  1022. if (S_IS_DEFINED (weakp))
  1023. {
  1024. /* This is a defined weak symbol. Copy value information
  1025. from the weak symbol itself to the alternate symbol. */
  1026. symbol_set_value_expression (symp,
  1027. symbol_get_value_expression (weakp));
  1028. symbol_set_frag (symp, symbol_get_frag (weakp));
  1029. S_SET_SEGMENT (symp, S_GET_SEGMENT (weakp));
  1030. }
  1031. else
  1032. {
  1033. /* This is an undefined weak symbol.
  1034. Define the alternate symbol to zero. */
  1035. S_SET_VALUE (symp, 0);
  1036. S_SET_SEGMENT (symp, absolute_section);
  1037. }
  1038. S_SET_NAME (symp, weak_uniquify (S_GET_NAME (symp)));
  1039. S_SET_STORAGE_CLASS (symp, C_EXT);
  1040. S_SET_VALUE (weakp, 0);
  1041. S_SET_SEGMENT (weakp, undefined_section);
  1042. }
  1043. }
  1044. #else /* TE_PE */
  1045. if (S_IS_WEAK (symp))
  1046. S_SET_STORAGE_CLASS (symp, C_WEAKEXT);
  1047. #endif /* TE_PE */
  1048. if (!S_IS_DEFINED (symp)
  1049. && !S_IS_WEAK (symp)
  1050. && S_GET_STORAGE_CLASS (symp) != C_STAT)
  1051. S_SET_STORAGE_CLASS (symp, C_EXT);
  1052. if (!SF_GET_DEBUG (symp))
  1053. {
  1054. symbolS * real;
  1055. if (!SF_GET_LOCAL (symp)
  1056. && !SF_GET_STATICS (symp)
  1057. && S_GET_STORAGE_CLASS (symp) != C_LABEL
  1058. && symbol_constant_p (symp)
  1059. && (real = symbol_find_noref (S_GET_NAME (symp), 1))
  1060. && S_GET_STORAGE_CLASS (real) == C_NULL
  1061. && real != symp)
  1062. {
  1063. c_symbol_merge (symp, real);
  1064. *punt = 1;
  1065. return;
  1066. }
  1067. if (!S_IS_DEFINED (symp) && !SF_GET_LOCAL (symp))
  1068. {
  1069. gas_assert (S_GET_VALUE (symp) == 0);
  1070. if (S_IS_WEAKREFD (symp))
  1071. *punt = 1;
  1072. else
  1073. S_SET_EXTERNAL (symp);
  1074. }
  1075. else if (S_GET_STORAGE_CLASS (symp) == C_NULL)
  1076. {
  1077. if (S_GET_SEGMENT (symp) == text_section
  1078. && symp != seg_info (text_section)->sym)
  1079. S_SET_STORAGE_CLASS (symp, C_LABEL);
  1080. else
  1081. S_SET_STORAGE_CLASS (symp, C_STAT);
  1082. }
  1083. if (SF_GET_PROCESS (symp))
  1084. {
  1085. if (S_GET_STORAGE_CLASS (symp) == C_BLOCK)
  1086. {
  1087. if (streq (S_GET_NAME (symp), ".bb"))
  1088. stack_push (block_stack, (char *) &symp);
  1089. else
  1090. {
  1091. symbolS *begin;
  1092. begin = *(symbolS **) stack_pop (block_stack);
  1093. if (begin == 0)
  1094. as_warn (_("mismatched .eb"));
  1095. else
  1096. next_set_end = begin;
  1097. }
  1098. }
  1099. if (coff_last_function == 0 && SF_GET_FUNCTION (symp)
  1100. && S_IS_DEFINED (symp))
  1101. {
  1102. union internal_auxent *auxp;
  1103. coff_last_function = symp;
  1104. if (S_GET_NUMBER_AUXILIARY (symp) < 1)
  1105. S_SET_NUMBER_AUXILIARY (symp, 1);
  1106. auxp = SYM_AUXENT (symp);
  1107. memset (auxp->x_sym.x_fcnary.x_ary.x_dimen, 0,
  1108. sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen));
  1109. }
  1110. if (S_GET_STORAGE_CLASS (symp) == C_EFCN
  1111. && S_IS_DEFINED (symp))
  1112. {
  1113. if (coff_last_function == 0)
  1114. as_fatal (_("C_EFCN symbol for %s out of scope"),
  1115. S_GET_NAME (symp));
  1116. SA_SET_SYM_FSIZE (coff_last_function,
  1117. (long) (S_GET_VALUE (symp)
  1118. - S_GET_VALUE (coff_last_function)));
  1119. next_set_end = coff_last_function;
  1120. coff_last_function = 0;
  1121. }
  1122. }
  1123. if (S_IS_EXTERNAL (symp))
  1124. S_SET_STORAGE_CLASS (symp, C_EXT);
  1125. else if (SF_GET_LOCAL (symp))
  1126. *punt = 1;
  1127. if (SF_GET_FUNCTION (symp))
  1128. symbol_get_bfdsym (symp)->flags |= BSF_FUNCTION;
  1129. }
  1130. /* Double check weak symbols. */
  1131. if (S_IS_WEAK (symp) && S_IS_COMMON (symp))
  1132. as_bad (_("Symbol `%s' can not be both weak and common"),
  1133. S_GET_NAME (symp));
  1134. if (SF_GET_TAG (symp))
  1135. last_tagP = symp;
  1136. else if (S_GET_STORAGE_CLASS (symp) == C_EOS)
  1137. next_set_end = last_tagP;
  1138. #ifdef OBJ_XCOFF
  1139. /* This is pretty horrible, but we have to set *punt correctly in
  1140. order to call SA_SET_SYM_ENDNDX correctly. */
  1141. if (! symbol_used_in_reloc_p (symp)
  1142. && S_GET_STORAGE_CLASS (symp) != C_DWARF
  1143. && ((symbol_get_bfdsym (symp)->flags & BSF_SECTION_SYM) != 0
  1144. || (! (S_IS_EXTERNAL (symp) || S_IS_WEAK (symp))
  1145. && ! symbol_get_tc (symp)->output
  1146. && S_GET_STORAGE_CLASS (symp) != C_FILE)))
  1147. *punt = 1;
  1148. #endif
  1149. if (set_end != (symbolS *) NULL
  1150. && ! *punt
  1151. && ((symbol_get_bfdsym (symp)->flags & BSF_NOT_AT_END) != 0
  1152. || (S_IS_DEFINED (symp)
  1153. && ! S_IS_COMMON (symp)
  1154. && (! S_IS_EXTERNAL (symp) || SF_GET_FUNCTION (symp)))))
  1155. {
  1156. SA_SET_SYM_ENDNDX (set_end, symp);
  1157. set_end = NULL;
  1158. }
  1159. if (next_set_end != NULL)
  1160. {
  1161. if (set_end != NULL)
  1162. as_warn (_("Warning: internal error: forgetting to set endndx of %s"),
  1163. S_GET_NAME (set_end));
  1164. set_end = next_set_end;
  1165. }
  1166. #ifndef OBJ_XCOFF
  1167. if (! *punt
  1168. && S_GET_STORAGE_CLASS (symp) == C_FCN
  1169. && streq (S_GET_NAME (symp), ".bf"))
  1170. {
  1171. if (coff_last_bf != NULL)
  1172. SA_SET_SYM_ENDNDX (coff_last_bf, symp);
  1173. coff_last_bf = symp;
  1174. }
  1175. #endif
  1176. if (coffsymbol (symbol_get_bfdsym (symp))->lineno)
  1177. {
  1178. int i;
  1179. struct line_no *lptr;
  1180. alent *l;
  1181. lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno;
  1182. for (i = 0; lptr; lptr = lptr->next)
  1183. i++;
  1184. lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno;
  1185. /* We need i entries for line numbers, plus 1 for the first
  1186. entry which BFD will override, plus 1 for the last zero
  1187. entry (a marker for BFD). */
  1188. l = XNEWVEC (alent, (i + 2));
  1189. coffsymbol (symbol_get_bfdsym (symp))->lineno = l;
  1190. l[i + 1].line_number = 0;
  1191. l[i + 1].u.sym = NULL;
  1192. for (; i > 0; i--)
  1193. {
  1194. if (lptr->frag)
  1195. lptr->l.u.offset += lptr->frag->fr_address / OCTETS_PER_BYTE;
  1196. l[i] = lptr->l;
  1197. lptr = lptr->next;
  1198. }
  1199. }
  1200. }
  1201. void
  1202. coff_adjust_section_syms (bfd *abfd ATTRIBUTE_UNUSED,
  1203. asection *sec,
  1204. void * x ATTRIBUTE_UNUSED)
  1205. {
  1206. symbolS *secsym;
  1207. segment_info_type *seginfo = seg_info (sec);
  1208. int nlnno, nrelocs = 0;
  1209. /* RS/6000 gas creates a .debug section manually in ppc_frob_file in
  1210. tc-ppc.c. Do not get confused by it. */
  1211. if (seginfo == NULL)
  1212. return;
  1213. if (streq (sec->name, ".text"))
  1214. nlnno = coff_n_line_nos;
  1215. else
  1216. nlnno = 0;
  1217. {
  1218. /* @@ Hope that none of the fixups expand to more than one reloc
  1219. entry... */
  1220. fixS *fixp = seginfo->fix_root;
  1221. while (fixp)
  1222. {
  1223. if (! fixp->fx_done)
  1224. nrelocs++;
  1225. fixp = fixp->fx_next;
  1226. }
  1227. }
  1228. if (bfd_section_size (sec) == 0
  1229. && nrelocs == 0
  1230. && nlnno == 0
  1231. && sec != text_section
  1232. && sec != data_section
  1233. && sec != bss_section)
  1234. return;
  1235. secsym = section_symbol (sec);
  1236. /* This is an estimate; we'll plug in the real value using
  1237. SET_SECTION_RELOCS later */
  1238. #ifdef OBJ_XCOFF
  1239. if (S_GET_STORAGE_CLASS (secsym) == C_DWARF)
  1240. SA_SET_SECT_NRELOC (secsym, nrelocs);
  1241. else
  1242. {
  1243. SA_SET_SCN_NRELOC (secsym, nrelocs);
  1244. SA_SET_SCN_NLINNO (secsym, nlnno);
  1245. }
  1246. #else
  1247. SA_SET_SCN_NRELOC (secsym, nrelocs);
  1248. SA_SET_SCN_NLINNO (secsym, nlnno);
  1249. #endif
  1250. }
  1251. void
  1252. coff_frob_file_after_relocs (void)
  1253. {
  1254. bfd_map_over_sections (stdoutput, coff_adjust_section_syms, NULL);
  1255. }
  1256. /* Implement the .section pseudo op:
  1257. .section name {, "flags"}
  1258. ^ ^
  1259. | +--- optional flags: 'b' for bss
  1260. | 'i' for info
  1261. +-- section name 'l' for lib
  1262. 'n' for noload
  1263. 'o' for over
  1264. 'w' for data
  1265. 'd' (apparently m88k for data)
  1266. 'e' for exclude
  1267. 'x' for text
  1268. 'r' for read-only data
  1269. 's' for shared data (PE)
  1270. 'y' for noread
  1271. '0' - '9' for power-of-two alignment (GNU extension).
  1272. But if the argument is not a quoted string, treat it as a
  1273. subsegment number.
  1274. Note the 'a' flag is silently ignored. This allows the same
  1275. .section directive to be parsed in both ELF and COFF formats. */
  1276. void
  1277. obj_coff_section (int ignore ATTRIBUTE_UNUSED)
  1278. {
  1279. /* Strip out the section name. */
  1280. char *section_name;
  1281. char c;
  1282. int alignment = -1;
  1283. char *name;
  1284. unsigned int exp;
  1285. flagword flags, oldflags;
  1286. asection *sec;
  1287. bool is_bss = false;
  1288. if (flag_mri)
  1289. {
  1290. char type;
  1291. s_mri_sect (&type);
  1292. return;
  1293. }
  1294. c = get_symbol_name (&section_name);
  1295. name = xmemdup0 (section_name, input_line_pointer - section_name);
  1296. *input_line_pointer = c;
  1297. SKIP_WHITESPACE_AFTER_NAME ();
  1298. exp = 0;
  1299. flags = SEC_NO_FLAGS;
  1300. if (*input_line_pointer == ',')
  1301. {
  1302. ++input_line_pointer;
  1303. SKIP_WHITESPACE ();
  1304. if (*input_line_pointer != '"')
  1305. exp = get_absolute_expression ();
  1306. else
  1307. {
  1308. unsigned char attr;
  1309. int readonly_removed = 0;
  1310. int load_removed = 0;
  1311. while (attr = *++input_line_pointer,
  1312. attr != '"'
  1313. && ! is_end_of_line[attr])
  1314. {
  1315. if (ISDIGIT (attr))
  1316. {
  1317. alignment = attr - '0';
  1318. continue;
  1319. }
  1320. switch (attr)
  1321. {
  1322. case 'e':
  1323. /* Exclude section from linking. */
  1324. flags |= SEC_EXCLUDE;
  1325. break;
  1326. case 'b':
  1327. /* Uninitialised data section. */
  1328. flags |= SEC_ALLOC;
  1329. flags &=~ SEC_LOAD;
  1330. is_bss = true;
  1331. break;
  1332. case 'n':
  1333. /* Section not loaded. */
  1334. flags &=~ SEC_LOAD;
  1335. flags |= SEC_NEVER_LOAD;
  1336. load_removed = 1;
  1337. break;
  1338. case 's':
  1339. /* Shared section. */
  1340. flags |= SEC_COFF_SHARED;
  1341. /* Fall through. */
  1342. case 'd':
  1343. /* Data section. */
  1344. flags |= SEC_DATA;
  1345. if (! load_removed)
  1346. flags |= SEC_LOAD;
  1347. flags &=~ SEC_READONLY;
  1348. break;
  1349. case 'w':
  1350. /* Writable section. */
  1351. flags &=~ SEC_READONLY;
  1352. readonly_removed = 1;
  1353. break;
  1354. case 'a':
  1355. /* Ignore. Here for compatibility with ELF. */
  1356. break;
  1357. case 'r': /* Read-only section. Implies a data section. */
  1358. readonly_removed = 0;
  1359. /* Fall through. */
  1360. case 'x': /* Executable section. */
  1361. /* If we are setting the 'x' attribute or if the 'r'
  1362. attribute is being used to restore the readonly status
  1363. of a code section (eg "wxr") then set the SEC_CODE flag,
  1364. otherwise set the SEC_DATA flag. */
  1365. flags |= (attr == 'x' || (flags & SEC_CODE) ? SEC_CODE : SEC_DATA);
  1366. if (! load_removed)
  1367. flags |= SEC_LOAD;
  1368. /* Note - the READONLY flag is set here, even for the 'x'
  1369. attribute in order to be compatible with the MSVC
  1370. linker. */
  1371. if (! readonly_removed)
  1372. flags |= SEC_READONLY;
  1373. break;
  1374. case 'y':
  1375. flags |= SEC_COFF_NOREAD | SEC_READONLY;
  1376. break;
  1377. case 'i': /* STYP_INFO */
  1378. case 'l': /* STYP_LIB */
  1379. case 'o': /* STYP_OVER */
  1380. as_warn (_("unsupported section attribute '%c'"), attr);
  1381. break;
  1382. default:
  1383. as_warn (_("unknown section attribute '%c'"), attr);
  1384. break;
  1385. }
  1386. }
  1387. if (attr == '"')
  1388. ++input_line_pointer;
  1389. }
  1390. }
  1391. sec = subseg_new (name, (subsegT) exp);
  1392. if (is_bss)
  1393. seg_info (sec)->bss = 1;
  1394. if (alignment >= 0)
  1395. sec->alignment_power = alignment;
  1396. oldflags = bfd_section_flags (sec);
  1397. if (oldflags == SEC_NO_FLAGS)
  1398. {
  1399. /* Set section flags for a new section just created by subseg_new.
  1400. Provide a default if no flags were parsed. */
  1401. if (flags == SEC_NO_FLAGS)
  1402. flags = TC_COFF_SECTION_DEFAULT_ATTRIBUTES;
  1403. #ifdef COFF_LONG_SECTION_NAMES
  1404. /* Add SEC_LINK_ONCE and SEC_LINK_DUPLICATES_DISCARD to .gnu.linkonce
  1405. sections so adjust_reloc_syms in write.c will correctly handle
  1406. relocs which refer to non-local symbols in these sections. */
  1407. if (startswith (name, ".gnu.linkonce"))
  1408. flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
  1409. #endif
  1410. if (!bfd_set_section_flags (sec, flags))
  1411. as_warn (_("error setting flags for \"%s\": %s"),
  1412. bfd_section_name (sec),
  1413. bfd_errmsg (bfd_get_error ()));
  1414. }
  1415. else if (flags != SEC_NO_FLAGS)
  1416. {
  1417. /* This section's attributes have already been set. Warn if the
  1418. attributes don't match. */
  1419. flagword matchflags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
  1420. | SEC_DATA | SEC_COFF_SHARED | SEC_NEVER_LOAD
  1421. | SEC_COFF_NOREAD);
  1422. if ((flags ^ oldflags) & matchflags)
  1423. as_warn (_("Ignoring changed section attributes for %s"), name);
  1424. }
  1425. demand_empty_rest_of_line ();
  1426. }
  1427. void
  1428. coff_adjust_symtab (void)
  1429. {
  1430. if (symbol_rootP == NULL
  1431. || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE)
  1432. c_dot_file_symbol ("fake", 0);
  1433. }
  1434. void
  1435. coff_frob_section (segT sec)
  1436. {
  1437. segT strsec;
  1438. char *p;
  1439. fragS *fragp;
  1440. bfd_vma n_entries;
  1441. /* The COFF back end in BFD requires that all section sizes be
  1442. rounded up to multiples of the corresponding section alignments,
  1443. supposedly because standard COFF has no other way of encoding alignment
  1444. for sections. If your COFF flavor has a different way of encoding
  1445. section alignment, then skip this step, as TICOFF does. */
  1446. bfd_vma size = bfd_section_size (sec);
  1447. #if !defined(TICOFF)
  1448. bfd_vma align_power = (bfd_vma) sec->alignment_power + OCTETS_PER_BYTE_POWER;
  1449. bfd_vma mask = ((bfd_vma) 1 << align_power) - 1;
  1450. if (size & mask)
  1451. {
  1452. bfd_vma new_size;
  1453. fragS *last;
  1454. new_size = (size + mask) & ~mask;
  1455. bfd_set_section_size (sec, new_size);
  1456. /* If the size had to be rounded up, add some padding in
  1457. the last non-empty frag. */
  1458. fragp = seg_info (sec)->frchainP->frch_root;
  1459. last = seg_info (sec)->frchainP->frch_last;
  1460. while (fragp->fr_next != last)
  1461. fragp = fragp->fr_next;
  1462. last->fr_address = size;
  1463. fragp->fr_offset += new_size - size;
  1464. }
  1465. #endif
  1466. /* If the section size is non-zero, the section symbol needs an aux
  1467. entry associated with it, indicating the size. We don't know
  1468. all the values yet; coff_frob_symbol will fill them in later. */
  1469. #ifndef TICOFF
  1470. if (size != 0
  1471. || sec == text_section
  1472. || sec == data_section
  1473. || sec == bss_section)
  1474. #endif
  1475. {
  1476. symbolS *secsym = section_symbol (sec);
  1477. unsigned char sclass = C_STAT;
  1478. #ifdef OBJ_XCOFF
  1479. if (bfd_section_flags (sec) & SEC_DEBUGGING)
  1480. sclass = C_DWARF;
  1481. #endif
  1482. S_SET_STORAGE_CLASS (secsym, sclass);
  1483. S_SET_NUMBER_AUXILIARY (secsym, 1);
  1484. SF_SET_STATICS (secsym);
  1485. #ifdef OBJ_XCOFF
  1486. SA_SET_SECT_SCNLEN (secsym, size);
  1487. #else
  1488. SA_SET_SCN_SCNLEN (secsym, size);
  1489. #endif
  1490. }
  1491. /* FIXME: These should be in a "stabs.h" file, or maybe as.h. */
  1492. #ifndef STAB_SECTION_NAME
  1493. #define STAB_SECTION_NAME ".stab"
  1494. #endif
  1495. #ifndef STAB_STRING_SECTION_NAME
  1496. #define STAB_STRING_SECTION_NAME ".stabstr"
  1497. #endif
  1498. if (! streq (STAB_STRING_SECTION_NAME, sec->name))
  1499. return;
  1500. strsec = sec;
  1501. sec = subseg_get (STAB_SECTION_NAME, 0);
  1502. /* size is already rounded up, since other section will be listed first */
  1503. size = bfd_section_size (strsec);
  1504. n_entries = bfd_section_size (sec) / 12 - 1;
  1505. /* Find first non-empty frag. It should be large enough. */
  1506. fragp = seg_info (sec)->frchainP->frch_root;
  1507. while (fragp && fragp->fr_fix == 0)
  1508. fragp = fragp->fr_next;
  1509. gas_assert (fragp != 0 && fragp->fr_fix >= 12);
  1510. /* Store the values. */
  1511. p = fragp->fr_literal;
  1512. bfd_h_put_16 (stdoutput, n_entries, (bfd_byte *) p + 6);
  1513. bfd_h_put_32 (stdoutput, size, (bfd_byte *) p + 8);
  1514. }
  1515. void
  1516. obj_coff_init_stab_section (segT seg)
  1517. {
  1518. const char *file;
  1519. char *p;
  1520. char *stabstr_name;
  1521. unsigned int stroff;
  1522. /* Make space for this first symbol. */
  1523. p = frag_more (12);
  1524. /* Zero it out. */
  1525. memset (p, 0, 12);
  1526. file = as_where ((unsigned int *) NULL);
  1527. stabstr_name = concat (seg->name, "str", (char *) NULL);
  1528. stroff = get_stab_string_offset (file, stabstr_name, true);
  1529. know (stroff == 1);
  1530. md_number_to_chars (p, stroff, 4);
  1531. }
  1532. #ifdef DEBUG
  1533. const char * s_get_name (symbolS *);
  1534. const char *
  1535. s_get_name (symbolS *s)
  1536. {
  1537. return ((s == NULL) ? "(NULL)" : S_GET_NAME (s));
  1538. }
  1539. void symbol_dump (void);
  1540. void
  1541. symbol_dump (void)
  1542. {
  1543. symbolS *symbolP;
  1544. for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
  1545. printf (_("0x%lx: \"%s\" type = %ld, class = %d, segment = %d\n"),
  1546. (unsigned long) symbolP,
  1547. S_GET_NAME (symbolP),
  1548. (long) S_GET_DATA_TYPE (symbolP),
  1549. S_GET_STORAGE_CLASS (symbolP),
  1550. (int) S_GET_SEGMENT (symbolP));
  1551. }
  1552. #endif /* DEBUG */
  1553. const pseudo_typeS coff_pseudo_table[] =
  1554. {
  1555. {"ABORT", s_abort, 0},
  1556. {"appline", obj_coff_ln, 1},
  1557. /* We accept the .bss directive for backward compatibility with
  1558. earlier versions of gas. */
  1559. {"bss", obj_coff_bss, 0},
  1560. #ifdef TE_PE
  1561. /* PE provides an enhanced version of .comm with alignment. */
  1562. {"comm", obj_coff_comm, 0},
  1563. #endif /* TE_PE */
  1564. {"def", obj_coff_def, 0},
  1565. {"dim", obj_coff_dim, 0},
  1566. {"endef", obj_coff_endef, 0},
  1567. {"ident", obj_coff_ident, 0},
  1568. {"line", obj_coff_line, 0},
  1569. {"ln", obj_coff_ln, 0},
  1570. {"scl", obj_coff_scl, 0},
  1571. {"sect", obj_coff_section, 0},
  1572. {"sect.s", obj_coff_section, 0},
  1573. {"section", obj_coff_section, 0},
  1574. {"section.s", obj_coff_section, 0},
  1575. /* FIXME: We ignore the MRI short attribute. */
  1576. {"size", obj_coff_size, 0},
  1577. {"tag", obj_coff_tag, 0},
  1578. {"type", obj_coff_type, 0},
  1579. {"val", obj_coff_val, 0},
  1580. {"version", s_ignore, 0},
  1581. {"loc", obj_coff_loc, 0},
  1582. {"optim", s_ignore, 0}, /* For sun386i cc (?) */
  1583. {"weak", obj_coff_weak, 0},
  1584. #if defined TC_TIC4X
  1585. /* The tic4x uses sdef instead of def. */
  1586. {"sdef", obj_coff_def, 0},
  1587. #endif
  1588. #if defined(SEH_CMDS)
  1589. SEH_CMDS
  1590. #endif
  1591. {NULL, NULL, 0}
  1592. };
  1593. /* Support for a COFF emulation. */
  1594. static void
  1595. coff_pop_insert (void)
  1596. {
  1597. pop_insert (coff_pseudo_table);
  1598. }
  1599. static int
  1600. coff_separate_stab_sections (void)
  1601. {
  1602. return 1;
  1603. }
  1604. const struct format_ops coff_format_ops =
  1605. {
  1606. bfd_target_coff_flavour,
  1607. 0, /* dfl_leading_underscore */
  1608. 1, /* emit_section_symbols */
  1609. 0, /* begin */
  1610. c_dot_file_symbol,
  1611. coff_frob_symbol,
  1612. 0, /* frob_file */
  1613. 0, /* frob_file_before_adjust */
  1614. 0, /* frob_file_before_fix */
  1615. coff_frob_file_after_relocs,
  1616. 0, /* s_get_size */
  1617. 0, /* s_set_size */
  1618. 0, /* s_get_align */
  1619. 0, /* s_set_align */
  1620. 0, /* s_get_other */
  1621. 0, /* s_set_other */
  1622. 0, /* s_get_desc */
  1623. 0, /* s_set_desc */
  1624. 0, /* s_get_type */
  1625. 0, /* s_set_type */
  1626. 0, /* copy_symbol_attributes */
  1627. 0, /* generate_asm_lineno */
  1628. 0, /* process_stab */
  1629. coff_separate_stab_sections,
  1630. obj_coff_init_stab_section,
  1631. 0, /* sec_sym_ok_for_reloc */
  1632. coff_pop_insert,
  1633. 0, /* ecoff_set_ext */
  1634. coff_obj_read_begin_hook,
  1635. coff_obj_symbol_new_hook,
  1636. coff_obj_symbol_clone_hook,
  1637. coff_adjust_symtab
  1638. };