]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/dwarf2asm.c
1 /* Dwarf2 assembler output helper routines.
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
28 #include "stringpool.h"
33 #include "dwarf2asm.h"
36 #ifndef XCOFF_DEBUGGING_INFO
37 #define XCOFF_DEBUGGING_INFO 0
41 /* Output an unaligned integer with the given value and size. Prefer not
42 to print a newline, since the caller may want to add a comment. */
45 dw2_assemble_integer (int size
, rtx x
)
47 const char *op
= integer_asm_op (size
, FALSE
);
51 fputs (op
, asm_out_file
);
53 fprint_whex (asm_out_file
, (unsigned HOST_WIDE_INT
) INTVAL (x
));
55 output_addr_const (asm_out_file
, x
);
58 assemble_integer (x
, size
, BITS_PER_UNIT
, 1);
62 /* Output a value of a given size in target byte order. */
65 dw2_asm_output_data_raw (int size
, unsigned HOST_WIDE_INT value
)
67 unsigned char bytes
[8];
70 for (i
= 0; i
< 8; ++i
)
72 bytes
[i
] = value
& 0xff;
78 for (i
= size
- 1; i
> 0; --i
)
79 fprintf (asm_out_file
, "%#x,", bytes
[i
]);
80 fprintf (asm_out_file
, "%#x", bytes
[0]);
84 for (i
= 0; i
< size
- 1; ++i
)
85 fprintf (asm_out_file
, "%#x,", bytes
[i
]);
86 fprintf (asm_out_file
, "%#x", bytes
[i
]);
90 /* Output an immediate constant in a given SIZE in bytes. */
93 dw2_asm_output_data (int size
, unsigned HOST_WIDE_INT value
,
94 const char *comment
, ...)
97 const char *op
= integer_asm_op (size
, FALSE
);
99 va_start (ap
, comment
);
101 if (size
* 8 < HOST_BITS_PER_WIDE_INT
)
102 value
&= ~(~(unsigned HOST_WIDE_INT
) 0 << (size
* 8));
106 fputs (op
, asm_out_file
);
107 fprint_whex (asm_out_file
, value
);
110 assemble_integer (GEN_INT (value
), size
, BITS_PER_UNIT
, 1);
112 if (flag_debug_asm
&& comment
)
114 fputs ("\t" ASM_COMMENT_START
" ", asm_out_file
);
115 vfprintf (asm_out_file
, comment
, ap
);
117 putc ('\n', asm_out_file
);
122 /* Output the difference between two symbols in a given size. */
123 /* ??? There appear to be assemblers that do not like such
124 subtraction, but do support ASM_SET_OP. It's unfortunately
125 impossible to do here, since the ASM_SET_OP for the difference
126 symbol must appear after both symbols are defined. */
129 dw2_asm_output_delta (int size
, const char *lab1
, const char *lab2
,
130 const char *comment
, ...)
134 va_start (ap
, comment
);
136 #ifdef ASM_OUTPUT_DWARF_DELTA
137 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, size
, lab1
, lab2
);
139 dw2_assemble_integer (size
,
140 gen_rtx_MINUS (Pmode
,
141 gen_rtx_SYMBOL_REF (Pmode
, lab1
),
142 gen_rtx_SYMBOL_REF (Pmode
, lab2
)));
144 if (flag_debug_asm
&& comment
)
146 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
147 vfprintf (asm_out_file
, comment
, ap
);
149 fputc ('\n', asm_out_file
);
154 #ifdef ASM_OUTPUT_DWARF_VMS_DELTA
155 /* Output the difference between two symbols in instruction units
159 dw2_asm_output_vms_delta (int size ATTRIBUTE_UNUSED
,
160 const char *lab1
, const char *lab2
,
161 const char *comment
, ...)
165 va_start (ap
, comment
);
167 ASM_OUTPUT_DWARF_VMS_DELTA (asm_out_file
, size
, lab1
, lab2
);
168 if (flag_debug_asm
&& comment
)
170 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
171 vfprintf (asm_out_file
, comment
, ap
);
173 fputc ('\n', asm_out_file
);
179 /* Output a section-relative reference to a LABEL, which was placed in
180 BASE. In general this can only be done for debugging symbols.
181 E.g. on most targets with the GNU linker, this is accomplished with
182 a direct reference and the knowledge that the debugging section
183 will be placed at VMA 0. Some targets have special relocations for
184 this that we must use. */
187 dw2_asm_output_offset (int size
, const char *label
,
188 section
*base ATTRIBUTE_UNUSED
,
189 const char *comment
, ...)
193 va_start (ap
, comment
);
195 #ifdef ASM_OUTPUT_DWARF_OFFSET
196 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, size
, label
, base
);
198 dw2_assemble_integer (size
, gen_rtx_SYMBOL_REF (Pmode
, label
));
201 if (flag_debug_asm
&& comment
)
203 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
204 vfprintf (asm_out_file
, comment
, ap
);
206 fputc ('\n', asm_out_file
);
213 /* Output a self-relative reference to a label, possibly in a
214 different section or object file. */
217 dw2_asm_output_pcrel (int size ATTRIBUTE_UNUSED
,
218 const char *label ATTRIBUTE_UNUSED
,
219 const char *comment
, ...)
223 va_start (ap
, comment
);
225 #ifdef ASM_OUTPUT_DWARF_PCREL
226 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, label
);
228 dw2_assemble_integer (size
,
229 gen_rtx_MINUS (Pmode
,
230 gen_rtx_SYMBOL_REF (Pmode
, label
),
234 if (flag_debug_asm
&& comment
)
236 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
237 vfprintf (asm_out_file
, comment
, ap
);
239 fputc ('\n', asm_out_file
);
245 /* Output an absolute reference to a label. */
248 dw2_asm_output_addr (int size
, const char *label
,
249 const char *comment
, ...)
253 va_start (ap
, comment
);
255 dw2_assemble_integer (size
, gen_rtx_SYMBOL_REF (Pmode
, label
));
257 if (flag_debug_asm
&& comment
)
259 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
260 vfprintf (asm_out_file
, comment
, ap
);
262 fputc ('\n', asm_out_file
);
267 /* Similar, but use an RTX expression instead of a text label. */
270 dw2_asm_output_addr_rtx (int size
, rtx addr
,
271 const char *comment
, ...)
275 va_start (ap
, comment
);
277 dw2_assemble_integer (size
, addr
);
279 if (flag_debug_asm
&& comment
)
281 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
282 vfprintf (asm_out_file
, comment
, ap
);
284 fputc ('\n', asm_out_file
);
289 /* Output the first ORIG_LEN characters of STR as a string.
290 If ORIG_LEN is equal to -1, ignore this parameter and output
291 the entire STR instead.
292 If COMMENT is not NULL and comments in the debug information
293 have been requested by the user, append the given COMMENT
294 to the generated output. */
297 dw2_asm_output_nstring (const char *str
, size_t orig_len
,
298 const char *comment
, ...)
303 va_start (ap
, comment
);
307 if (len
== (size_t) -1)
310 if (flag_debug_asm
&& comment
)
312 if (XCOFF_DEBUGGING_INFO
)
313 fputs ("\t.byte \"", asm_out_file
);
315 fputs ("\t.ascii \"", asm_out_file
);
317 for (i
= 0; i
< len
; i
++)
320 if (c
== '\"' || c
== '\\')
321 fputc ('\\', asm_out_file
);
323 fputc (c
, asm_out_file
);
325 fprintf (asm_out_file
, "\\%o", c
);
327 fprintf (asm_out_file
, "\\0\"\t%s ", ASM_COMMENT_START
);
328 vfprintf (asm_out_file
, comment
, ap
);
329 fputc ('\n', asm_out_file
);
333 /* If an explicit length was given, we can't assume there
334 is a null termination in the string buffer. */
335 if (orig_len
== (size_t) -1)
337 ASM_OUTPUT_ASCII (asm_out_file
, str
, len
);
338 if (orig_len
!= (size_t) -1)
339 assemble_integer (const0_rtx
, 1, BITS_PER_UNIT
, 1);
346 /* Return the size of an unsigned LEB128 quantity. */
349 size_of_uleb128 (unsigned HOST_WIDE_INT value
)
363 /* Return the size of a signed LEB128 quantity. */
366 size_of_sleb128 (HOST_WIDE_INT value
)
372 byte
= (value
& 0x7f);
376 while (!((value
== 0 && (byte
& 0x40) == 0)
377 || (value
== -1 && (byte
& 0x40) != 0)));
382 /* Given an encoding, return the number of bytes the format occupies.
383 This is only defined for fixed-size encodings, and so does not
387 size_of_encoded_value (int encoding
)
389 if (encoding
== DW_EH_PE_omit
)
392 switch (encoding
& 0x07)
394 case DW_EH_PE_absptr
:
395 return POINTER_SIZE_UNITS
;
396 case DW_EH_PE_udata2
:
398 case DW_EH_PE_udata4
:
400 case DW_EH_PE_udata8
:
407 /* Yield a name for a given pointer encoding. */
410 eh_data_format_name (int format
)
412 #if HAVE_DESIGNATED_INITIALIZERS
413 #define S(p, v) [p] = v,
415 #define S(p, v) case p: return v;
418 #if HAVE_DESIGNATED_INITIALIZERS
419 __extension__
static const char * const format_names
[256] = {
424 S(DW_EH_PE_absptr
, "absolute")
425 S(DW_EH_PE_omit
, "omit")
426 S(DW_EH_PE_aligned
, "aligned absolute")
428 S(DW_EH_PE_uleb128
, "uleb128")
429 S(DW_EH_PE_udata2
, "udata2")
430 S(DW_EH_PE_udata4
, "udata4")
431 S(DW_EH_PE_udata8
, "udata8")
432 S(DW_EH_PE_sleb128
, "sleb128")
433 S(DW_EH_PE_sdata2
, "sdata2")
434 S(DW_EH_PE_sdata4
, "sdata4")
435 S(DW_EH_PE_sdata8
, "sdata8")
437 S(DW_EH_PE_absptr
| DW_EH_PE_pcrel
, "pcrel")
438 S(DW_EH_PE_uleb128
| DW_EH_PE_pcrel
, "pcrel uleb128")
439 S(DW_EH_PE_udata2
| DW_EH_PE_pcrel
, "pcrel udata2")
440 S(DW_EH_PE_udata4
| DW_EH_PE_pcrel
, "pcrel udata4")
441 S(DW_EH_PE_udata8
| DW_EH_PE_pcrel
, "pcrel udata8")
442 S(DW_EH_PE_sleb128
| DW_EH_PE_pcrel
, "pcrel sleb128")
443 S(DW_EH_PE_sdata2
| DW_EH_PE_pcrel
, "pcrel sdata2")
444 S(DW_EH_PE_sdata4
| DW_EH_PE_pcrel
, "pcrel sdata4")
445 S(DW_EH_PE_sdata8
| DW_EH_PE_pcrel
, "pcrel sdata8")
447 S(DW_EH_PE_absptr
| DW_EH_PE_textrel
, "textrel")
448 S(DW_EH_PE_uleb128
| DW_EH_PE_textrel
, "textrel uleb128")
449 S(DW_EH_PE_udata2
| DW_EH_PE_textrel
, "textrel udata2")
450 S(DW_EH_PE_udata4
| DW_EH_PE_textrel
, "textrel udata4")
451 S(DW_EH_PE_udata8
| DW_EH_PE_textrel
, "textrel udata8")
452 S(DW_EH_PE_sleb128
| DW_EH_PE_textrel
, "textrel sleb128")
453 S(DW_EH_PE_sdata2
| DW_EH_PE_textrel
, "textrel sdata2")
454 S(DW_EH_PE_sdata4
| DW_EH_PE_textrel
, "textrel sdata4")
455 S(DW_EH_PE_sdata8
| DW_EH_PE_textrel
, "textrel sdata8")
457 S(DW_EH_PE_absptr
| DW_EH_PE_datarel
, "datarel")
458 S(DW_EH_PE_uleb128
| DW_EH_PE_datarel
, "datarel uleb128")
459 S(DW_EH_PE_udata2
| DW_EH_PE_datarel
, "datarel udata2")
460 S(DW_EH_PE_udata4
| DW_EH_PE_datarel
, "datarel udata4")
461 S(DW_EH_PE_udata8
| DW_EH_PE_datarel
, "datarel udata8")
462 S(DW_EH_PE_sleb128
| DW_EH_PE_datarel
, "datarel sleb128")
463 S(DW_EH_PE_sdata2
| DW_EH_PE_datarel
, "datarel sdata2")
464 S(DW_EH_PE_sdata4
| DW_EH_PE_datarel
, "datarel sdata4")
465 S(DW_EH_PE_sdata8
| DW_EH_PE_datarel
, "datarel sdata8")
467 S(DW_EH_PE_absptr
| DW_EH_PE_funcrel
, "funcrel")
468 S(DW_EH_PE_uleb128
| DW_EH_PE_funcrel
, "funcrel uleb128")
469 S(DW_EH_PE_udata2
| DW_EH_PE_funcrel
, "funcrel udata2")
470 S(DW_EH_PE_udata4
| DW_EH_PE_funcrel
, "funcrel udata4")
471 S(DW_EH_PE_udata8
| DW_EH_PE_funcrel
, "funcrel udata8")
472 S(DW_EH_PE_sleb128
| DW_EH_PE_funcrel
, "funcrel sleb128")
473 S(DW_EH_PE_sdata2
| DW_EH_PE_funcrel
, "funcrel sdata2")
474 S(DW_EH_PE_sdata4
| DW_EH_PE_funcrel
, "funcrel sdata4")
475 S(DW_EH_PE_sdata8
| DW_EH_PE_funcrel
, "funcrel sdata8")
477 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
, "indirect absolute")
479 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_pcrel
,
481 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_pcrel
,
482 "indirect pcrel uleb128")
483 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_pcrel
,
484 "indirect pcrel udata2")
485 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_pcrel
,
486 "indirect pcrel udata4")
487 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_pcrel
,
488 "indirect pcrel udata8")
489 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_pcrel
,
490 "indirect pcrel sleb128")
491 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_pcrel
,
492 "indirect pcrel sdata2")
493 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_pcrel
,
494 "indirect pcrel sdata4")
495 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_pcrel
,
496 "indirect pcrel sdata8")
498 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_textrel
,
500 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_textrel
,
501 "indirect textrel uleb128")
502 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_textrel
,
503 "indirect textrel udata2")
504 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_textrel
,
505 "indirect textrel udata4")
506 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_textrel
,
507 "indirect textrel udata8")
508 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_textrel
,
509 "indirect textrel sleb128")
510 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_textrel
,
511 "indirect textrel sdata2")
512 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_textrel
,
513 "indirect textrel sdata4")
514 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_textrel
,
515 "indirect textrel sdata8")
517 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_datarel
,
519 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_datarel
,
520 "indirect datarel uleb128")
521 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_datarel
,
522 "indirect datarel udata2")
523 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_datarel
,
524 "indirect datarel udata4")
525 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_datarel
,
526 "indirect datarel udata8")
527 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_datarel
,
528 "indirect datarel sleb128")
529 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_datarel
,
530 "indirect datarel sdata2")
531 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_datarel
,
532 "indirect datarel sdata4")
533 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_datarel
,
534 "indirect datarel sdata8")
536 S(DW_EH_PE_indirect
| DW_EH_PE_absptr
| DW_EH_PE_funcrel
,
538 S(DW_EH_PE_indirect
| DW_EH_PE_uleb128
| DW_EH_PE_funcrel
,
539 "indirect funcrel uleb128")
540 S(DW_EH_PE_indirect
| DW_EH_PE_udata2
| DW_EH_PE_funcrel
,
541 "indirect funcrel udata2")
542 S(DW_EH_PE_indirect
| DW_EH_PE_udata4
| DW_EH_PE_funcrel
,
543 "indirect funcrel udata4")
544 S(DW_EH_PE_indirect
| DW_EH_PE_udata8
| DW_EH_PE_funcrel
,
545 "indirect funcrel udata8")
546 S(DW_EH_PE_indirect
| DW_EH_PE_sleb128
| DW_EH_PE_funcrel
,
547 "indirect funcrel sleb128")
548 S(DW_EH_PE_indirect
| DW_EH_PE_sdata2
| DW_EH_PE_funcrel
,
549 "indirect funcrel sdata2")
550 S(DW_EH_PE_indirect
| DW_EH_PE_sdata4
| DW_EH_PE_funcrel
,
551 "indirect funcrel sdata4")
552 S(DW_EH_PE_indirect
| DW_EH_PE_sdata8
| DW_EH_PE_funcrel
,
553 "indirect funcrel sdata8")
555 #if HAVE_DESIGNATED_INITIALIZERS
558 gcc_assert (format
>= 0 && format
< 0x100 && format_names
[format
]);
560 return format_names
[format
];
567 /* Output an unsigned LEB128 quantity, but only the byte values. */
570 dw2_asm_output_data_uleb128_raw (unsigned HOST_WIDE_INT value
)
574 int byte
= (value
& 0x7f);
577 /* More bytes to follow. */
580 fprintf (asm_out_file
, "%#x", byte
);
583 fputc (',', asm_out_file
);
587 /* Output an unsigned LEB128 quantity. */
590 dw2_asm_output_data_uleb128 (unsigned HOST_WIDE_INT value
,
591 const char *comment
, ...)
595 va_start (ap
, comment
);
597 #ifdef HAVE_AS_LEB128
598 fputs ("\t.uleb128 ", asm_out_file
);
599 fprint_whex (asm_out_file
, value
);
601 if (flag_debug_asm
&& comment
)
603 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
604 vfprintf (asm_out_file
, comment
, ap
);
608 unsigned HOST_WIDE_INT work
= value
;
609 const char *byte_op
= targetm
.asm_out
.byte_op
;
612 fputs (byte_op
, asm_out_file
);
615 int byte
= (work
& 0x7f);
618 /* More bytes to follow. */
623 fprintf (asm_out_file
, "%#x", byte
);
625 fputc (',', asm_out_file
);
628 assemble_integer (GEN_INT (byte
), 1, BITS_PER_UNIT
, 1);
634 fprintf (asm_out_file
, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX
,
635 ASM_COMMENT_START
, value
);
638 fputs ("; ", asm_out_file
);
639 vfprintf (asm_out_file
, comment
, ap
);
644 putc ('\n', asm_out_file
);
649 /* Output an signed LEB128 quantity, but only the byte values. */
652 dw2_asm_output_data_sleb128_raw (HOST_WIDE_INT value
)
658 byte
= (value
& 0x7f);
660 more
= !((value
== 0 && (byte
& 0x40) == 0)
661 || (value
== -1 && (byte
& 0x40) != 0));
665 fprintf (asm_out_file
, "%#x", byte
);
668 fputc (',', asm_out_file
);
672 /* Output a signed LEB128 quantity. */
675 dw2_asm_output_data_sleb128 (HOST_WIDE_INT value
,
676 const char *comment
, ...)
680 va_start (ap
, comment
);
682 #ifdef HAVE_AS_LEB128
683 fprintf (asm_out_file
, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC
, value
);
685 if (flag_debug_asm
&& comment
)
687 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
688 vfprintf (asm_out_file
, comment
, ap
);
692 HOST_WIDE_INT work
= value
;
694 const char *byte_op
= targetm
.asm_out
.byte_op
;
697 fputs (byte_op
, asm_out_file
);
700 byte
= (work
& 0x7f);
701 /* arithmetic shift */
703 more
= !((work
== 0 && (byte
& 0x40) == 0)
704 || (work
== -1 && (byte
& 0x40) != 0));
710 fprintf (asm_out_file
, "%#x", byte
);
712 fputc (',', asm_out_file
);
715 assemble_integer (GEN_INT (byte
), 1, BITS_PER_UNIT
, 1);
721 fprintf (asm_out_file
, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC
,
722 ASM_COMMENT_START
, value
);
725 fputs ("; ", asm_out_file
);
726 vfprintf (asm_out_file
, comment
, ap
);
731 fputc ('\n', asm_out_file
);
737 dw2_asm_output_delta_uleb128 (const char *lab1 ATTRIBUTE_UNUSED
,
738 const char *lab2 ATTRIBUTE_UNUSED
,
739 const char *comment
, ...)
743 va_start (ap
, comment
);
745 #ifdef HAVE_AS_LEB128
746 fputs ("\t.uleb128 ", asm_out_file
);
747 assemble_name (asm_out_file
, lab1
);
748 putc ('-', asm_out_file
);
749 assemble_name (asm_out_file
, lab2
);
754 if (flag_debug_asm
&& comment
)
756 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
757 vfprintf (asm_out_file
, comment
, ap
);
759 fputc ('\n', asm_out_file
);
767 dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED
,
768 const char *lab2 ATTRIBUTE_UNUSED
,
769 const char *comment
, ...)
773 va_start (ap
, comment
);
775 #ifdef HAVE_AS_LEB128
776 fputs ("\t.sleb128 ", asm_out_file
);
777 assemble_name (asm_out_file
, lab1
);
778 putc ('-', asm_out_file
);
779 assemble_name (asm_out_file
, lab2
);
784 if (flag_debug_asm
&& comment
)
786 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
787 vfprintf (asm_out_file
, comment
, ap
);
789 fputc ('\n', asm_out_file
);
795 static GTY(()) hash_map
<const char *, tree
> *indirect_pool
;
797 static GTY(()) int dw2_const_labelno
;
799 #if defined(HAVE_GAS_HIDDEN)
800 # define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY)
802 # define USE_LINKONCE_INDIRECT 0
805 /* Compare two std::pair<const char *, tree> by their first element.
807 >0 to indicate whether K1 is less than, equal to, or greater than
811 compare_strings (const void *a
, const void *b
)
813 const char *s1
= ((const std::pair
<const char *, tree
> *) a
)->first
;
814 const char *s2
= ((const std::pair
<const char *, tree
> *) b
)->first
;
820 ret
= strcmp (s1
, s2
);
822 /* The strings are always those from IDENTIFIER_NODEs, and,
823 therefore, we should never have two copies of the same
830 /* Put X, a SYMBOL_REF, in memory. Return a SYMBOL_REF to the allocated
831 memory. Differs from force_const_mem in that a single pool is used for
832 the entire unit of translation, and the memory is not guaranteed to be
833 "near" the function in any interesting sense. IS_PUBLIC controls whether
834 the symbol can be shared across the entire application (or DSO). */
837 dw2_force_const_mem (rtx x
, bool is_public
)
843 indirect_pool
= hash_map
<const char *, tree
>::create_ggc (64);
845 gcc_assert (GET_CODE (x
) == SYMBOL_REF
);
848 tree
*slot
= indirect_pool
->get (key
);
854 const char *str
= targetm
.strip_name_encoding (key
);
856 if (is_public
&& USE_LINKONCE_INDIRECT
)
858 char *ref_name
= XALLOCAVEC (char, strlen (str
) + sizeof "DW.ref.");
860 sprintf (ref_name
, "DW.ref.%s", str
);
861 gcc_assert (!maybe_get_identifier (ref_name
));
862 decl_id
= get_identifier (ref_name
);
863 TREE_PUBLIC (decl_id
) = 1;
869 ASM_GENERATE_INTERNAL_LABEL (label
, "LDFCM", dw2_const_labelno
);
871 gcc_assert (!maybe_get_identifier (label
));
872 decl_id
= get_identifier (label
);
875 id
= maybe_get_identifier (str
);
877 TREE_SYMBOL_REFERENCED (id
) = 1;
879 indirect_pool
->put (key
, decl_id
);
882 return gen_rtx_SYMBOL_REF (Pmode
, IDENTIFIER_POINTER (decl_id
));
885 /* A helper function for dw2_output_indirect_constants. Emit one queued
886 constant to memory. */
889 dw2_output_indirect_constant_1 (const char *sym
, tree id
)
894 decl
= build_decl (UNKNOWN_LOCATION
, VAR_DECL
, id
, ptr_type_node
);
895 SET_DECL_ASSEMBLER_NAME (decl
, id
);
896 DECL_ARTIFICIAL (decl
) = 1;
897 DECL_IGNORED_P (decl
) = 1;
898 DECL_INITIAL (decl
) = decl
;
899 TREE_READONLY (decl
) = 1;
900 TREE_STATIC (decl
) = 1;
902 if (TREE_PUBLIC (id
))
904 TREE_PUBLIC (decl
) = 1;
905 make_decl_one_only (decl
, DECL_ASSEMBLER_NAME (decl
));
906 if (USE_LINKONCE_INDIRECT
)
907 DECL_VISIBILITY (decl
) = VISIBILITY_HIDDEN
;
910 sym_ref
= gen_rtx_SYMBOL_REF (Pmode
, sym
);
911 assemble_variable (decl
, 1, 1, 1);
912 assemble_integer (sym_ref
, POINTER_SIZE_UNITS
, POINTER_SIZE
, 1);
917 /* Emit the constants queued through dw2_force_const_mem. */
920 dw2_output_indirect_constants (void)
925 auto_vec
<std::pair
<const char *, tree
> > temp (indirect_pool
->elements ());
926 for (hash_map
<const char *, tree
>::iterator iter
= indirect_pool
->begin ();
927 iter
!= indirect_pool
->end (); ++iter
)
928 temp
.quick_push (*iter
);
930 temp
.qsort (compare_strings
);
932 for (unsigned int i
= 0; i
< temp
.length (); i
++)
933 dw2_output_indirect_constant_1 (temp
[i
].first
, temp
[i
].second
);
936 /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed.
937 If PUBLIC is set and the encoding is DW_EH_PE_indirect, the indirect
938 reference is shared across the entire application (or DSO). */
941 dw2_asm_output_encoded_addr_rtx (int encoding
, rtx addr
, bool is_public
,
942 const char *comment
, ...)
947 va_start (ap
, comment
);
949 size
= size_of_encoded_value (encoding
);
951 if (encoding
== DW_EH_PE_aligned
)
953 assemble_align (POINTER_SIZE
);
954 assemble_integer (addr
, size
, POINTER_SIZE
, 1);
959 /* NULL is _always_ represented as a plain zero, as is 1 for Ada's
961 if (addr
== const0_rtx
|| addr
== const1_rtx
)
962 assemble_integer (addr
, size
, BITS_PER_UNIT
, 1);
966 /* Allow the target first crack at emitting this. Some of the
967 special relocations require special directives instead of
968 just ".4byte" or whatever. */
969 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
970 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file
, encoding
, size
,
974 /* Indirection is used to get dynamic relocations out of a
975 read-only section. */
976 if (encoding
& DW_EH_PE_indirect
)
978 /* It is very tempting to use force_const_mem so that we share data
979 with the normal constant pool. However, we've already emitted
980 the constant pool for this function. Moreover, we'd like to
981 share these constants across the entire unit of translation and
982 even, if possible, across the entire application (or DSO). */
983 addr
= dw2_force_const_mem (addr
, is_public
);
984 encoding
&= ~DW_EH_PE_indirect
;
988 switch (encoding
& 0xF0)
990 case DW_EH_PE_absptr
:
991 dw2_assemble_integer (size
, addr
);
994 #ifdef ASM_OUTPUT_DWARF_DATAREL
995 case DW_EH_PE_datarel
:
996 gcc_assert (GET_CODE (addr
) == SYMBOL_REF
);
997 ASM_OUTPUT_DWARF_DATAREL (asm_out_file
, size
, XSTR (addr
, 0));
1001 case DW_EH_PE_pcrel
:
1002 gcc_assert (GET_CODE (addr
) == SYMBOL_REF
);
1003 #ifdef ASM_OUTPUT_DWARF_PCREL
1004 ASM_OUTPUT_DWARF_PCREL (asm_out_file
, size
, XSTR (addr
, 0));
1006 dw2_assemble_integer (size
, gen_rtx_MINUS (Pmode
, addr
, pc_rtx
));
1011 /* Other encodings should have been handled by
1012 ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX. */
1016 #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
1021 if (flag_debug_asm
&& comment
)
1023 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
1024 vfprintf (asm_out_file
, comment
, ap
);
1026 fputc ('\n', asm_out_file
);
1031 #include "gt-dwarf2asm.h"