1 /* dwarf2dbg.c - DWARF2 debug support
2 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 /* Logical line numbers can be controlled by the compiler via the
27 .loc FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
28 [epilogue_begin] [is_stmt VALUE] [isa VALUE]
32 #include "safe-ctype.h"
37 #ifdef HAVE_SYS_PARAM_H
38 #include <sys/param.h>
41 #define INT_MAX (int) (((unsigned) (-1)) >> 1)
45 #include "dwarf2dbg.h"
46 #include <filenames.h>
48 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
49 /* We need to decide which character to use as a directory separator.
50 Just because HAVE_DOS_BASED_FILE_SYSTEM is defined, it does not
51 necessarily mean that the backslash character is the one to use.
52 Some environments, eg Cygwin, can support both naming conventions.
53 So we use the heuristic that we only need to use the backslash if
54 the path is an absolute path starting with a DOS style drive
55 selector. eg C: or D: */
56 # define INSERT_DIR_SEPARATOR(string, offset) \
61 && string[1] == ':') \
62 string [offset] = '\\'; \
64 string [offset] = '/'; \
68 # define INSERT_DIR_SEPARATOR(string, offset) string[offset] = '/'
72 # define DWARF2_FORMAT(SEC) dwarf2_format_32bit
75 #ifndef DWARF2_ADDR_SIZE
76 # define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8)
79 #ifndef DWARF2_FILE_NAME
80 #define DWARF2_FILE_NAME(FILENAME, DIRNAME) FILENAME
83 #ifndef DWARF2_FILE_TIME_NAME
84 #define DWARF2_FILE_TIME_NAME(FILENAME,DIRNAME) 0
87 #ifndef DWARF2_FILE_SIZE_NAME
88 #define DWARF2_FILE_SIZE_NAME(FILENAME,DIRNAME) 0
93 #include "elf/dwarf2.h"
95 /* Since we can't generate the prolog until the body is complete, we
96 use three different subsegments for .debug_line: one holding the
97 prolog, one for the directory and filename info, and one for the
98 body ("statement program"). */
103 /* If linker relaxation might change offsets in the code, the DWARF special
104 opcodes and variable-length operands cannot be used. If this macro is
105 nonzero, use the DW_LNS_fixed_advance_pc opcode instead. */
106 #ifndef DWARF2_USE_FIXED_ADVANCE_PC
107 # define DWARF2_USE_FIXED_ADVANCE_PC 0
110 /* First special line opcde - leave room for the standard opcodes.
111 Note: If you want to change this, you'll have to update the
112 "standard_opcode_lengths" table that is emitted below in
114 #define DWARF2_LINE_OPCODE_BASE 13
116 #ifndef DWARF2_LINE_BASE
117 /* Minimum line offset in a special line info. opcode. This value
118 was chosen to give a reasonable range of values. */
119 # define DWARF2_LINE_BASE -5
122 /* Range of line offsets in a special line info. opcode. */
123 #ifndef DWARF2_LINE_RANGE
124 # define DWARF2_LINE_RANGE 14
127 #ifndef DWARF2_LINE_MIN_INSN_LENGTH
128 /* Define the architecture-dependent minimum instruction length (in
129 bytes). This value should be rather too small than too big. */
130 # define DWARF2_LINE_MIN_INSN_LENGTH 1
133 /* Flag that indicates the initial value of the is_stmt_start flag. */
134 #define DWARF2_LINE_DEFAULT_IS_STMT 1
136 /* Given a special op, return the line skip amount. */
137 #define SPECIAL_LINE(op) \
138 (((op) - DWARF2_LINE_OPCODE_BASE)%DWARF2_LINE_RANGE + DWARF2_LINE_BASE)
140 /* Given a special op, return the address skip amount (in units of
141 DWARF2_LINE_MIN_INSN_LENGTH. */
142 #define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)
144 /* The maximum address skip amount that can be encoded with a special op. */
145 #define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255)
148 struct line_entry
*next
;
150 struct dwarf2_line_info loc
;
154 struct line_subseg
*next
;
156 struct line_entry
*head
;
157 struct line_entry
**ptail
;
161 struct line_seg
*next
;
163 struct line_subseg
*head
;
168 /* Collects data for all line table entries during assembly. */
169 static struct line_seg
*all_segs
;
172 const char *filename
;
176 /* Table of files used by .debug_line. */
177 static struct file_entry
*files
;
178 static unsigned int files_in_use
;
179 static unsigned int files_allocated
;
181 /* Table of directories used by .debug_line. */
183 static unsigned int dirs_in_use
;
184 static unsigned int dirs_allocated
;
186 /* TRUE when we've seen a .loc directive recently. Used to avoid
187 doing work when there's nothing to do. */
188 bfd_boolean dwarf2_loc_directive_seen
;
190 /* TRUE when we're supposed to set the basic block mark whenever a
192 bfd_boolean dwarf2_loc_mark_labels
;
194 /* Current location as indicated by the most recent .loc directive. */
195 static struct dwarf2_line_info current
= {
197 DWARF2_LINE_DEFAULT_IS_STMT
? DWARF2_FLAG_IS_STMT
: 0
200 /* The size of an address on the target. */
201 static unsigned int sizeof_address
;
203 static unsigned int get_filenum (const char *, unsigned int);
205 #ifndef TC_DWARF2_EMIT_OFFSET
206 #define TC_DWARF2_EMIT_OFFSET generic_dwarf2_emit_offset
208 /* Create an offset to .dwarf2_*. */
211 generic_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
215 expr
.X_op
= O_symbol
;
216 expr
.X_add_symbol
= symbol
;
217 expr
.X_add_number
= 0;
218 emit_expr (&expr
, size
);
222 /* Find or create an entry for SEG+SUBSEG in ALL_SEGS. */
224 static struct line_subseg
*
225 get_line_subseg (segT seg
, subsegT subseg
)
227 static segT last_seg
;
228 static subsegT last_subseg
;
229 static struct line_subseg
*last_line_subseg
;
231 struct line_seg
**ps
, *s
;
232 struct line_subseg
**pss
, *ss
;
234 if (seg
== last_seg
&& subseg
== last_subseg
)
235 return last_line_subseg
;
237 for (ps
= &all_segs
; (s
= *ps
) != NULL
; ps
= &s
->next
)
241 s
= (struct line_seg
*) xmalloc (sizeof (*s
));
248 for (pss
= &s
->head
; (ss
= *pss
) != NULL
; pss
= &ss
->next
)
250 if (ss
->subseg
== subseg
)
252 if (ss
->subseg
> subseg
)
256 ss
= (struct line_subseg
*) xmalloc (sizeof (*ss
));
260 ss
->ptail
= &ss
->head
;
265 last_subseg
= subseg
;
266 last_line_subseg
= ss
;
271 /* Record an entry for LOC occurring at LABEL. */
274 dwarf2_gen_line_info_1 (symbolS
*label
, struct dwarf2_line_info
*loc
)
276 struct line_subseg
*ss
;
277 struct line_entry
*e
;
279 e
= (struct line_entry
*) xmalloc (sizeof (*e
));
284 ss
= get_line_subseg (now_seg
, now_subseg
);
286 ss
->ptail
= &e
->next
;
289 /* Record an entry for LOC occurring at OFS within the current fragment. */
292 dwarf2_gen_line_info (addressT ofs
, struct dwarf2_line_info
*loc
)
294 static unsigned int line
= -1;
295 static unsigned int filenum
= -1;
299 /* Early out for as-yet incomplete location information. */
300 if (loc
->filenum
== 0 || loc
->line
== 0)
303 /* Don't emit sequences of line symbols for the same line when the
304 symbols apply to assembler code. It is necessary to emit
305 duplicate line symbols when a compiler asks for them, because GDB
306 uses them to determine the end of the prologue. */
307 if (debug_type
== DEBUG_DWARF2
308 && line
== loc
->line
&& filenum
== loc
->filenum
)
312 filenum
= loc
->filenum
;
314 sym
= symbol_temp_new (now_seg
, ofs
, frag_now
);
315 dwarf2_gen_line_info_1 (sym
, loc
);
318 /* Returns the current source information. If .file directives have
319 been encountered, the info for the corresponding source file is
320 returned. Otherwise, the info for the assembly source file is
324 dwarf2_where (struct dwarf2_line_info
*line
)
326 if (debug_type
== DEBUG_DWARF2
)
329 as_where (&filename
, &line
->line
);
330 line
->filenum
= get_filenum (filename
, 0);
332 line
->flags
= DWARF2_FLAG_IS_STMT
;
333 line
->isa
= current
.isa
;
339 /* A hook to allow the target backend to inform the line number state
340 machine of isa changes when assembler debug info is enabled. */
343 dwarf2_set_isa (unsigned int isa
)
348 /* Called for each machine instruction, or relatively atomic group of
349 machine instructions (ie built-in macro). The instruction or group
350 is SIZE bytes in length. If dwarf2 line number generation is called
351 for, emit a line statement appropriately. */
354 dwarf2_emit_insn (int size
)
356 struct dwarf2_line_info loc
;
358 if (!dwarf2_loc_directive_seen
&& debug_type
!= DEBUG_DWARF2
)
363 dwarf2_gen_line_info (frag_now_fix () - size
, &loc
);
364 dwarf2_consume_line_info ();
367 /* Called after the current line information has been either used with
368 dwarf2_gen_line_info or saved with a machine instruction for later use.
369 This resets the state of the line number information to reflect that
373 dwarf2_consume_line_info (void)
375 /* Unless we generate DWARF2 debugging information for each
376 assembler line, we only emit one line symbol for one LOC. */
377 dwarf2_loc_directive_seen
= FALSE
;
379 current
.flags
&= ~(DWARF2_FLAG_BASIC_BLOCK
380 | DWARF2_FLAG_PROLOGUE_END
381 | DWARF2_FLAG_EPILOGUE_BEGIN
);
384 /* Called for each (preferably code) label. If dwarf2_loc_mark_labels
385 is enabled, emit a basic block marker. */
388 dwarf2_emit_label (symbolS
*label
)
390 struct dwarf2_line_info loc
;
392 if (!dwarf2_loc_mark_labels
)
394 if (S_GET_SEGMENT (label
) != now_seg
)
396 if (!(bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
))
398 if (files_in_use
== 0 && debug_type
!= DEBUG_DWARF2
)
403 loc
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
405 dwarf2_gen_line_info_1 (label
, &loc
);
406 dwarf2_consume_line_info ();
409 /* Get a .debug_line file number for FILENAME. If NUM is nonzero,
410 allocate it on that file table slot, otherwise return the first
414 get_filenum (const char *filename
, unsigned int num
)
416 static unsigned int last_used
, last_used_dir_len
;
421 if (num
== 0 && last_used
)
423 if (! files
[last_used
].dir
424 && strcmp (filename
, files
[last_used
].filename
) == 0)
426 if (files
[last_used
].dir
427 && strncmp (filename
, dirs
[files
[last_used
].dir
],
428 last_used_dir_len
) == 0
429 && IS_DIR_SEPARATOR (filename
[last_used_dir_len
])
430 && strcmp (filename
+ last_used_dir_len
+ 1,
431 files
[last_used
].filename
) == 0)
435 file
= lbasename (filename
);
436 /* Don't make empty string from / or A: from A:/ . */
437 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
438 if (file
<= filename
+ 3)
441 if (file
== filename
+ 1)
444 dir_len
= file
- filename
;
449 #ifndef DWARF2_DIR_SHOULD_END_WITH_SEPARATOR
452 for (dir
= 1; dir
< dirs_in_use
; ++dir
)
453 if (strncmp (filename
, dirs
[dir
], dir_len
) == 0
454 && dirs
[dir
][dir_len
] == '\0')
457 if (dir
>= dirs_in_use
)
459 if (dir
>= dirs_allocated
)
461 dirs_allocated
= dir
+ 32;
463 xrealloc (dirs
, (dir
+ 32) * sizeof (const char *));
466 dirs
[dir
] = xmalloc (dir_len
+ 1);
467 memcpy (dirs
[dir
], filename
, dir_len
);
468 dirs
[dir
][dir_len
] = '\0';
469 dirs_in_use
= dir
+ 1;
475 for (i
= 1; i
< files_in_use
; ++i
)
476 if (files
[i
].dir
== dir
478 && strcmp (file
, files
[i
].filename
) == 0)
481 last_used_dir_len
= dir_len
;
488 if (i
>= files_allocated
)
490 unsigned int old
= files_allocated
;
492 files_allocated
= i
+ 32;
493 files
= (struct file_entry
*)
494 xrealloc (files
, (i
+ 32) * sizeof (struct file_entry
));
496 memset (files
+ old
, 0, (i
+ 32 - old
) * sizeof (struct file_entry
));
499 files
[i
].filename
= num
? file
: xstrdup (file
);
501 if (files_in_use
< i
+ 1)
502 files_in_use
= i
+ 1;
504 last_used_dir_len
= dir_len
;
509 /* Handle two forms of .file directive:
510 - Pass .file "source.c" to s_app_file
511 - Handle .file 1 "source.c" by adding an entry to the DWARF-2 file table
513 If an entry is added to the file table, return a pointer to the filename. */
516 dwarf2_directive_file (int dummy ATTRIBUTE_UNUSED
)
522 /* Continue to accept a bare string and pass it off. */
524 if (*input_line_pointer
== '"')
530 num
= get_absolute_expression ();
531 filename
= demand_copy_C_string (&filename_len
);
532 if (filename
== NULL
)
534 demand_empty_rest_of_line ();
538 as_bad (_("file number less than one"));
542 /* A .file directive implies compiler generated debug information is
543 being supplied. Turn off gas generated debug info. */
544 debug_type
= DEBUG_NONE
;
546 if (num
< (int) files_in_use
&& files
[num
].filename
!= 0)
548 as_bad (_("file number %ld already allocated"), (long) num
);
552 get_filenum (filename
, num
);
558 dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED
)
560 offsetT filenum
, line
;
562 /* If we see two .loc directives in a row, force the first one to be
564 if (dwarf2_loc_directive_seen
)
565 dwarf2_emit_insn (0);
567 filenum
= get_absolute_expression ();
569 line
= get_absolute_expression ();
573 as_bad (_("file number less than one"));
576 if (filenum
>= (int) files_in_use
|| files
[filenum
].filename
== 0)
578 as_bad (_("unassigned file number %ld"), (long) filenum
);
582 current
.filenum
= filenum
;
588 if (files
[filenum
].dir
)
590 size_t dir_len
= strlen (dirs
[files
[filenum
].dir
]);
591 size_t file_len
= strlen (files
[filenum
].filename
);
592 char *cp
= (char *) alloca (dir_len
+ 1 + file_len
+ 1);
594 memcpy (cp
, dirs
[files
[filenum
].dir
], dir_len
);
595 INSERT_DIR_SEPARATOR (cp
, dir_len
);
596 memcpy (cp
+ dir_len
+ 1, files
[filenum
].filename
, file_len
);
597 cp
[dir_len
+ file_len
+ 1] = '\0';
598 listing_source_file (cp
);
601 listing_source_file (files
[filenum
].filename
);
602 listing_source_line (line
);
607 if (ISDIGIT (*input_line_pointer
))
609 current
.column
= get_absolute_expression ();
613 while (ISALPHA (*input_line_pointer
))
618 p
= input_line_pointer
;
619 c
= get_symbol_end ();
621 if (strcmp (p
, "basic_block") == 0)
623 current
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
624 *input_line_pointer
= c
;
626 else if (strcmp (p
, "prologue_end") == 0)
628 current
.flags
|= DWARF2_FLAG_PROLOGUE_END
;
629 *input_line_pointer
= c
;
631 else if (strcmp (p
, "epilogue_begin") == 0)
633 current
.flags
|= DWARF2_FLAG_EPILOGUE_BEGIN
;
634 *input_line_pointer
= c
;
636 else if (strcmp (p
, "is_stmt") == 0)
638 *input_line_pointer
= c
;
639 value
= get_absolute_expression ();
641 current
.flags
&= ~DWARF2_FLAG_IS_STMT
;
643 current
.flags
|= DWARF2_FLAG_IS_STMT
;
646 as_bad (_("is_stmt value not 0 or 1"));
650 else if (strcmp (p
, "isa") == 0)
652 *input_line_pointer
= c
;
653 value
= get_absolute_expression ();
658 as_bad (_("isa number less than zero"));
664 as_bad (_("unknown .loc sub-directive `%s'"), p
);
665 *input_line_pointer
= c
;
672 demand_empty_rest_of_line ();
673 dwarf2_loc_directive_seen
= TRUE
;
674 debug_type
= DEBUG_NONE
;
678 dwarf2_directive_loc_mark_labels (int dummy ATTRIBUTE_UNUSED
)
680 offsetT value
= get_absolute_expression ();
682 if (value
!= 0 && value
!= 1)
684 as_bad (_("expected 0 or 1"));
685 ignore_rest_of_line ();
689 dwarf2_loc_mark_labels
= value
!= 0;
690 demand_empty_rest_of_line ();
695 first_frag_for_seg (segT seg
)
697 return seg_info (seg
)->frchainP
->frch_root
;
701 last_frag_for_seg (segT seg
)
703 frchainS
*f
= seg_info (seg
)->frchainP
;
705 while (f
->frch_next
!= NULL
)
711 /* Emit a single byte into the current segment. */
716 FRAG_APPEND_1_CHAR (byte
);
719 /* Emit a statement program opcode into the current segment. */
727 /* Emit a two-byte word into the current segment. */
732 md_number_to_chars (frag_more (2), data
, 2);
735 /* Emit a four byte word into the current segment. */
740 md_number_to_chars (frag_more (4), data
, 4);
743 /* Emit an unsigned "little-endian base 128" number. */
746 out_uleb128 (addressT value
)
748 output_leb128 (frag_more (sizeof_leb128 (value
, 0)), value
, 0);
751 /* Emit a tuple for .debug_abbrev. */
754 out_abbrev (int name
, int form
)
760 /* Get the size of a fragment. */
763 get_frag_fix (fragS
*frag
, segT seg
)
770 /* If a fragment is the last in the chain, special measures must be
771 taken to find its size before relaxation, since it may be pending
772 on some subsegment chain. */
773 for (fr
= seg_info (seg
)->frchainP
; fr
; fr
= fr
->frch_next
)
774 if (fr
->frch_last
== frag
)
775 return (char *) obstack_next_free (&fr
->frch_obstack
) - frag
->fr_literal
;
780 /* Set an absolute address (may result in a relocation entry). */
783 out_set_addr (symbolS
*sym
)
787 out_opcode (DW_LNS_extended_op
);
788 out_uleb128 (sizeof_address
+ 1);
790 out_opcode (DW_LNE_set_address
);
791 expr
.X_op
= O_symbol
;
792 expr
.X_add_symbol
= sym
;
793 expr
.X_add_number
= 0;
794 emit_expr (&expr
, sizeof_address
);
797 #if DWARF2_LINE_MIN_INSN_LENGTH > 1
798 static void scale_addr_delta (addressT
*);
801 scale_addr_delta (addressT
*addr_delta
)
803 static int printed_this
= 0;
804 if (*addr_delta
% DWARF2_LINE_MIN_INSN_LENGTH
!= 0)
807 as_bad("unaligned opcodes detected in executable segment");
810 *addr_delta
/= DWARF2_LINE_MIN_INSN_LENGTH
;
813 #define scale_addr_delta(A)
816 /* Encode a pair of line and address skips as efficiently as possible.
817 Note that the line skip is signed, whereas the address skip is unsigned.
819 The following two routines *must* be kept in sync. This is
820 enforced by making emit_inc_line_addr abort if we do not emit
821 exactly the expected number of bytes. */
824 size_inc_line_addr (int line_delta
, addressT addr_delta
)
826 unsigned int tmp
, opcode
;
829 /* Scale the address delta by the minimum instruction length. */
830 scale_addr_delta (&addr_delta
);
832 /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
833 We cannot use special opcodes here, since we want the end_sequence
834 to emit the matrix entry. */
835 if (line_delta
== INT_MAX
)
837 if (addr_delta
== MAX_SPECIAL_ADDR_DELTA
)
840 len
= 1 + sizeof_leb128 (addr_delta
, 0);
844 /* Bias the line delta by the base. */
845 tmp
= line_delta
- DWARF2_LINE_BASE
;
847 /* If the line increment is out of range of a special opcode, we
848 must encode it with DW_LNS_advance_line. */
849 if (tmp
>= DWARF2_LINE_RANGE
)
851 len
= 1 + sizeof_leb128 (line_delta
, 1);
853 tmp
= 0 - DWARF2_LINE_BASE
;
856 /* Bias the opcode by the special opcode base. */
857 tmp
+= DWARF2_LINE_OPCODE_BASE
;
859 /* Avoid overflow when addr_delta is large. */
860 if (addr_delta
< 256 + MAX_SPECIAL_ADDR_DELTA
)
862 /* Try using a special opcode. */
863 opcode
= tmp
+ addr_delta
* DWARF2_LINE_RANGE
;
867 /* Try using DW_LNS_const_add_pc followed by special op. */
868 opcode
= tmp
+ (addr_delta
- MAX_SPECIAL_ADDR_DELTA
) * DWARF2_LINE_RANGE
;
873 /* Otherwise use DW_LNS_advance_pc. */
874 len
+= 1 + sizeof_leb128 (addr_delta
, 0);
876 /* DW_LNS_copy or special opcode. */
883 emit_inc_line_addr (int line_delta
, addressT addr_delta
, char *p
, int len
)
885 unsigned int tmp
, opcode
;
889 /* Line number sequences cannot go backward in addresses. This means
890 we've incorrectly ordered the statements in the sequence. */
891 assert ((offsetT
) addr_delta
>= 0);
893 /* Scale the address delta by the minimum instruction length. */
894 scale_addr_delta (&addr_delta
);
896 /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence.
897 We cannot use special opcodes here, since we want the end_sequence
898 to emit the matrix entry. */
899 if (line_delta
== INT_MAX
)
901 if (addr_delta
== MAX_SPECIAL_ADDR_DELTA
)
902 *p
++ = DW_LNS_const_add_pc
;
905 *p
++ = DW_LNS_advance_pc
;
906 p
+= output_leb128 (p
, addr_delta
, 0);
909 *p
++ = DW_LNS_extended_op
;
911 *p
++ = DW_LNE_end_sequence
;
915 /* Bias the line delta by the base. */
916 tmp
= line_delta
- DWARF2_LINE_BASE
;
918 /* If the line increment is out of range of a special opcode, we
919 must encode it with DW_LNS_advance_line. */
920 if (tmp
>= DWARF2_LINE_RANGE
)
922 *p
++ = DW_LNS_advance_line
;
923 p
+= output_leb128 (p
, line_delta
, 1);
926 tmp
= 0 - DWARF2_LINE_BASE
;
930 /* Prettier, I think, to use DW_LNS_copy instead of a "line +0, addr +0"
932 if (line_delta
== 0 && addr_delta
== 0)
938 /* Bias the opcode by the special opcode base. */
939 tmp
+= DWARF2_LINE_OPCODE_BASE
;
941 /* Avoid overflow when addr_delta is large. */
942 if (addr_delta
< 256 + MAX_SPECIAL_ADDR_DELTA
)
944 /* Try using a special opcode. */
945 opcode
= tmp
+ addr_delta
* DWARF2_LINE_RANGE
;
952 /* Try using DW_LNS_const_add_pc followed by special op. */
953 opcode
= tmp
+ (addr_delta
- MAX_SPECIAL_ADDR_DELTA
) * DWARF2_LINE_RANGE
;
956 *p
++ = DW_LNS_const_add_pc
;
962 /* Otherwise use DW_LNS_advance_pc. */
963 *p
++ = DW_LNS_advance_pc
;
964 p
+= output_leb128 (p
, addr_delta
, 0);
975 /* Handy routine to combine calls to the above two routines. */
978 out_inc_line_addr (int line_delta
, addressT addr_delta
)
980 int len
= size_inc_line_addr (line_delta
, addr_delta
);
981 emit_inc_line_addr (line_delta
, addr_delta
, frag_more (len
), len
);
984 /* Write out an alternative form of line and address skips using
985 DW_LNS_fixed_advance_pc opcodes. This uses more space than the default
986 line and address information, but it is required if linker relaxation
987 could change the code offsets. The following two routines *must* be
991 size_fixed_inc_line_addr (int line_delta
, addressT addr_delta
)
995 /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence. */
996 if (line_delta
!= INT_MAX
)
997 len
= 1 + sizeof_leb128 (line_delta
, 1);
999 if (addr_delta
> 50000)
1001 /* DW_LNS_extended_op */
1002 len
+= 1 + sizeof_leb128 (sizeof_address
+ 1, 0);
1003 /* DW_LNE_set_address */
1004 len
+= 1 + sizeof_address
;
1007 /* DW_LNS_fixed_advance_pc */
1010 if (line_delta
== INT_MAX
)
1011 /* DW_LNS_extended_op + DW_LNE_end_sequence */
1021 emit_fixed_inc_line_addr (int line_delta
, addressT addr_delta
, fragS
*frag
,
1026 char *end
= p
+ len
;
1028 /* Line number sequences cannot go backward in addresses. This means
1029 we've incorrectly ordered the statements in the sequence. */
1030 assert ((offsetT
) addr_delta
>= 0);
1032 /* INT_MAX is a signal that this is actually a DW_LNE_end_sequence. */
1033 if (line_delta
!= INT_MAX
)
1035 *p
++ = DW_LNS_advance_line
;
1036 p
+= output_leb128 (p
, line_delta
, 1);
1039 exp
= symbol_get_value_expression (frag
->fr_symbol
);
1040 line_seg
= subseg_get (".debug_line", 0);
1042 /* The DW_LNS_fixed_advance_pc opcode has a 2-byte operand so it can
1043 advance the address by at most 64K. Linker relaxation (without
1044 which this function would not be used) could change the operand by
1045 an unknown amount. If the address increment is getting close to
1046 the limit, just reset the address. */
1047 if (addr_delta
> 50000)
1052 assert (exp
->X_op
= O_subtract
);
1053 to_sym
= exp
->X_add_symbol
;
1055 *p
++ = DW_LNS_extended_op
;
1056 p
+= output_leb128 (p
, sizeof_address
+ 1, 0);
1057 *p
++ = DW_LNE_set_address
;
1058 expr
.X_op
= O_symbol
;
1059 expr
.X_add_symbol
= to_sym
;
1060 expr
.X_add_number
= 0;
1061 subseg_change (line_seg
, 0);
1062 emit_expr_fix (&expr
, sizeof_address
, frag
, p
);
1063 p
+= sizeof_address
;
1067 *p
++ = DW_LNS_fixed_advance_pc
;
1068 subseg_change (line_seg
, 0);
1069 emit_expr_fix (exp
, 2, frag
, p
);
1073 if (line_delta
== INT_MAX
)
1075 *p
++ = DW_LNS_extended_op
;
1077 *p
++ = DW_LNE_end_sequence
;
1085 /* Generate a variant frag that we can use to relax address/line
1086 increments between fragments of the target segment. */
1089 relax_inc_line_addr (int line_delta
, symbolS
*to_sym
, symbolS
*from_sym
)
1094 expr
.X_op
= O_subtract
;
1095 expr
.X_add_symbol
= to_sym
;
1096 expr
.X_op_symbol
= from_sym
;
1097 expr
.X_add_number
= 0;
1099 /* The maximum size of the frag is the line delta with a maximum
1100 sized address delta. */
1101 if (DWARF2_USE_FIXED_ADVANCE_PC
)
1102 max_chars
= size_fixed_inc_line_addr (line_delta
,
1103 -DWARF2_LINE_MIN_INSN_LENGTH
);
1105 max_chars
= size_inc_line_addr (line_delta
, -DWARF2_LINE_MIN_INSN_LENGTH
);
1107 frag_var (rs_dwarf2dbg
, max_chars
, max_chars
, 1,
1108 make_expr_symbol (&expr
), line_delta
, NULL
);
1111 /* The function estimates the size of a rs_dwarf2dbg variant frag
1112 based on the current values of the symbols. It is called before
1113 the relaxation loop. We set fr_subtype to the expected length. */
1116 dwarf2dbg_estimate_size_before_relax (fragS
*frag
)
1121 addr_delta
= resolve_symbol_value (frag
->fr_symbol
);
1122 if (DWARF2_USE_FIXED_ADVANCE_PC
)
1123 size
= size_fixed_inc_line_addr (frag
->fr_offset
, addr_delta
);
1125 size
= size_inc_line_addr (frag
->fr_offset
, addr_delta
);
1127 frag
->fr_subtype
= size
;
1132 /* This function relaxes a rs_dwarf2dbg variant frag based on the
1133 current values of the symbols. fr_subtype is the current length
1134 of the frag. This returns the change in frag length. */
1137 dwarf2dbg_relax_frag (fragS
*frag
)
1139 int old_size
, new_size
;
1141 old_size
= frag
->fr_subtype
;
1142 new_size
= dwarf2dbg_estimate_size_before_relax (frag
);
1144 return new_size
- old_size
;
1147 /* This function converts a rs_dwarf2dbg variant frag into a normal
1148 fill frag. This is called after all relaxation has been done.
1149 fr_subtype will be the desired length of the frag. */
1152 dwarf2dbg_convert_frag (fragS
*frag
)
1156 addr_diff
= resolve_symbol_value (frag
->fr_symbol
);
1158 /* fr_var carries the max_chars that we created the fragment with.
1159 fr_subtype carries the current expected length. We must, of
1160 course, have allocated enough memory earlier. */
1161 assert (frag
->fr_var
>= (int) frag
->fr_subtype
);
1163 if (DWARF2_USE_FIXED_ADVANCE_PC
)
1164 emit_fixed_inc_line_addr (frag
->fr_offset
, addr_diff
, frag
,
1165 frag
->fr_literal
+ frag
->fr_fix
,
1168 emit_inc_line_addr (frag
->fr_offset
, addr_diff
,
1169 frag
->fr_literal
+ frag
->fr_fix
, frag
->fr_subtype
);
1171 frag
->fr_fix
+= frag
->fr_subtype
;
1172 frag
->fr_type
= rs_fill
;
1174 frag
->fr_offset
= 0;
1177 /* Generate .debug_line content for the chain of line number entries
1178 beginning at E, for segment SEG. */
1181 process_entries (segT seg
, struct line_entry
*e
)
1183 unsigned filenum
= 1;
1185 unsigned column
= 0;
1187 unsigned flags
= DWARF2_LINE_DEFAULT_IS_STMT
? DWARF2_FLAG_IS_STMT
: 0;
1188 fragS
*last_frag
= NULL
, *frag
;
1189 addressT last_frag_ofs
= 0, frag_ofs
;
1190 symbolS
*last_lab
= NULL
, *lab
;
1191 struct line_entry
*next
;
1197 if (filenum
!= e
->loc
.filenum
)
1199 filenum
= e
->loc
.filenum
;
1200 out_opcode (DW_LNS_set_file
);
1201 out_uleb128 (filenum
);
1204 if (column
!= e
->loc
.column
)
1206 column
= e
->loc
.column
;
1207 out_opcode (DW_LNS_set_column
);
1208 out_uleb128 (column
);
1211 if (isa
!= e
->loc
.isa
)
1214 out_opcode (DW_LNS_set_isa
);
1218 if ((e
->loc
.flags
^ flags
) & DWARF2_FLAG_IS_STMT
)
1220 flags
= e
->loc
.flags
;
1221 out_opcode (DW_LNS_negate_stmt
);
1224 if (e
->loc
.flags
& DWARF2_FLAG_BASIC_BLOCK
)
1225 out_opcode (DW_LNS_set_basic_block
);
1227 if (e
->loc
.flags
& DWARF2_FLAG_PROLOGUE_END
)
1228 out_opcode (DW_LNS_set_prologue_end
);
1230 if (e
->loc
.flags
& DWARF2_FLAG_EPILOGUE_BEGIN
)
1231 out_opcode (DW_LNS_set_epilogue_begin
);
1233 /* Don't try to optimize away redundant entries; gdb wants two
1234 entries for a function where the code starts on the same line as
1235 the {, and there's no way to identify that case here. Trust gcc
1236 to optimize appropriately. */
1237 line_delta
= e
->loc
.line
- line
;
1239 frag
= symbol_get_frag (lab
);
1240 frag_ofs
= S_GET_VALUE (lab
);
1242 if (last_frag
== NULL
)
1245 out_inc_line_addr (line_delta
, 0);
1247 else if (frag
== last_frag
&& ! DWARF2_USE_FIXED_ADVANCE_PC
)
1248 out_inc_line_addr (line_delta
, frag_ofs
- last_frag_ofs
);
1250 relax_inc_line_addr (line_delta
, lab
, last_lab
);
1255 last_frag_ofs
= frag_ofs
;
1263 /* Emit a DW_LNE_end_sequence for the end of the section. */
1264 frag
= last_frag_for_seg (seg
);
1265 frag_ofs
= get_frag_fix (frag
, seg
);
1266 if (frag
== last_frag
&& ! DWARF2_USE_FIXED_ADVANCE_PC
)
1267 out_inc_line_addr (INT_MAX
, frag_ofs
- last_frag_ofs
);
1270 lab
= symbol_temp_new (seg
, frag_ofs
, frag
);
1271 relax_inc_line_addr (INT_MAX
, lab
, last_lab
);
1275 /* Emit the directory and file tables for .debug_line. */
1278 out_file_list (void)
1285 /* Emit directory list. */
1286 for (i
= 1; i
< dirs_in_use
; ++i
)
1288 dir
= remap_debug_filename (dirs
[i
]);
1289 size
= strlen (dir
) + 1;
1290 cp
= frag_more (size
);
1291 memcpy (cp
, dir
, size
);
1296 for (i
= 1; i
< files_in_use
; ++i
)
1298 const char *fullfilename
;
1300 if (files
[i
].filename
== NULL
)
1302 as_bad (_("unassigned file number %ld"), (long) i
);
1303 /* Prevent a crash later, particularly for file 1. */
1304 files
[i
].filename
= "";
1308 fullfilename
= DWARF2_FILE_NAME (files
[i
].filename
,
1309 files
[i
].dir
? dirs
[files
[i
].dir
] : "");
1310 size
= strlen (fullfilename
) + 1;
1311 cp
= frag_more (size
);
1312 memcpy (cp
, fullfilename
, size
);
1314 out_uleb128 (files
[i
].dir
); /* directory number */
1315 /* Output the last modification timestamp. */
1316 out_uleb128 (DWARF2_FILE_TIME_NAME (files
[i
].filename
,
1317 files
[i
].dir
? dirs
[files
[i
].dir
] : ""));
1318 /* Output the filesize. */
1319 out_uleb128 (DWARF2_FILE_SIZE_NAME (files
[i
].filename
,
1320 files
[i
].dir
? dirs
[files
[i
].dir
] : ""));
1323 /* Terminate filename list. */
1327 /* Switch to SEC and output a header length field. Return the size of
1328 offsets used in SEC. The caller must set EXPR->X_add_symbol value
1329 to the end of the section. */
1332 out_header (asection
*sec
, expressionS
*expr
)
1337 subseg_set (sec
, 0);
1338 start_sym
= symbol_temp_new_now ();;
1339 end_sym
= symbol_temp_make ();
1341 /* Total length of the information. */
1342 expr
->X_op
= O_subtract
;
1343 expr
->X_add_symbol
= end_sym
;
1344 expr
->X_op_symbol
= start_sym
;
1346 switch (DWARF2_FORMAT (sec
))
1348 case dwarf2_format_32bit
:
1349 expr
->X_add_number
= -4;
1350 emit_expr (expr
, 4);
1353 case dwarf2_format_64bit
:
1354 expr
->X_add_number
= -12;
1356 emit_expr (expr
, 8);
1359 case dwarf2_format_64bit_irix
:
1360 expr
->X_add_number
= -8;
1361 emit_expr (expr
, 8);
1365 as_fatal (_("internal error: unknown dwarf2 format"));
1369 /* Emit the collected .debug_line data. */
1372 out_debug_line (segT line_seg
)
1375 symbolS
*prologue_end
;
1380 sizeof_offset
= out_header (line_seg
, &expr
);
1381 line_end
= expr
.X_add_symbol
;
1386 /* Length of the prologue following this length. */
1387 prologue_end
= symbol_temp_make ();
1388 expr
.X_add_symbol
= prologue_end
;
1389 expr
.X_add_number
= - (4 + 2 + 4);
1390 emit_expr (&expr
, sizeof_offset
);
1392 /* Parameters of the state machine. */
1393 out_byte (DWARF2_LINE_MIN_INSN_LENGTH
);
1394 out_byte (DWARF2_LINE_DEFAULT_IS_STMT
);
1395 out_byte (DWARF2_LINE_BASE
);
1396 out_byte (DWARF2_LINE_RANGE
);
1397 out_byte (DWARF2_LINE_OPCODE_BASE
);
1399 /* Standard opcode lengths. */
1400 out_byte (0); /* DW_LNS_copy */
1401 out_byte (1); /* DW_LNS_advance_pc */
1402 out_byte (1); /* DW_LNS_advance_line */
1403 out_byte (1); /* DW_LNS_set_file */
1404 out_byte (1); /* DW_LNS_set_column */
1405 out_byte (0); /* DW_LNS_negate_stmt */
1406 out_byte (0); /* DW_LNS_set_basic_block */
1407 out_byte (0); /* DW_LNS_const_add_pc */
1408 out_byte (1); /* DW_LNS_fixed_advance_pc */
1409 out_byte (0); /* DW_LNS_set_prologue_end */
1410 out_byte (0); /* DW_LNS_set_epilogue_begin */
1411 out_byte (1); /* DW_LNS_set_isa */
1415 symbol_set_value_now (prologue_end
);
1417 /* For each section, emit a statement program. */
1418 for (s
= all_segs
; s
; s
= s
->next
)
1419 process_entries (s
->seg
, s
->head
->head
);
1421 symbol_set_value_now (line_end
);
1425 out_debug_ranges (segT ranges_seg
)
1427 unsigned int addr_size
= sizeof_address
;
1432 subseg_set (ranges_seg
, 0);
1434 /* Base Address Entry. */
1435 for (i
= 0; i
< addr_size
; i
++)
1437 for (i
= 0; i
< addr_size
; i
++)
1440 /* Range List Entry. */
1441 for (s
= all_segs
; s
; s
= s
->next
)
1446 frag
= first_frag_for_seg (s
->seg
);
1447 beg
= symbol_temp_new (s
->seg
, 0, frag
);
1448 s
->text_start
= beg
;
1450 frag
= last_frag_for_seg (s
->seg
);
1451 end
= symbol_temp_new (s
->seg
, get_frag_fix (frag
, s
->seg
), frag
);
1454 expr
.X_op
= O_symbol
;
1455 expr
.X_add_symbol
= beg
;
1456 expr
.X_add_number
= 0;
1457 emit_expr (&expr
, addr_size
);
1459 expr
.X_op
= O_symbol
;
1460 expr
.X_add_symbol
= end
;
1461 expr
.X_add_number
= 0;
1462 emit_expr (&expr
, addr_size
);
1465 /* End of Range Entry. */
1466 for (i
= 0; i
< addr_size
; i
++)
1468 for (i
= 0; i
< addr_size
; i
++)
1472 /* Emit data for .debug_aranges. */
1475 out_debug_aranges (segT aranges_seg
, segT info_seg
)
1477 unsigned int addr_size
= sizeof_address
;
1480 symbolS
*aranges_end
;
1484 sizeof_offset
= out_header (aranges_seg
, &expr
);
1485 aranges_end
= expr
.X_add_symbol
;
1490 /* Offset to .debug_info. */
1491 TC_DWARF2_EMIT_OFFSET (section_symbol (info_seg
), sizeof_offset
);
1493 /* Size of an address (offset portion). */
1494 out_byte (addr_size
);
1496 /* Size of a segment descriptor. */
1499 /* Align the header. */
1500 frag_align (ffs (2 * addr_size
) - 1, 0, 0);
1502 for (s
= all_segs
; s
; s
= s
->next
)
1507 frag
= first_frag_for_seg (s
->seg
);
1508 beg
= symbol_temp_new (s
->seg
, 0, frag
);
1509 s
->text_start
= beg
;
1511 frag
= last_frag_for_seg (s
->seg
);
1512 end
= symbol_temp_new (s
->seg
, get_frag_fix (frag
, s
->seg
), frag
);
1515 expr
.X_op
= O_symbol
;
1516 expr
.X_add_symbol
= beg
;
1517 expr
.X_add_number
= 0;
1518 emit_expr (&expr
, addr_size
);
1520 expr
.X_op
= O_subtract
;
1521 expr
.X_add_symbol
= end
;
1522 expr
.X_op_symbol
= beg
;
1523 expr
.X_add_number
= 0;
1524 emit_expr (&expr
, addr_size
);
1527 p
= frag_more (2 * addr_size
);
1528 md_number_to_chars (p
, 0, addr_size
);
1529 md_number_to_chars (p
+ addr_size
, 0, addr_size
);
1531 symbol_set_value_now (aranges_end
);
1534 /* Emit data for .debug_abbrev. Note that this must be kept in
1535 sync with out_debug_info below. */
1538 out_debug_abbrev (segT abbrev_seg
,
1539 segT info_seg ATTRIBUTE_UNUSED
,
1540 segT line_seg ATTRIBUTE_UNUSED
)
1542 subseg_set (abbrev_seg
, 0);
1545 out_uleb128 (DW_TAG_compile_unit
);
1546 out_byte (DW_CHILDREN_no
);
1547 if (DWARF2_FORMAT (line_seg
) == dwarf2_format_32bit
)
1548 out_abbrev (DW_AT_stmt_list
, DW_FORM_data4
);
1550 out_abbrev (DW_AT_stmt_list
, DW_FORM_data8
);
1551 if (all_segs
->next
== NULL
)
1553 out_abbrev (DW_AT_low_pc
, DW_FORM_addr
);
1554 out_abbrev (DW_AT_high_pc
, DW_FORM_addr
);
1558 if (DWARF2_FORMAT (info_seg
) == dwarf2_format_32bit
)
1559 out_abbrev (DW_AT_ranges
, DW_FORM_data4
);
1561 out_abbrev (DW_AT_ranges
, DW_FORM_data8
);
1563 out_abbrev (DW_AT_name
, DW_FORM_string
);
1564 out_abbrev (DW_AT_comp_dir
, DW_FORM_string
);
1565 out_abbrev (DW_AT_producer
, DW_FORM_string
);
1566 out_abbrev (DW_AT_language
, DW_FORM_data2
);
1569 /* Terminate the abbreviations for this compilation unit. */
1573 /* Emit a description of this compilation unit for .debug_info. */
1576 out_debug_info (segT info_seg
, segT abbrev_seg
, segT line_seg
, segT ranges_seg
)
1579 const char *comp_dir
;
1580 const char *dirname
;
1587 sizeof_offset
= out_header (info_seg
, &expr
);
1588 info_end
= expr
.X_add_symbol
;
1590 /* DWARF version. */
1593 /* .debug_abbrev offset */
1594 TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg
), sizeof_offset
);
1596 /* Target address size. */
1597 out_byte (sizeof_address
);
1599 /* DW_TAG_compile_unit DIE abbrev */
1602 /* DW_AT_stmt_list */
1603 TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg
),
1604 (DWARF2_FORMAT (line_seg
) == dwarf2_format_32bit
1607 /* These two attributes are emitted if all of the code is contiguous. */
1608 if (all_segs
->next
== NULL
)
1611 expr
.X_op
= O_symbol
;
1612 expr
.X_add_symbol
= all_segs
->text_start
;
1613 expr
.X_add_number
= 0;
1614 emit_expr (&expr
, sizeof_address
);
1617 expr
.X_op
= O_symbol
;
1618 expr
.X_add_symbol
= all_segs
->text_end
;
1619 expr
.X_add_number
= 0;
1620 emit_expr (&expr
, sizeof_address
);
1624 /* This attribute is emitted if the code is disjoint. */
1626 TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg
), sizeof_offset
);
1629 /* DW_AT_name. We don't have the actual file name that was present
1630 on the command line, so assume files[1] is the main input file.
1631 We're not supposed to get called unless at least one line number
1632 entry was emitted, so this should always be defined. */
1633 if (files_in_use
== 0)
1637 dirname
= remap_debug_filename (dirs
[files
[1].dir
]);
1638 len
= strlen (dirname
);
1639 p
= frag_more (len
+ 1);
1640 memcpy (p
, dirname
, len
);
1641 INSERT_DIR_SEPARATOR (p
, len
);
1643 len
= strlen (files
[1].filename
) + 1;
1644 p
= frag_more (len
);
1645 memcpy (p
, files
[1].filename
, len
);
1647 /* DW_AT_comp_dir */
1648 comp_dir
= remap_debug_filename (getpwd ());
1649 len
= strlen (comp_dir
) + 1;
1650 p
= frag_more (len
);
1651 memcpy (p
, comp_dir
, len
);
1653 /* DW_AT_producer */
1654 sprintf (producer
, "GNU AS %s", VERSION
);
1655 len
= strlen (producer
) + 1;
1656 p
= frag_more (len
);
1657 memcpy (p
, producer
, len
);
1659 /* DW_AT_language. Yes, this is probably not really MIPS, but the
1660 dwarf2 draft has no standard code for assembler. */
1661 out_two (DW_LANG_Mips_Assembler
);
1663 symbol_set_value_now (info_end
);
1666 /* Finish the dwarf2 debug sections. We emit .debug.line if there
1667 were any .file/.loc directives, or --gdwarf2 was given, or if the
1668 file has a non-empty .debug_info section. If we emit .debug_line,
1669 and the .debug_info section is empty, we also emit .debug_info,
1670 .debug_aranges and .debug_abbrev. ALL_SEGS will be non-null if
1671 there were any .file/.loc directives, or --gdwarf2 was given and
1672 there were any located instructions emitted. */
1675 dwarf2_finish (void)
1680 int emit_other_sections
= 0;
1682 info_seg
= bfd_get_section_by_name (stdoutput
, ".debug_info");
1683 emit_other_sections
= info_seg
== NULL
|| !seg_not_empty_p (info_seg
);
1685 if (!all_segs
&& emit_other_sections
)
1686 /* There is no line information and no non-empty .debug_info
1690 /* Calculate the size of an address for the target machine. */
1691 sizeof_address
= DWARF2_ADDR_SIZE (stdoutput
);
1693 /* Create and switch to the line number section. */
1694 line_seg
= subseg_new (".debug_line", 0);
1695 bfd_set_section_flags (stdoutput
, line_seg
, SEC_READONLY
| SEC_DEBUGGING
);
1697 /* For each subsection, chain the debug entries together. */
1698 for (s
= all_segs
; s
; s
= s
->next
)
1700 struct line_subseg
*ss
= s
->head
;
1701 struct line_entry
**ptail
= ss
->ptail
;
1703 while ((ss
= ss
->next
) != NULL
)
1710 out_debug_line (line_seg
);
1712 /* If this is assembler generated line info, and there is no
1713 debug_info already, we need .debug_info and .debug_abbrev
1714 sections as well. */
1715 if (emit_other_sections
)
1723 info_seg
= subseg_new (".debug_info", 0);
1724 abbrev_seg
= subseg_new (".debug_abbrev", 0);
1725 aranges_seg
= subseg_new (".debug_aranges", 0);
1727 bfd_set_section_flags (stdoutput
, info_seg
,
1728 SEC_READONLY
| SEC_DEBUGGING
);
1729 bfd_set_section_flags (stdoutput
, abbrev_seg
,
1730 SEC_READONLY
| SEC_DEBUGGING
);
1731 bfd_set_section_flags (stdoutput
, aranges_seg
,
1732 SEC_READONLY
| SEC_DEBUGGING
);
1734 record_alignment (aranges_seg
, ffs (2 * sizeof_address
) - 1);
1736 if (all_segs
->next
== NULL
)
1740 ranges_seg
= subseg_new (".debug_ranges", 0);
1741 bfd_set_section_flags (stdoutput
, ranges_seg
,
1742 SEC_READONLY
| SEC_DEBUGGING
);
1743 record_alignment (ranges_seg
, ffs (2 * sizeof_address
) - 1);
1744 out_debug_ranges (ranges_seg
);
1747 out_debug_aranges (aranges_seg
, info_seg
);
1748 out_debug_abbrev (abbrev_seg
, info_seg
, line_seg
);
1749 out_debug_info (info_seg
, abbrev_seg
, line_seg
, ranges_seg
);