dwarf2dbg.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957
  1. /* dwarf2dbg.c - DWARF2 debug support
  2. Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of GAS, the GNU Assembler.
  5. GAS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GAS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GAS; see the file COPYING. If not, write to the Free
  15. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  16. 02110-1301, USA. */
  17. /* Logical line numbers can be controlled by the compiler via the
  18. following directives:
  19. .file FILENO "file.c"
  20. .loc FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
  21. [epilogue_begin] [is_stmt VALUE] [isa VALUE] \
  22. [discriminator VALUE]
  23. */
  24. #include "as.h"
  25. #include "safe-ctype.h"
  26. #ifdef HAVE_LIMITS_H
  27. #include <limits.h>
  28. #else
  29. #ifdef HAVE_SYS_PARAM_H
  30. #include <sys/param.h>
  31. #endif
  32. #ifndef INT_MAX
  33. #define INT_MAX (int) (((unsigned) (-1)) >> 1)
  34. #endif
  35. #endif
  36. #include "dwarf2dbg.h"
  37. #include <filenames.h>
  38. #ifdef HAVE_DOS_BASED_FILE_SYSTEM
  39. /* We need to decide which character to use as a directory separator.
  40. Just because HAVE_DOS_BASED_FILE_SYSTEM is defined, it does not
  41. necessarily mean that the backslash character is the one to use.
  42. Some environments, eg Cygwin, can support both naming conventions.
  43. So we use the heuristic that we only need to use the backslash if
  44. the path is an absolute path starting with a DOS style drive
  45. selector. eg C: or D: */
  46. # define INSERT_DIR_SEPARATOR(string, offset) \
  47. do \
  48. { \
  49. if (offset > 1 \
  50. && string[0] != 0 \
  51. && string[1] == ':') \
  52. string [offset] = '\\'; \
  53. else \
  54. string [offset] = '/'; \
  55. } \
  56. while (0)
  57. #else
  58. # define INSERT_DIR_SEPARATOR(string, offset) string[offset] = '/'
  59. #endif
  60. #ifndef DWARF2_FORMAT
  61. # define DWARF2_FORMAT(SEC) dwarf2_format_32bit
  62. #endif
  63. #ifndef DWARF2_ADDR_SIZE
  64. # define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8)
  65. #endif
  66. #ifndef DWARF2_FILE_NAME
  67. #define DWARF2_FILE_NAME(FILENAME, DIRNAME) FILENAME
  68. #endif
  69. #ifndef DWARF2_FILE_TIME_NAME
  70. #define DWARF2_FILE_TIME_NAME(FILENAME,DIRNAME) 0
  71. #endif
  72. #ifndef DWARF2_FILE_SIZE_NAME
  73. #define DWARF2_FILE_SIZE_NAME(FILENAME,DIRNAME) 0
  74. #endif
  75. #ifndef DWARF2_VERSION
  76. #define DWARF2_VERSION 2
  77. #endif
  78. /* The .debug_aranges version has been 2 in DWARF version 2, 3 and 4. */
  79. #ifndef DWARF2_ARANGES_VERSION
  80. #define DWARF2_ARANGES_VERSION 2
  81. #endif
  82. /* This implementation output version 2 .debug_line information. */
  83. #ifndef DWARF2_LINE_VERSION
  84. #define DWARF2_LINE_VERSION 2
  85. #endif
  86. #include "subsegs.h"
  87. #include "dwarf2.h"
  88. /* Since we can't generate the prolog until the body is complete, we
  89. use three different subsegments for .debug_line: one holding the
  90. prolog, one for the directory and filename info, and one for the
  91. body ("statement program"). */
  92. #define DL_PROLOG 0
  93. #define DL_FILES 1
  94. #define DL_BODY 2
  95. /* If linker relaxation might change offsets in the code, the DWARF special
  96. opcodes and variable-length operands cannot be used. If this macro is
  97. nonzero, use the DW_LNS_fixed_advance_pc opcode instead. */
  98. #ifndef DWARF2_USE_FIXED_ADVANCE_PC
  99. # define DWARF2_USE_FIXED_ADVANCE_PC linkrelax
  100. #endif
  101. /* First special line opcde - leave room for the standard opcodes.
  102. Note: If you want to change this, you'll have to update the
  103. "standard_opcode_lengths" table that is emitted below in
  104. out_debug_line(). */
  105. #define DWARF2_LINE_OPCODE_BASE 13
  106. #ifndef DWARF2_LINE_BASE
  107. /* Minimum line offset in a special line info. opcode. This value
  108. was chosen to give a reasonable range of values. */
  109. # define DWARF2_LINE_BASE -5
  110. #endif
  111. /* Range of line offsets in a special line info. opcode. */
  112. #ifndef DWARF2_LINE_RANGE
  113. # define DWARF2_LINE_RANGE 14
  114. #endif
  115. #ifndef DWARF2_LINE_MIN_INSN_LENGTH
  116. /* Define the architecture-dependent minimum instruction length (in
  117. bytes). This value should be rather too small than too big. */
  118. # define DWARF2_LINE_MIN_INSN_LENGTH 1
  119. #endif
  120. /* Flag that indicates the initial value of the is_stmt_start flag. */
  121. #define DWARF2_LINE_DEFAULT_IS_STMT 1
  122. /* Given a special op, return the line skip amount. */
  123. #define SPECIAL_LINE(op) \
  124. (((op) - DWARF2_LINE_OPCODE_BASE)%DWARF2_LINE_RANGE + DWARF2_LINE_BASE)
  125. /* Given a special op, return the address skip amount (in units of
  126. DWARF2_LINE_MIN_INSN_LENGTH. */
  127. #define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)
  128. /* The maximum address skip amount that can be encoded with a special op. */
  129. #define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255)
  130. #ifndef TC_PARSE_CONS_RETURN_NONE
  131. #define TC_PARSE_CONS_RETURN_NONE BFD_RELOC_NONE
  132. #endif
  133. struct line_entry {
  134. struct line_entry *next;
  135. symbolS *label;
  136. struct dwarf2_line_info loc;
  137. };
  138. struct line_subseg {
  139. struct line_subseg *next;
  140. subsegT subseg;
  141. struct line_entry *head;
  142. struct line_entry **ptail;
  143. struct line_entry **pmove_tail;
  144. };
  145. struct line_seg {
  146. struct line_seg *next;
  147. segT seg;
  148. struct line_subseg *head;
  149. symbolS *text_start;
  150. symbolS *text_end;
  151. };
  152. /* Collects data for all line table entries during assembly. */
  153. static struct line_seg *all_segs;
  154. static struct line_seg **last_seg_ptr;
  155. struct file_entry {
  156. const char *filename;
  157. unsigned int dir;
  158. };
  159. /* Table of files used by .debug_line. */
  160. static struct file_entry *files;
  161. static unsigned int files_in_use;
  162. static unsigned int files_allocated;
  163. /* Table of directories used by .debug_line. */
  164. static char **dirs;
  165. static unsigned int dirs_in_use;
  166. static unsigned int dirs_allocated;
  167. /* TRUE when we've seen a .loc directive recently. Used to avoid
  168. doing work when there's nothing to do. */
  169. bfd_boolean dwarf2_loc_directive_seen;
  170. /* TRUE when we're supposed to set the basic block mark whenever a
  171. label is seen. */
  172. bfd_boolean dwarf2_loc_mark_labels;
  173. /* Current location as indicated by the most recent .loc directive. */
  174. static struct dwarf2_line_info current = {
  175. 1, 1, 0, 0,
  176. DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0,
  177. 0
  178. };
  179. /* The size of an address on the target. */
  180. static unsigned int sizeof_address;
  181. static unsigned int get_filenum (const char *, unsigned int);
  182. #ifndef TC_DWARF2_EMIT_OFFSET
  183. #define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset
  184. /* Create an offset to .dwarf2_*. */
  185. static void
  186. generic_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
  187. {
  188. expressionS exp;
  189. exp.X_op = O_symbol;
  190. exp.X_add_symbol = symbol;
  191. exp.X_add_number = 0;
  192. emit_expr (&exp, size);
  193. }
  194. #endif
  195. /* Find or create (if CREATE_P) an entry for SEG+SUBSEG in ALL_SEGS. */
  196. static struct line_subseg *
  197. get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
  198. {
  199. struct line_seg *s = seg_info (seg)->dwarf2_line_seg;
  200. struct line_subseg **pss, *lss;
  201. if (s == NULL)
  202. {
  203. if (!create_p)
  204. return NULL;
  205. s = (struct line_seg *) xmalloc (sizeof (*s));
  206. s->next = NULL;
  207. s->seg = seg;
  208. s->head = NULL;
  209. *last_seg_ptr = s;
  210. last_seg_ptr = &s->next;
  211. seg_info (seg)->dwarf2_line_seg = s;
  212. }
  213. gas_assert (seg == s->seg);
  214. for (pss = &s->head; (lss = *pss) != NULL ; pss = &lss->next)
  215. {
  216. if (lss->subseg == subseg)
  217. goto found_subseg;
  218. if (lss->subseg > subseg)
  219. break;
  220. }
  221. lss = (struct line_subseg *) xmalloc (sizeof (*lss));
  222. lss->next = *pss;
  223. lss->subseg = subseg;
  224. lss->head = NULL;
  225. lss->ptail = &lss->head;
  226. lss->pmove_tail = &lss->head;
  227. *pss = lss;
  228. found_subseg:
  229. return lss;
  230. }
  231. /* Record an entry for LOC occurring at LABEL. */
  232. static void
  233. dwarf2_gen_line_info_1 (symbolS *label, struct dwarf2_line_info *loc)
  234. {
  235. struct line_subseg *lss;
  236. struct line_entry *e;
  237. e = (struct line_entry *) xmalloc (sizeof (*e));
  238. e->next = NULL;
  239. e->label = label;
  240. e->loc = *loc;
  241. lss = get_line_subseg (now_seg, now_subseg, TRUE);
  242. *lss->ptail = e;
  243. lss->ptail = &e->next;
  244. }
  245. /* Record an entry for LOC occurring at OFS within the current fragment. */
  246. void
  247. dwarf2_gen_line_info (addressT ofs, struct dwarf2_line_info *loc)
  248. {
  249. static unsigned int line = -1;
  250. static unsigned int filenum = -1;
  251. symbolS *sym;
  252. /* Early out for as-yet incomplete location information. */
  253. if (loc->filenum == 0 || loc->line == 0)
  254. return;
  255. /* Don't emit sequences of line symbols for the same line when the
  256. symbols apply to assembler code. It is necessary to emit
  257. duplicate line symbols when a compiler asks for them, because GDB
  258. uses them to determine the end of the prologue. */
  259. if (debug_type == DEBUG_DWARF2
  260. && line == loc->line && filenum == loc->filenum)
  261. return;
  262. line = loc->line;
  263. filenum = loc->filenum;
  264. if (linkrelax)
  265. {
  266. char name[120];
  267. /* Use a non-fake name for the line number location,
  268. so that it can be referred to by relocations. */
  269. sprintf (name, ".Loc.%u.%u", line, filenum);
  270. sym = symbol_new (name, now_seg, ofs, frag_now);
  271. }
  272. else
  273. sym = symbol_temp_new (now_seg, ofs, frag_now);
  274. dwarf2_gen_line_info_1 (sym, loc);
  275. }
  276. /* Returns the current source information. If .file directives have
  277. been encountered, the info for the corresponding source file is
  278. returned. Otherwise, the info for the assembly source file is
  279. returned. */
  280. void
  281. dwarf2_where (struct dwarf2_line_info *line)
  282. {
  283. if (debug_type == DEBUG_DWARF2)
  284. {
  285. char *filename;
  286. as_where (&filename, &line->line);
  287. line->filenum = get_filenum (filename, 0);
  288. line->column = 0;
  289. line->flags = DWARF2_FLAG_IS_STMT;
  290. line->isa = current.isa;
  291. line->discriminator = current.discriminator;
  292. }
  293. else
  294. *line = current;
  295. }
  296. /* A hook to allow the target backend to inform the line number state
  297. machine of isa changes when assembler debug info is enabled. */
  298. void
  299. dwarf2_set_isa (unsigned int isa)
  300. {
  301. current.isa = isa;
  302. }
  303. /* Called for each machine instruction, or relatively atomic group of
  304. machine instructions (ie built-in macro). The instruction or group
  305. is SIZE bytes in length. If dwarf2 line number generation is called
  306. for, emit a line statement appropriately. */
  307. void
  308. dwarf2_emit_insn (int size)
  309. {
  310. struct dwarf2_line_info loc;
  311. if (!dwarf2_loc_directive_seen && debug_type != DEBUG_DWARF2)
  312. return;
  313. dwarf2_where (&loc);
  314. dwarf2_gen_line_info (frag_now_fix () - size, &loc);
  315. dwarf2_consume_line_info ();
  316. }
  317. /* Move all previously-emitted line entries for the current position by
  318. DELTA bytes. This function cannot be used to move the same entries
  319. twice. */
  320. void
  321. dwarf2_move_insn (int delta)
  322. {
  323. struct line_subseg *lss;
  324. struct line_entry *e;
  325. valueT now;
  326. if (delta == 0)
  327. return;
  328. lss = get_line_subseg (now_seg, now_subseg, FALSE);
  329. if (!lss)
  330. return;
  331. now = frag_now_fix ();
  332. while ((e = *lss->pmove_tail))
  333. {
  334. if (S_GET_VALUE (e->label) == now)
  335. S_SET_VALUE (e->label, now + delta);
  336. lss->pmove_tail = &e->next;
  337. }
  338. }
  339. /* Called after the current line information has been either used with
  340. dwarf2_gen_line_info or saved with a machine instruction for later use.
  341. This resets the state of the line number information to reflect that
  342. it has been used. */
  343. void
  344. dwarf2_consume_line_info (void)
  345. {
  346. /* Unless we generate DWARF2 debugging information for each
  347. assembler line, we only emit one line symbol for one LOC. */
  348. dwarf2_loc_directive_seen = FALSE;
  349. current.flags &= ~(DWARF2_FLAG_BASIC_BLOCK
  350. | DWARF2_FLAG_PROLOGUE_END
  351. | DWARF2_FLAG_EPILOGUE_BEGIN);
  352. current.discriminator = 0;
  353. }
  354. /* Called for each (preferably code) label. If dwarf2_loc_mark_labels
  355. is enabled, emit a basic block marker. */
  356. void
  357. dwarf2_emit_label (symbolS *label)
  358. {
  359. struct dwarf2_line_info loc;
  360. if (!dwarf2_loc_mark_labels)
  361. return;
  362. if (S_GET_SEGMENT (label) != now_seg)
  363. return;
  364. if (!(bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE))
  365. return;
  366. if (files_in_use == 0 && debug_type != DEBUG_DWARF2)
  367. return;
  368. dwarf2_where (&loc);
  369. loc.flags |= DWARF2_FLAG_BASIC_BLOCK;
  370. dwarf2_gen_line_info_1 (label, &loc);
  371. dwarf2_consume_line_info ();
  372. }
  373. /* Get a .debug_line file number for FILENAME. If NUM is nonzero,
  374. allocate it on that file table slot, otherwise return the first
  375. empty one. */
  376. static unsigned int
  377. get_filenum (const char *filename, unsigned int num)
  378. {
  379. static unsigned int last_used, last_used_dir_len;
  380. const char *file;
  381. size_t dir_len;
  382. unsigned int i, dir;
  383. if (num == 0 && last_used)
  384. {
  385. if (! files[last_used].dir
  386. && filename_cmp (filename, files[last_used].filename) == 0)
  387. return last_used;
  388. if (files[last_used].dir
  389. && filename_ncmp (filename, dirs[files[last_used].dir],
  390. last_used_dir_len) == 0
  391. && IS_DIR_SEPARATOR (filename [last_used_dir_len])
  392. && filename_cmp (filename + last_used_dir_len + 1,
  393. files[last_used].filename) == 0)
  394. return last_used;
  395. }
  396. file = lbasename (filename);
  397. /* Don't make empty string from / or A: from A:/ . */
  398. #ifdef HAVE_DOS_BASED_FILE_SYSTEM
  399. if (file <= filename + 3)
  400. file = filename;
  401. #else
  402. if (file == filename + 1)
  403. file = filename;
  404. #endif
  405. dir_len = file - filename;
  406. dir = 0;
  407. if (dir_len)
  408. {
  409. #ifndef DWARF2_DIR_SHOULD_END_WITH_SEPARATOR
  410. --dir_len;
  411. #endif
  412. for (dir = 1; dir < dirs_in_use; ++dir)
  413. if (filename_ncmp (filename, dirs[dir], dir_len) == 0
  414. && dirs[dir][dir_len] == '\0')
  415. break;
  416. if (dir >= dirs_in_use)
  417. {
  418. if (dir >= dirs_allocated)
  419. {
  420. dirs_allocated = dir + 32;
  421. dirs = (char **)
  422. xrealloc (dirs, (dir + 32) * sizeof (const char *));
  423. }
  424. dirs[dir] = (char *) xmalloc (dir_len + 1);
  425. memcpy (dirs[dir], filename, dir_len);
  426. dirs[dir][dir_len] = '\0';
  427. dirs_in_use = dir + 1;
  428. }
  429. }
  430. if (num == 0)
  431. {
  432. for (i = 1; i < files_in_use; ++i)
  433. if (files[i].dir == dir
  434. && files[i].filename
  435. && filename_cmp (file, files[i].filename) == 0)
  436. {
  437. last_used = i;
  438. last_used_dir_len = dir_len;
  439. return i;
  440. }
  441. }
  442. else
  443. i = num;
  444. if (i >= files_allocated)
  445. {
  446. unsigned int old = files_allocated;
  447. files_allocated = i + 32;
  448. files = (struct file_entry *)
  449. xrealloc (files, (i + 32) * sizeof (struct file_entry));
  450. memset (files + old, 0, (i + 32 - old) * sizeof (struct file_entry));
  451. }
  452. files[i].filename = num ? file : xstrdup (file);
  453. files[i].dir = dir;
  454. if (files_in_use < i + 1)
  455. files_in_use = i + 1;
  456. last_used = i;
  457. last_used_dir_len = dir_len;
  458. return i;
  459. }
  460. /* Handle two forms of .file directive:
  461. - Pass .file "source.c" to s_app_file
  462. - Handle .file 1 "source.c" by adding an entry to the DWARF-2 file table
  463. If an entry is added to the file table, return a pointer to the filename. */
  464. char *
  465. dwarf2_directive_file (int dummy ATTRIBUTE_UNUSED)
  466. {
  467. offsetT num;
  468. char *filename;
  469. int filename_len;
  470. /* Continue to accept a bare string and pass it off. */
  471. SKIP_WHITESPACE ();
  472. if (*input_line_pointer == '"')
  473. {
  474. s_app_file (0);
  475. return NULL;
  476. }
  477. num = get_absolute_expression ();
  478. filename = demand_copy_C_string (&filename_len);
  479. if (filename == NULL)
  480. return NULL;
  481. demand_empty_rest_of_line ();
  482. if (num < 1)
  483. {
  484. as_bad (_("file number less than one"));
  485. return NULL;
  486. }
  487. /* A .file directive implies compiler generated debug information is
  488. being supplied. Turn off gas generated debug info. */
  489. debug_type = DEBUG_NONE;
  490. if (num < (int) files_in_use && files[num].filename != 0)
  491. {
  492. as_bad (_("file number %ld already allocated"), (long) num);
  493. return NULL;
  494. }
  495. get_filenum (filename, num);
  496. return filename;
  497. }
  498. void
  499. dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
  500. {
  501. offsetT filenum, line;
  502. /* If we see two .loc directives in a row, force the first one to be
  503. output now. */
  504. if (dwarf2_loc_directive_seen)
  505. dwarf2_emit_insn (0);
  506. filenum = get_absolute_expression ();
  507. SKIP_WHITESPACE ();
  508. line = get_absolute_expression ();
  509. if (filenum < 1)
  510. {
  511. as_bad (_("file number less than one"));
  512. return;
  513. }
  514. if (filenum >= (int) files_in_use || files[filenum].filename == 0)
  515. {
  516. as_bad (_("unassigned file number %ld"), (long) filenum);
  517. return;
  518. }
  519. current.filenum = filenum;
  520. current.line = line;
  521. current.discriminator = 0;
  522. #ifndef NO_LISTING
  523. if (listing)
  524. {
  525. if (files[filenum].dir)
  526. {
  527. size_t dir_len = strlen (dirs[files[filenum].dir]);
  528. size_t file_len = strlen (files[filenum].filename);
  529. char *cp = (char *) alloca (dir_len + 1 + file_len + 1);
  530. memcpy (cp, dirs[files[filenum].dir], dir_len);
  531. INSERT_DIR_SEPARATOR (cp, dir_len);
  532. memcpy (cp + dir_len + 1, files[filenum].filename, file_len);
  533. cp[dir_len + file_len + 1] = '\0';
  534. listing_source_file (cp);
  535. }
  536. else
  537. listing_source_file (files[filenum].filename);
  538. listing_source_line (line);
  539. }
  540. #endif
  541. SKIP_WHITESPACE ();
  542. if (ISDIGIT (*input_line_pointer))
  543. {
  544. current.column = get_absolute_expression ();
  545. SKIP_WHITESPACE ();
  546. }
  547. while (ISALPHA (*input_line_pointer))
  548. {
  549. char *p, c;
  550. offsetT value;
  551. c = get_symbol_name (& p);
  552. if (strcmp (p, "basic_block") == 0)
  553. {
  554. current.flags |= DWARF2_FLAG_BASIC_BLOCK;
  555. *input_line_pointer = c;
  556. }
  557. else if (strcmp (p, "prologue_end") == 0)
  558. {
  559. current.flags |= DWARF2_FLAG_PROLOGUE_END;
  560. *input_line_pointer = c;
  561. }
  562. else if (strcmp (p, "epilogue_begin") == 0)
  563. {
  564. current.flags |= DWARF2_FLAG_EPILOGUE_BEGIN;
  565. *input_line_pointer = c;
  566. }
  567. else if (strcmp (p, "is_stmt") == 0)
  568. {
  569. (void) restore_line_pointer (c);
  570. value = get_absolute_expression ();
  571. if (value == 0)
  572. current.flags &= ~DWARF2_FLAG_IS_STMT;
  573. else if (value == 1)
  574. current.flags |= DWARF2_FLAG_IS_STMT;
  575. else
  576. {
  577. as_bad (_("is_stmt value not 0 or 1"));
  578. return;
  579. }
  580. }
  581. else if (strcmp (p, "isa") == 0)
  582. {
  583. (void) restore_line_pointer (c);
  584. value = get_absolute_expression ();
  585. if (value >= 0)
  586. current.isa = value;
  587. else
  588. {
  589. as_bad (_("isa number less than zero"));
  590. return;
  591. }
  592. }
  593. else if (strcmp (p, "discriminator") == 0)
  594. {
  595. (void) restore_line_pointer (c);
  596. value = get_absolute_expression ();
  597. if (value >= 0)
  598. current.discriminator = value;
  599. else
  600. {
  601. as_bad (_("discriminator less than zero"));
  602. return;
  603. }
  604. }
  605. else
  606. {
  607. as_bad (_("unknown .loc sub-directive `%s'"), p);
  608. (void) restore_line_pointer (c);
  609. return;
  610. }
  611. SKIP_WHITESPACE_AFTER_NAME ();
  612. }
  613. demand_empty_rest_of_line ();
  614. dwarf2_loc_directive_seen = TRUE;
  615. debug_type = DEBUG_NONE;
  616. }
  617. void
  618. dwarf2_directive_loc_mark_labels (int dummy ATTRIBUTE_UNUSED)
  619. {
  620. offsetT value = get_absolute_expression ();
  621. if (value != 0 && value != 1)
  622. {
  623. as_bad (_("expected 0 or 1"));
  624. ignore_rest_of_line ();
  625. }
  626. else
  627. {
  628. dwarf2_loc_mark_labels = value != 0;
  629. demand_empty_rest_of_line ();
  630. }
  631. }
  632. static struct frag *
  633. first_frag_for_seg (segT seg)
  634. {
  635. return seg_info (seg)->frchainP->frch_root;
  636. }
  637. static struct frag *
  638. last_frag_for_seg (segT seg)
  639. {
  640. frchainS *f = seg_info (seg)->frchainP;
  641. while (f->frch_next != NULL)
  642. f = f->frch_next;
  643. return f->frch_last;
  644. }
  645. /* Emit a single byte into the current segment. */
  646. static inline void
  647. out_byte (int byte)
  648. {
  649. FRAG_APPEND_1_CHAR (byte);
  650. }
  651. /* Emit a statement program opcode into the current segment. */
  652. static inline void
  653. out_opcode (int opc)
  654. {
  655. out_byte (opc);
  656. }
  657. /* Emit a two-byte word into the current segment. */
  658. static inline void
  659. out_two (int data)
  660. {
  661. md_number_to_chars (frag_more (2), data, 2);
  662. }
  663. /* Emit a four byte word into the current segment. */
  664. static inline void
  665. out_four (int data)
  666. {
  667. md_number_to_chars (frag_more (4), data, 4);
  668. }
  669. /* Emit an unsigned "little-endian base 128" number. */
  670. static void
  671. out_uleb128 (addressT value)
  672. {
  673. output_leb128 (frag_more (sizeof_leb128 (value, 0)), value, 0);
  674. }
  675. /* Emit a signed "little-endian base 128" number. */
  676. static void
  677. out_leb128 (addressT value)
  678. {
  679. output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1);
  680. }
  681. /* Emit a tuple for .debug_abbrev. */
  682. static inline void
  683. out_abbrev (int name, int form)
  684. {
  685. out_uleb128 (name);
  686. out_uleb128 (form);
  687. }
  688. /* Get the size of a fragment. */
  689. static offsetT
  690. get_frag_fix (fragS *frag, segT seg)
  691. {
  692. frchainS *fr;
  693. if (frag->fr_next)
  694. return frag->fr_fix;
  695. /* If a fragment is the last in the chain, special measures must be
  696. taken to find its size before relaxation, since it may be pending
  697. on some subsegment chain. */
  698. for (fr = seg_info (seg)->frchainP; fr; fr = fr->frch_next)
  699. if (fr->frch_last == frag)
  700. return (char *) obstack_next_free (&fr->frch_obstack) - frag->fr_literal;
  701. abort ();
  702. }
  703. /* Set an absolute address (may result in a relocation entry). */
  704. static void
  705. out_set_addr (symbolS *sym)
  706. {
  707. expressionS exp;
  708. out_opcode (DW_LNS_extended_op);
  709. out_uleb128 (sizeof_address + 1);
  710. out_opcode (DW_LNE_set_address);
  711. exp.X_op = O_symbol;
  712. exp.X_add_symbol = sym;
  713. exp.X_add_number = 0;
  714. emit_expr (&exp, sizeof_address);
  715. }
  716. static void scale_addr_delta (addressT *);
  717. static void
  718. scale_addr_delta (addressT *addr_delta)
  719. {
  720. static int printed_this = 0;
  721. if (DWARF2_LINE_MIN_INSN_LENGTH > 1)
  722. {
  723. if (*addr_delta % DWARF2_LINE_MIN_INSN_LENGTH != 0 && !printed_this)
  724. {
  725. as_bad("unaligned opcodes detected in executable segment");
  726. printed_this = 1;
  727. }
  728. *addr_delta /= DWARF2_LINE_MIN_INSN_LENGTH;
  729. }
  730. }
  731. /* Encode a pair of line and address skips as efficiently as possible.
  732. Note that the line skip is signed, whereas the address skip is unsigned.
  733. The following two routines *must* be kept in sync. This is
  734. enforced by making emit_inc_line_addr abort if we do not emit
  735. exactly the expected number of bytes. */
  736. static int
  737. size_inc_line_addr (int line_delta, addressT addr_delta)
  738. {
  739. unsigned int tmp, opcode;
  740. int len = 0;
  741. /* Scale the address delta by the minimum instruction length. */
  742. scale_addr_delta (&addr_delta);
  743. /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
  744. We cannot use special opcodes here, since we want the end_sequence
  745. to emit the matrix entry. */
  746. if (line_delta == INT_MAX)
  747. {
  748. if (addr_delta == MAX_SPECIAL_ADDR_DELTA)
  749. len = 1;
  750. else
  751. len = 1 + sizeof_leb128 (addr_delta, 0);
  752. return len + 3;
  753. }
  754. /* Bias the line delta by the base. */
  755. tmp = line_delta - DWARF2_LINE_BASE;
  756. /* If the line increment is out of range of a special opcode, we
  757. must encode it with DW_LNS_advance_line. */
  758. if (tmp >= DWARF2_LINE_RANGE)
  759. {
  760. len = 1 + sizeof_leb128 (line_delta, 1);
  761. line_delta = 0;
  762. tmp = 0 - DWARF2_LINE_BASE;
  763. }
  764. /* Bias the opcode by the special opcode base. */
  765. tmp += DWARF2_LINE_OPCODE_BASE;
  766. /* Avoid overflow when addr_delta is large. */
  767. if (addr_delta < 256 + MAX_SPECIAL_ADDR_DELTA)
  768. {
  769. /* Try using a special opcode. */
  770. opcode = tmp + addr_delta * DWARF2_LINE_RANGE;
  771. if (opcode <= 255)
  772. return len + 1;
  773. /* Try using DW_LNS_const_add_pc followed by special op. */
  774. opcode = tmp + (addr_delta - MAX_SPECIAL_ADDR_DELTA) * DWARF2_LINE_RANGE;
  775. if (opcode <= 255)
  776. return len + 2;
  777. }
  778. /* Otherwise use DW_LNS_advance_pc. */
  779. len += 1 + sizeof_leb128 (addr_delta, 0);
  780. /* DW_LNS_copy or special opcode. */
  781. len += 1;
  782. return len;
  783. }
  784. static void
  785. emit_inc_line_addr (int line_delta, addressT addr_delta, char *p, int len)
  786. {
  787. unsigned int tmp, opcode;
  788. int need_copy = 0;
  789. char *end = p + len;
  790. /* Line number sequences cannot go backward in addresses. This means
  791. we've incorrectly ordered the statements in the sequence. */
  792. gas_assert ((offsetT) addr_delta >= 0);
  793. /* Scale the address delta by the minimum instruction length. */
  794. scale_addr_delta (&addr_delta);
  795. /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
  796. We cannot use special opcodes here, since we want the end_sequence
  797. to emit the matrix entry. */
  798. if (line_delta == INT_MAX)
  799. {
  800. if (addr_delta == MAX_SPECIAL_ADDR_DELTA)
  801. *p++ = DW_LNS_const_add_pc;
  802. else
  803. {
  804. *p++ = DW_LNS_advance_pc;
  805. p += output_leb128 (p, addr_delta, 0);
  806. }
  807. *p++ = DW_LNS_extended_op;
  808. *p++ = 1;
  809. *p++ = DW_LNE_end_sequence;
  810. goto done;
  811. }
  812. /* Bias the line delta by the base. */
  813. tmp = line_delta - DWARF2_LINE_BASE;
  814. /* If the line increment is out of range of a special opcode, we
  815. must encode it with DW_LNS_advance_line. */
  816. if (tmp >= DWARF2_LINE_RANGE)
  817. {
  818. *p++ = DW_LNS_advance_line;
  819. p += output_leb128 (p, line_delta, 1);
  820. line_delta = 0;
  821. tmp = 0 - DWARF2_LINE_BASE;
  822. need_copy = 1;
  823. }
  824. /* Prettier, I think, to use DW_LNS_copy instead of a "line +0, addr +0"
  825. special opcode. */
  826. if (line_delta == 0 && addr_delta == 0)
  827. {
  828. *p++ = DW_LNS_copy;
  829. goto done;
  830. }
  831. /* Bias the opcode by the special opcode base. */
  832. tmp += DWARF2_LINE_OPCODE_BASE;
  833. /* Avoid overflow when addr_delta is large. */
  834. if (addr_delta < 256 + MAX_SPECIAL_ADDR_DELTA)
  835. {
  836. /* Try using a special opcode. */
  837. opcode = tmp + addr_delta * DWARF2_LINE_RANGE;
  838. if (opcode <= 255)
  839. {
  840. *p++ = opcode;
  841. goto done;
  842. }
  843. /* Try using DW_LNS_const_add_pc followed by special op. */
  844. opcode = tmp + (addr_delta - MAX_SPECIAL_ADDR_DELTA) * DWARF2_LINE_RANGE;
  845. if (opcode <= 255)
  846. {
  847. *p++ = DW_LNS_const_add_pc;
  848. *p++ = opcode;
  849. goto done;
  850. }
  851. }
  852. /* Otherwise use DW_LNS_advance_pc. */
  853. *p++ = DW_LNS_advance_pc;
  854. p += output_leb128 (p, addr_delta, 0);
  855. if (need_copy)
  856. *p++ = DW_LNS_copy;
  857. else
  858. *p++ = tmp;
  859. done:
  860. gas_assert (p == end);
  861. }
  862. /* Handy routine to combine calls to the above two routines. */
  863. static void
  864. out_inc_line_addr (int line_delta, addressT addr_delta)
  865. {
  866. int len = size_inc_line_addr (line_delta, addr_delta);
  867. emit_inc_line_addr (line_delta, addr_delta, frag_more (len), len);
  868. }
  869. /* Write out an alternative form of line and address skips using
  870. DW_LNS_fixed_advance_pc opcodes. This uses more space than the default
  871. line and address information, but it is required if linker relaxation
  872. could change the code offsets. The following two routines *must* be
  873. kept in sync. */
  874. #define ADDR_DELTA_LIMIT 50000
  875. static int
  876. size_fixed_inc_line_addr (int line_delta, addressT addr_delta)
  877. {
  878. int len = 0;
  879. /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence. */
  880. if (line_delta != INT_MAX)
  881. len = 1 + sizeof_leb128 (line_delta, 1);
  882. if (addr_delta > ADDR_DELTA_LIMIT)
  883. {
  884. /* DW_LNS_extended_op */
  885. len += 1 + sizeof_leb128 (sizeof_address + 1, 0);
  886. /* DW_LNE_set_address */
  887. len += 1 + sizeof_address;
  888. }
  889. else
  890. /* DW_LNS_fixed_advance_pc */
  891. len += 3;
  892. if (line_delta == INT_MAX)
  893. /* DW_LNS_extended_op + DW_LNE_end_sequence */
  894. len += 3;
  895. else
  896. /* DW_LNS_copy */
  897. len += 1;
  898. return len;
  899. }
  900. static void
  901. emit_fixed_inc_line_addr (int line_delta, addressT addr_delta, fragS *frag,
  902. char *p, int len)
  903. {
  904. expressionS *pexp;
  905. char *end = p + len;
  906. /* Line number sequences cannot go backward in addresses. This means
  907. we've incorrectly ordered the statements in the sequence. */
  908. gas_assert ((offsetT) addr_delta >= 0);
  909. /* Verify that we have kept in sync with size_fixed_inc_line_addr. */
  910. gas_assert (len == size_fixed_inc_line_addr (line_delta, addr_delta));
  911. /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence. */
  912. if (line_delta != INT_MAX)
  913. {
  914. *p++ = DW_LNS_advance_line;
  915. p += output_leb128 (p, line_delta, 1);
  916. }
  917. pexp = symbol_get_value_expression (frag->fr_symbol);
  918. /* The DW_LNS_fixed_advance_pc opcode has a 2-byte operand so it can
  919. advance the address by at most 64K. Linker relaxation (without
  920. which this function would not be used) could change the operand by
  921. an unknown amount. If the address increment is getting close to
  922. the limit, just reset the address. */
  923. if (addr_delta > ADDR_DELTA_LIMIT)
  924. {
  925. symbolS *to_sym;
  926. expressionS exp;
  927. gas_assert (pexp->X_op == O_subtract);
  928. to_sym = pexp->X_add_symbol;
  929. *p++ = DW_LNS_extended_op;
  930. p += output_leb128 (p, sizeof_address + 1, 0);
  931. *p++ = DW_LNE_set_address;
  932. exp.X_op = O_symbol;
  933. exp.X_add_symbol = to_sym;
  934. exp.X_add_number = 0;
  935. emit_expr_fix (&exp, sizeof_address, frag, p, TC_PARSE_CONS_RETURN_NONE);
  936. p += sizeof_address;
  937. }
  938. else
  939. {
  940. *p++ = DW_LNS_fixed_advance_pc;
  941. emit_expr_fix (pexp, 2, frag, p, TC_PARSE_CONS_RETURN_NONE);
  942. p += 2;
  943. }
  944. if (line_delta == INT_MAX)
  945. {
  946. *p++ = DW_LNS_extended_op;
  947. *p++ = 1;
  948. *p++ = DW_LNE_end_sequence;
  949. }
  950. else
  951. *p++ = DW_LNS_copy;
  952. gas_assert (p == end);
  953. }
  954. /* Generate a variant frag that we can use to relax address/line
  955. increments between fragments of the target segment. */
  956. static void
  957. relax_inc_line_addr (int line_delta, symbolS *to_sym, symbolS *from_sym)
  958. {
  959. expressionS exp;
  960. int max_chars;
  961. exp.X_op = O_subtract;
  962. exp.X_add_symbol = to_sym;
  963. exp.X_op_symbol = from_sym;
  964. exp.X_add_number = 0;
  965. /* The maximum size of the frag is the line delta with a maximum
  966. sized address delta. */
  967. if (DWARF2_USE_FIXED_ADVANCE_PC)
  968. max_chars = size_fixed_inc_line_addr (line_delta,
  969. -DWARF2_LINE_MIN_INSN_LENGTH);
  970. else
  971. max_chars = size_inc_line_addr (line_delta, -DWARF2_LINE_MIN_INSN_LENGTH);
  972. frag_var (rs_dwarf2dbg, max_chars, max_chars, 1,
  973. make_expr_symbol (&exp), line_delta, NULL);
  974. }
  975. /* The function estimates the size of a rs_dwarf2dbg variant frag
  976. based on the current values of the symbols. It is called before
  977. the relaxation loop. We set fr_subtype to the expected length. */
  978. int
  979. dwarf2dbg_estimate_size_before_relax (fragS *frag)
  980. {
  981. offsetT addr_delta;
  982. int size;
  983. addr_delta = resolve_symbol_value (frag->fr_symbol);
  984. if (DWARF2_USE_FIXED_ADVANCE_PC)
  985. size = size_fixed_inc_line_addr (frag->fr_offset, addr_delta);
  986. else
  987. size = size_inc_line_addr (frag->fr_offset, addr_delta);
  988. frag->fr_subtype = size;
  989. return size;
  990. }
  991. /* This function relaxes a rs_dwarf2dbg variant frag based on the
  992. current values of the symbols. fr_subtype is the current length
  993. of the frag. This returns the change in frag length. */
  994. int
  995. dwarf2dbg_relax_frag (fragS *frag)
  996. {
  997. int old_size, new_size;
  998. old_size = frag->fr_subtype;
  999. new_size = dwarf2dbg_estimate_size_before_relax (frag);
  1000. return new_size - old_size;
  1001. }
  1002. /* This function converts a rs_dwarf2dbg variant frag into a normal
  1003. fill frag. This is called after all relaxation has been done.
  1004. fr_subtype will be the desired length of the frag. */
  1005. void
  1006. dwarf2dbg_convert_frag (fragS *frag)
  1007. {
  1008. offsetT addr_diff;
  1009. if (DWARF2_USE_FIXED_ADVANCE_PC)
  1010. {
  1011. /* If linker relaxation is enabled then the distance bewteen the two
  1012. symbols in the frag->fr_symbol expression might change. Hence we
  1013. cannot rely upon the value computed by resolve_symbol_value.
  1014. Instead we leave the expression unfinalized and allow
  1015. emit_fixed_inc_line_addr to create a fixup (which later becomes a
  1016. relocation) that will allow the linker to correctly compute the
  1017. actual address difference. We have to use a fixed line advance for
  1018. this as we cannot (easily) relocate leb128 encoded values. */
  1019. int saved_finalize_syms = finalize_syms;
  1020. finalize_syms = 0;
  1021. addr_diff = resolve_symbol_value (frag->fr_symbol);
  1022. finalize_syms = saved_finalize_syms;
  1023. }
  1024. else
  1025. addr_diff = resolve_symbol_value (frag->fr_symbol);
  1026. /* fr_var carries the max_chars that we created the fragment with.
  1027. fr_subtype carries the current expected length. We must, of
  1028. course, have allocated enough memory earlier. */
  1029. gas_assert (frag->fr_var >= (int) frag->fr_subtype);
  1030. if (DWARF2_USE_FIXED_ADVANCE_PC)
  1031. emit_fixed_inc_line_addr (frag->fr_offset, addr_diff, frag,
  1032. frag->fr_literal + frag->fr_fix,
  1033. frag->fr_subtype);
  1034. else
  1035. emit_inc_line_addr (frag->fr_offset, addr_diff,
  1036. frag->fr_literal + frag->fr_fix, frag->fr_subtype);
  1037. frag->fr_fix += frag->fr_subtype;
  1038. frag->fr_type = rs_fill;
  1039. frag->fr_var = 0;
  1040. frag->fr_offset = 0;
  1041. }
  1042. /* Generate .debug_line content for the chain of line number entries
  1043. beginning at E, for segment SEG. */
  1044. static void
  1045. process_entries (segT seg, struct line_entry *e)
  1046. {
  1047. unsigned filenum = 1;
  1048. unsigned line = 1;
  1049. unsigned column = 0;
  1050. unsigned isa = 0;
  1051. unsigned flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
  1052. fragS *last_frag = NULL, *frag;
  1053. addressT last_frag_ofs = 0, frag_ofs;
  1054. symbolS *last_lab = NULL, *lab;
  1055. struct line_entry *next;
  1056. if (flag_dwarf_sections)
  1057. {
  1058. char * name;
  1059. const char * sec_name;
  1060. /* Switch to the relevent sub-section before we start to emit
  1061. the line number table.
  1062. FIXME: These sub-sections do not have a normal Line Number
  1063. Program Header, thus strictly speaking they are not valid
  1064. DWARF sections. Unfortunately the DWARF standard assumes
  1065. a one-to-one relationship between compilation units and
  1066. line number tables. Thus we have to have a .debug_line
  1067. section, as well as our sub-sections, and we have to ensure
  1068. that all of the sub-sections are merged into a proper
  1069. .debug_line section before a debugger sees them. */
  1070. sec_name = bfd_get_section_name (stdoutput, seg);
  1071. if (strcmp (sec_name, ".text") != 0)
  1072. {
  1073. unsigned int len;
  1074. len = strlen (sec_name);
  1075. name = xmalloc (len + 11 + 2);
  1076. sprintf (name, ".debug_line%s", sec_name);
  1077. subseg_set (subseg_get (name, FALSE), 0);
  1078. }
  1079. else
  1080. /* Don't create a .debug_line.text section -
  1081. that is redundant. Instead just switch back to the
  1082. normal .debug_line section. */
  1083. subseg_set (subseg_get (".debug_line", FALSE), 0);
  1084. }
  1085. do
  1086. {
  1087. int line_delta;
  1088. if (filenum != e->loc.filenum)
  1089. {
  1090. filenum = e->loc.filenum;
  1091. out_opcode (DW_LNS_set_file);
  1092. out_uleb128 (filenum);
  1093. }
  1094. if (column != e->loc.column)
  1095. {
  1096. column = e->loc.column;
  1097. out_opcode (DW_LNS_set_column);
  1098. out_uleb128 (column);
  1099. }
  1100. if (e->loc.discriminator != 0)
  1101. {
  1102. out_opcode (DW_LNS_extended_op);
  1103. out_leb128 (1 + sizeof_leb128 (e->loc.discriminator, 0));
  1104. out_opcode (DW_LNE_set_discriminator);
  1105. out_uleb128 (e->loc.discriminator);
  1106. }
  1107. if (isa != e->loc.isa)
  1108. {
  1109. isa = e->loc.isa;
  1110. out_opcode (DW_LNS_set_isa);
  1111. out_uleb128 (isa);
  1112. }
  1113. if ((e->loc.flags ^ flags) & DWARF2_FLAG_IS_STMT)
  1114. {
  1115. flags = e->loc.flags;
  1116. out_opcode (DW_LNS_negate_stmt);
  1117. }
  1118. if (e->loc.flags & DWARF2_FLAG_BASIC_BLOCK)
  1119. out_opcode (DW_LNS_set_basic_block);
  1120. if (e->loc.flags & DWARF2_FLAG_PROLOGUE_END)
  1121. out_opcode (DW_LNS_set_prologue_end);
  1122. if (e->loc.flags & DWARF2_FLAG_EPILOGUE_BEGIN)
  1123. out_opcode (DW_LNS_set_epilogue_begin);
  1124. /* Don't try to optimize away redundant entries; gdb wants two
  1125. entries for a function where the code starts on the same line as
  1126. the {, and there's no way to identify that case here. Trust gcc
  1127. to optimize appropriately. */
  1128. line_delta = e->loc.line - line;
  1129. lab = e->label;
  1130. frag = symbol_get_frag (lab);
  1131. frag_ofs = S_GET_VALUE (lab);
  1132. if (last_frag == NULL)
  1133. {
  1134. out_set_addr (lab);
  1135. out_inc_line_addr (line_delta, 0);
  1136. }
  1137. else if (frag == last_frag && ! DWARF2_USE_FIXED_ADVANCE_PC)
  1138. out_inc_line_addr (line_delta, frag_ofs - last_frag_ofs);
  1139. else
  1140. relax_inc_line_addr (line_delta, lab, last_lab);
  1141. line = e->loc.line;
  1142. last_lab = lab;
  1143. last_frag = frag;
  1144. last_frag_ofs = frag_ofs;
  1145. next = e->next;
  1146. free (e);
  1147. e = next;
  1148. }
  1149. while (e);
  1150. /* Emit a DW_LNE_end_sequence for the end of the section. */
  1151. frag = last_frag_for_seg (seg);
  1152. frag_ofs = get_frag_fix (frag, seg);
  1153. if (frag == last_frag && ! DWARF2_USE_FIXED_ADVANCE_PC)
  1154. out_inc_line_addr (INT_MAX, frag_ofs - last_frag_ofs);
  1155. else
  1156. {
  1157. lab = symbol_temp_new (seg, frag_ofs, frag);
  1158. relax_inc_line_addr (INT_MAX, lab, last_lab);
  1159. }
  1160. }
  1161. /* Emit the directory and file tables for .debug_line. */
  1162. static void
  1163. out_file_list (void)
  1164. {
  1165. size_t size;
  1166. const char *dir;
  1167. char *cp;
  1168. unsigned int i;
  1169. /* Emit directory list. */
  1170. for (i = 1; i < dirs_in_use; ++i)
  1171. {
  1172. dir = remap_debug_filename (dirs[i]);
  1173. size = strlen (dir) + 1;
  1174. cp = frag_more (size);
  1175. memcpy (cp, dir, size);
  1176. }
  1177. /* Terminate it. */
  1178. out_byte ('\0');
  1179. for (i = 1; i < files_in_use; ++i)
  1180. {
  1181. const char *fullfilename;
  1182. if (files[i].filename == NULL)
  1183. {
  1184. as_bad (_("unassigned file number %ld"), (long) i);
  1185. /* Prevent a crash later, particularly for file 1. */
  1186. files[i].filename = "";
  1187. continue;
  1188. }
  1189. fullfilename = DWARF2_FILE_NAME (files[i].filename,
  1190. files[i].dir ? dirs [files [i].dir] : "");
  1191. size = strlen (fullfilename) + 1;
  1192. cp = frag_more (size);
  1193. memcpy (cp, fullfilename, size);
  1194. out_uleb128 (files[i].dir); /* directory number */
  1195. /* Output the last modification timestamp. */
  1196. out_uleb128 (DWARF2_FILE_TIME_NAME (files[i].filename,
  1197. files[i].dir ? dirs [files [i].dir] : ""));
  1198. /* Output the filesize. */
  1199. out_uleb128 (DWARF2_FILE_SIZE_NAME (files[i].filename,
  1200. files[i].dir ? dirs [files [i].dir] : ""));
  1201. }
  1202. /* Terminate filename list. */
  1203. out_byte (0);
  1204. }
  1205. /* Switch to SEC and output a header length field. Return the size of
  1206. offsets used in SEC. The caller must set EXPR->X_add_symbol value
  1207. to the end of the section. EXPR->X_add_number will be set to the
  1208. negative size of the header. */
  1209. static int
  1210. out_header (asection *sec, expressionS *exp)
  1211. {
  1212. symbolS *start_sym;
  1213. symbolS *end_sym;
  1214. subseg_set (sec, 0);
  1215. if (flag_dwarf_sections)
  1216. {
  1217. /* If we are going to put the start and end symbols in different
  1218. sections, then we need real symbols, not just fake, local ones. */
  1219. frag_now_fix ();
  1220. start_sym = symbol_make (".Ldebug_line_start");
  1221. end_sym = symbol_make (".Ldebug_line_end");
  1222. symbol_set_value_now (start_sym);
  1223. }
  1224. else
  1225. {
  1226. start_sym = symbol_temp_new_now ();
  1227. end_sym = symbol_temp_make ();
  1228. }
  1229. /* Total length of the information. */
  1230. exp->X_op = O_subtract;
  1231. exp->X_add_symbol = end_sym;
  1232. exp->X_op_symbol = start_sym;
  1233. switch (DWARF2_FORMAT (sec))
  1234. {
  1235. case dwarf2_format_32bit:
  1236. exp->X_add_number = -4;
  1237. emit_expr (exp, 4);
  1238. return 4;
  1239. case dwarf2_format_64bit:
  1240. exp->X_add_number = -12;
  1241. out_four (-1);
  1242. emit_expr (exp, 8);
  1243. return 8;
  1244. case dwarf2_format_64bit_irix:
  1245. exp->X_add_number = -8;
  1246. emit_expr (exp, 8);
  1247. return 8;
  1248. }
  1249. as_fatal (_("internal error: unknown dwarf2 format"));
  1250. return 0;
  1251. }
  1252. /* Emit the collected .debug_line data. */
  1253. static void
  1254. out_debug_line (segT line_seg)
  1255. {
  1256. expressionS exp;
  1257. symbolS *prologue_start, *prologue_end;
  1258. symbolS *line_end;
  1259. struct line_seg *s;
  1260. int sizeof_offset;
  1261. sizeof_offset = out_header (line_seg, &exp);
  1262. line_end = exp.X_add_symbol;
  1263. /* Version. */
  1264. out_two (DWARF2_LINE_VERSION);
  1265. /* Length of the prologue following this length. */
  1266. prologue_start = symbol_temp_make ();
  1267. prologue_end = symbol_temp_make ();
  1268. exp.X_op = O_subtract;
  1269. exp.X_add_symbol = prologue_end;
  1270. exp.X_op_symbol = prologue_start;
  1271. exp.X_add_number = 0;
  1272. emit_expr (&exp, sizeof_offset);
  1273. symbol_set_value_now (prologue_start);
  1274. /* Parameters of the state machine. */
  1275. out_byte (DWARF2_LINE_MIN_INSN_LENGTH);
  1276. out_byte (DWARF2_LINE_DEFAULT_IS_STMT);
  1277. out_byte (DWARF2_LINE_BASE);
  1278. out_byte (DWARF2_LINE_RANGE);
  1279. out_byte (DWARF2_LINE_OPCODE_BASE);
  1280. /* Standard opcode lengths. */
  1281. out_byte (0); /* DW_LNS_copy */
  1282. out_byte (1); /* DW_LNS_advance_pc */
  1283. out_byte (1); /* DW_LNS_advance_line */
  1284. out_byte (1); /* DW_LNS_set_file */
  1285. out_byte (1); /* DW_LNS_set_column */
  1286. out_byte (0); /* DW_LNS_negate_stmt */
  1287. out_byte (0); /* DW_LNS_set_basic_block */
  1288. out_byte (0); /* DW_LNS_const_add_pc */
  1289. out_byte (1); /* DW_LNS_fixed_advance_pc */
  1290. out_byte (0); /* DW_LNS_set_prologue_end */
  1291. out_byte (0); /* DW_LNS_set_epilogue_begin */
  1292. out_byte (1); /* DW_LNS_set_isa */
  1293. out_file_list ();
  1294. symbol_set_value_now (prologue_end);
  1295. /* For each section, emit a statement program. */
  1296. for (s = all_segs; s; s = s->next)
  1297. if (SEG_NORMAL (s->seg))
  1298. process_entries (s->seg, s->head->head);
  1299. else
  1300. as_warn ("dwarf line number information for %s ignored",
  1301. segment_name (s->seg));
  1302. if (flag_dwarf_sections)
  1303. /* We have to switch to the special .debug_line_end section
  1304. before emitting the end-of-debug_line symbol. The linker
  1305. script arranges for this section to be placed after all the
  1306. (potentially garbage collected) .debug_line.<foo> sections.
  1307. This section contains the line_end symbol which is used to
  1308. compute the size of the linked .debug_line section, as seen
  1309. in the DWARF Line Number header. */
  1310. subseg_set (subseg_get (".debug_line_end", FALSE), 0);
  1311. symbol_set_value_now (line_end);
  1312. }
  1313. static void
  1314. out_debug_ranges (segT ranges_seg)
  1315. {
  1316. unsigned int addr_size = sizeof_address;
  1317. struct line_seg *s;
  1318. expressionS exp;
  1319. unsigned int i;
  1320. subseg_set (ranges_seg, 0);
  1321. /* Base Address Entry. */
  1322. for (i = 0; i < addr_size; i++)
  1323. out_byte (0xff);
  1324. for (i = 0; i < addr_size; i++)
  1325. out_byte (0);
  1326. /* Range List Entry. */
  1327. for (s = all_segs; s; s = s->next)
  1328. {
  1329. fragS *frag;
  1330. symbolS *beg, *end;
  1331. frag = first_frag_for_seg (s->seg);
  1332. beg = symbol_temp_new (s->seg, 0, frag);
  1333. s->text_start = beg;
  1334. frag = last_frag_for_seg (s->seg);
  1335. end = symbol_temp_new (s->seg, get_frag_fix (frag, s->seg), frag);
  1336. s->text_end = end;
  1337. exp.X_op = O_symbol;
  1338. exp.X_add_symbol = beg;
  1339. exp.X_add_number = 0;
  1340. emit_expr (&exp, addr_size);
  1341. exp.X_op = O_symbol;
  1342. exp.X_add_symbol = end;
  1343. exp.X_add_number = 0;
  1344. emit_expr (&exp, addr_size);
  1345. }
  1346. /* End of Range Entry. */
  1347. for (i = 0; i < addr_size; i++)
  1348. out_byte (0);
  1349. for (i = 0; i < addr_size; i++)
  1350. out_byte (0);
  1351. }
  1352. /* Emit data for .debug_aranges. */
  1353. static void
  1354. out_debug_aranges (segT aranges_seg, segT info_seg)
  1355. {
  1356. unsigned int addr_size = sizeof_address;
  1357. offsetT size;
  1358. struct line_seg *s;
  1359. expressionS exp;
  1360. symbolS *aranges_end;
  1361. char *p;
  1362. int sizeof_offset;
  1363. sizeof_offset = out_header (aranges_seg, &exp);
  1364. aranges_end = exp.X_add_symbol;
  1365. size = -exp.X_add_number;
  1366. /* Version. */
  1367. out_two (DWARF2_ARANGES_VERSION);
  1368. size += 2;
  1369. /* Offset to .debug_info. */
  1370. TC_DWARF2_EMIT_OFFSET (section_symbol (info_seg), sizeof_offset);
  1371. size += sizeof_offset;
  1372. /* Size of an address (offset portion). */
  1373. out_byte (addr_size);
  1374. size++;
  1375. /* Size of a segment descriptor. */
  1376. out_byte (0);
  1377. size++;
  1378. /* Align the header. */
  1379. while ((size++ % (2 * addr_size)) > 0)
  1380. out_byte (0);
  1381. for (s = all_segs; s; s = s->next)
  1382. {
  1383. fragS *frag;
  1384. symbolS *beg, *end;
  1385. frag = first_frag_for_seg (s->seg);
  1386. beg = symbol_temp_new (s->seg, 0, frag);
  1387. s->text_start = beg;
  1388. frag = last_frag_for_seg (s->seg);
  1389. end = symbol_temp_new (s->seg, get_frag_fix (frag, s->seg), frag);
  1390. s->text_end = end;
  1391. exp.X_op = O_symbol;
  1392. exp.X_add_symbol = beg;
  1393. exp.X_add_number = 0;
  1394. emit_expr (&exp, addr_size);
  1395. exp.X_op = O_subtract;
  1396. exp.X_add_symbol = end;
  1397. exp.X_op_symbol = beg;
  1398. exp.X_add_number = 0;
  1399. emit_expr (&exp, addr_size);
  1400. }
  1401. p = frag_more (2 * addr_size);
  1402. md_number_to_chars (p, 0, addr_size);
  1403. md_number_to_chars (p + addr_size, 0, addr_size);
  1404. symbol_set_value_now (aranges_end);
  1405. }
  1406. /* Emit data for .debug_abbrev. Note that this must be kept in
  1407. sync with out_debug_info below. */
  1408. static void
  1409. out_debug_abbrev (segT abbrev_seg,
  1410. segT info_seg ATTRIBUTE_UNUSED,
  1411. segT line_seg ATTRIBUTE_UNUSED)
  1412. {
  1413. subseg_set (abbrev_seg, 0);
  1414. out_uleb128 (1);
  1415. out_uleb128 (DW_TAG_compile_unit);
  1416. out_byte (DW_CHILDREN_no);
  1417. if (DWARF2_FORMAT (line_seg) == dwarf2_format_32bit)
  1418. out_abbrev (DW_AT_stmt_list, DW_FORM_data4);
  1419. else
  1420. out_abbrev (DW_AT_stmt_list, DW_FORM_data8);
  1421. if (all_segs->next == NULL)
  1422. {
  1423. out_abbrev (DW_AT_low_pc, DW_FORM_addr);
  1424. if (DWARF2_VERSION < 4)
  1425. out_abbrev (DW_AT_high_pc, DW_FORM_addr);
  1426. else
  1427. out_abbrev (DW_AT_high_pc, (sizeof_address == 4
  1428. ? DW_FORM_data4 : DW_FORM_data8));
  1429. }
  1430. else
  1431. {
  1432. if (DWARF2_FORMAT (info_seg) == dwarf2_format_32bit)
  1433. out_abbrev (DW_AT_ranges, DW_FORM_data4);
  1434. else
  1435. out_abbrev (DW_AT_ranges, DW_FORM_data8);
  1436. }
  1437. out_abbrev (DW_AT_name, DW_FORM_string);
  1438. out_abbrev (DW_AT_comp_dir, DW_FORM_string);
  1439. out_abbrev (DW_AT_producer, DW_FORM_string);
  1440. out_abbrev (DW_AT_language, DW_FORM_data2);
  1441. out_abbrev (0, 0);
  1442. /* Terminate the abbreviations for this compilation unit. */
  1443. out_byte (0);
  1444. }
  1445. /* Emit a description of this compilation unit for .debug_info. */
  1446. static void
  1447. out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
  1448. {
  1449. char producer[128];
  1450. const char *comp_dir;
  1451. const char *dirname;
  1452. expressionS exp;
  1453. symbolS *info_end;
  1454. char *p;
  1455. int len;
  1456. int sizeof_offset;
  1457. sizeof_offset = out_header (info_seg, &exp);
  1458. info_end = exp.X_add_symbol;
  1459. /* DWARF version. */
  1460. out_two (DWARF2_VERSION);
  1461. /* .debug_abbrev offset */
  1462. TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
  1463. /* Target address size. */
  1464. out_byte (sizeof_address);
  1465. /* DW_TAG_compile_unit DIE abbrev */
  1466. out_uleb128 (1);
  1467. /* DW_AT_stmt_list */
  1468. TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg),
  1469. (DWARF2_FORMAT (line_seg) == dwarf2_format_32bit
  1470. ? 4 : 8));
  1471. /* These two attributes are emitted if all of the code is contiguous. */
  1472. if (all_segs->next == NULL)
  1473. {
  1474. /* DW_AT_low_pc */
  1475. exp.X_op = O_symbol;
  1476. exp.X_add_symbol = all_segs->text_start;
  1477. exp.X_add_number = 0;
  1478. emit_expr (&exp, sizeof_address);
  1479. /* DW_AT_high_pc */
  1480. if (DWARF2_VERSION < 4)
  1481. exp.X_op = O_symbol;
  1482. else
  1483. {
  1484. exp.X_op = O_subtract;
  1485. exp.X_op_symbol = all_segs->text_start;
  1486. }
  1487. exp.X_add_symbol = all_segs->text_end;
  1488. exp.X_add_number = 0;
  1489. emit_expr (&exp, sizeof_address);
  1490. }
  1491. else
  1492. {
  1493. /* This attribute is emitted if the code is disjoint. */
  1494. /* DW_AT_ranges. */
  1495. TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg), sizeof_offset);
  1496. }
  1497. /* DW_AT_name. We don't have the actual file name that was present
  1498. on the command line, so assume files[1] is the main input file.
  1499. We're not supposed to get called unless at least one line number
  1500. entry was emitted, so this should always be defined. */
  1501. if (files_in_use == 0)
  1502. abort ();
  1503. if (files[1].dir)
  1504. {
  1505. dirname = remap_debug_filename (dirs[files[1].dir]);
  1506. len = strlen (dirname);
  1507. #ifdef TE_VMS
  1508. /* Already has trailing slash. */
  1509. p = frag_more (len);
  1510. memcpy (p, dirname, len);
  1511. #else
  1512. p = frag_more (len + 1);
  1513. memcpy (p, dirname, len);
  1514. INSERT_DIR_SEPARATOR (p, len);
  1515. #endif
  1516. }
  1517. len = strlen (files[1].filename) + 1;
  1518. p = frag_more (len);
  1519. memcpy (p, files[1].filename, len);
  1520. /* DW_AT_comp_dir */
  1521. comp_dir = remap_debug_filename (getpwd ());
  1522. len = strlen (comp_dir) + 1;
  1523. p = frag_more (len);
  1524. memcpy (p, comp_dir, len);
  1525. /* DW_AT_producer */
  1526. sprintf (producer, "GNU AS %s", VERSION);
  1527. len = strlen (producer) + 1;
  1528. p = frag_more (len);
  1529. memcpy (p, producer, len);
  1530. /* DW_AT_language. Yes, this is probably not really MIPS, but the
  1531. dwarf2 draft has no standard code for assembler. */
  1532. out_two (DW_LANG_Mips_Assembler);
  1533. symbol_set_value_now (info_end);
  1534. }
  1535. void
  1536. dwarf2_init (void)
  1537. {
  1538. last_seg_ptr = &all_segs;
  1539. }
  1540. /* Finish the dwarf2 debug sections. We emit .debug.line if there
  1541. were any .file/.loc directives, or --gdwarf2 was given, or if the
  1542. file has a non-empty .debug_info section and an empty .debug_line
  1543. section. If we emit .debug_line, and the .debug_info section is
  1544. empty, we also emit .debug_info, .debug_aranges and .debug_abbrev.
  1545. ALL_SEGS will be non-null if there were any .file/.loc directives,
  1546. or --gdwarf2 was given and there were any located instructions
  1547. emitted. */
  1548. void
  1549. dwarf2_finish (void)
  1550. {
  1551. segT line_seg;
  1552. struct line_seg *s;
  1553. segT info_seg;
  1554. int emit_other_sections = 0;
  1555. int empty_debug_line = 0;
  1556. info_seg = bfd_get_section_by_name (stdoutput, ".debug_info");
  1557. emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg);
  1558. line_seg = bfd_get_section_by_name (stdoutput, ".debug_line");
  1559. empty_debug_line = line_seg == NULL || !seg_not_empty_p (line_seg);
  1560. /* We can't construct a new debug_line section if we already have one.
  1561. Give an error. */
  1562. if (all_segs && !empty_debug_line)
  1563. as_fatal ("duplicate .debug_line sections");
  1564. if ((!all_segs && emit_other_sections)
  1565. || (!emit_other_sections && !empty_debug_line))
  1566. /* If there is no line information and no non-empty .debug_info
  1567. section, or if there is both a non-empty .debug_info and a non-empty
  1568. .debug_line, then we do nothing. */
  1569. return;
  1570. /* Calculate the size of an address for the target machine. */
  1571. sizeof_address = DWARF2_ADDR_SIZE (stdoutput);
  1572. /* Create and switch to the line number section. */
  1573. line_seg = subseg_new (".debug_line", 0);
  1574. bfd_set_section_flags (stdoutput, line_seg, SEC_READONLY | SEC_DEBUGGING);
  1575. /* For each subsection, chain the debug entries together. */
  1576. for (s = all_segs; s; s = s->next)
  1577. {
  1578. struct line_subseg *lss = s->head;
  1579. struct line_entry **ptail = lss->ptail;
  1580. while ((lss = lss->next) != NULL)
  1581. {
  1582. *ptail = lss->head;
  1583. ptail = lss->ptail;
  1584. }
  1585. }
  1586. out_debug_line (line_seg);
  1587. /* If this is assembler generated line info, and there is no
  1588. debug_info already, we need .debug_info and .debug_abbrev
  1589. sections as well. */
  1590. if (emit_other_sections)
  1591. {
  1592. segT abbrev_seg;
  1593. segT aranges_seg;
  1594. segT ranges_seg;
  1595. gas_assert (all_segs);
  1596. info_seg = subseg_new (".debug_info", 0);
  1597. abbrev_seg = subseg_new (".debug_abbrev", 0);
  1598. aranges_seg = subseg_new (".debug_aranges", 0);
  1599. bfd_set_section_flags (stdoutput, info_seg,
  1600. SEC_READONLY | SEC_DEBUGGING);
  1601. bfd_set_section_flags (stdoutput, abbrev_seg,
  1602. SEC_READONLY | SEC_DEBUGGING);
  1603. bfd_set_section_flags (stdoutput, aranges_seg,
  1604. SEC_READONLY | SEC_DEBUGGING);
  1605. record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1);
  1606. if (all_segs->next == NULL)
  1607. ranges_seg = NULL;
  1608. else
  1609. {
  1610. ranges_seg = subseg_new (".debug_ranges", 0);
  1611. bfd_set_section_flags (stdoutput, ranges_seg,
  1612. SEC_READONLY | SEC_DEBUGGING);
  1613. record_alignment (ranges_seg, ffs (2 * sizeof_address) - 1);
  1614. out_debug_ranges (ranges_seg);
  1615. }
  1616. out_debug_aranges (aranges_seg, info_seg);
  1617. out_debug_abbrev (abbrev_seg, info_seg, line_seg);
  1618. out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg);
  1619. }
  1620. }