]>
Commit | Line | Data |
---|---|---|
ca98eb0a | 1 | /* Dwarf2 assembler output helper routines. |
711789cc | 2 | Copyright (C) 2001-2013 Free Software Foundation, Inc. |
ca98eb0a | 3 | |
f12b58b3 | 4 | This file is part of GCC. |
ca98eb0a | 5 | |
f12b58b3 | 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 | |
8c4c00c1 | 8 | Software Foundation; either version 3, or (at your option) any later |
f12b58b3 | 9 | version. |
ca98eb0a | 10 | |
f12b58b3 | 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 | |
14 | for more details. | |
ca98eb0a | 15 | |
16 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ | |
ca98eb0a | 19 | |
20 | ||
21 | #include "config.h" | |
22 | #include "system.h" | |
805e22b2 | 23 | #include "coretypes.h" |
24 | #include "tm.h" | |
ca98eb0a | 25 | #include "flags.h" |
ad5818ae | 26 | #include "tree.h" |
ca98eb0a | 27 | #include "rtl.h" |
28 | #include "output.h" | |
58356836 | 29 | #include "target.h" |
ca98eb0a | 30 | #include "dwarf2asm.h" |
bde36f4a | 31 | #include "dwarf2.h" |
ad5818ae | 32 | #include "splay-tree.h" |
33 | #include "ggc.h" | |
ca98eb0a | 34 | #include "tm_p.h" |
35 | ||
ca98eb0a | 36 | \f |
58356836 | 37 | /* Output an unaligned integer with the given value and size. Prefer not |
38 | to print a newline, since the caller may want to add a comment. */ | |
39 | ||
40 | void | |
8ec3a57b | 41 | dw2_assemble_integer (int size, rtx x) |
ca98eb0a | 42 | { |
58356836 | 43 | const char *op = integer_asm_op (size, FALSE); |
44 | ||
45 | if (op) | |
ca98eb0a | 46 | { |
58356836 | 47 | fputs (op, asm_out_file); |
971ba038 | 48 | if (CONST_INT_P (x)) |
c0e76f1f | 49 | fprint_whex (asm_out_file, (unsigned HOST_WIDE_INT) INTVAL (x)); |
58356836 | 50 | else |
51 | output_addr_const (asm_out_file, x); | |
ca98eb0a | 52 | } |
58356836 | 53 | else |
54 | assemble_integer (x, size, BITS_PER_UNIT, 1); | |
ca98eb0a | 55 | } |
1eefe280 | 56 | |
ca98eb0a | 57 | |
fb39ff6e | 58 | /* Output a value of a given size in target byte order. */ |
59 | ||
60 | void | |
61 | dw2_asm_output_data_raw (int size, unsigned HOST_WIDE_INT value) | |
62 | { | |
63 | unsigned char bytes[8]; | |
64 | int i; | |
65 | ||
66 | for (i = 0; i < 8; ++i) | |
67 | { | |
68 | bytes[i] = value & 0xff; | |
69 | value >>= 8; | |
70 | } | |
71 | ||
72 | if (BYTES_BIG_ENDIAN) | |
73 | { | |
74 | for (i = size - 1; i > 0; --i) | |
3eb9ad16 | 75 | fprintf (asm_out_file, "%#x,", bytes[i]); |
76 | fprintf (asm_out_file, "%#x", bytes[0]); | |
fb39ff6e | 77 | } |
78 | else | |
79 | { | |
80 | for (i = 0; i < size - 1; ++i) | |
3eb9ad16 | 81 | fprintf (asm_out_file, "%#x,", bytes[i]); |
82 | fprintf (asm_out_file, "%#x", bytes[i]); | |
fb39ff6e | 83 | } |
84 | } | |
85 | ||
76ee6ef2 | 86 | /* Output an immediate constant in a given SIZE in bytes. */ |
19e5668c | 87 | |
ca98eb0a | 88 | void |
ee582a61 | 89 | dw2_asm_output_data (int size, unsigned HOST_WIDE_INT value, |
90 | const char *comment, ...) | |
ca98eb0a | 91 | { |
ee582a61 | 92 | va_list ap; |
08365969 | 93 | const char *op = integer_asm_op (size, FALSE); |
8ec3a57b | 94 | |
ee582a61 | 95 | va_start (ap, comment); |
ca98eb0a | 96 | |
8de0b9f7 | 97 | if (size * 8 < HOST_BITS_PER_WIDE_INT) |
dfe09cce | 98 | value &= ~(~(unsigned HOST_WIDE_INT) 0 << (size * 8)); |
8de0b9f7 | 99 | |
08365969 | 100 | if (op) |
c0e76f1f | 101 | { |
102 | fputs (op, asm_out_file); | |
103 | fprint_whex (asm_out_file, value); | |
104 | } | |
08365969 | 105 | else |
106 | assemble_integer (GEN_INT (value), size, BITS_PER_UNIT, 1); | |
ca98eb0a | 107 | |
108 | if (flag_debug_asm && comment) | |
109 | { | |
c0e76f1f | 110 | fputs ("\t" ASM_COMMENT_START " ", asm_out_file); |
ca98eb0a | 111 | vfprintf (asm_out_file, comment, ap); |
112 | } | |
c0e76f1f | 113 | putc ('\n', asm_out_file); |
ca98eb0a | 114 | |
ee582a61 | 115 | va_end (ap); |
ca98eb0a | 116 | } |
117 | ||
19e5668c | 118 | /* Output the difference between two symbols in a given size. */ |
119 | /* ??? There appear to be assemblers that do not like such | |
120 | subtraction, but do support ASM_SET_OP. It's unfortunately | |
121 | impossible to do here, since the ASM_SET_OP for the difference | |
122 | symbol must appear after both symbols are defined. */ | |
123 | ||
ca98eb0a | 124 | void |
ee582a61 | 125 | dw2_asm_output_delta (int size, const char *lab1, const char *lab2, |
126 | const char *comment, ...) | |
ca98eb0a | 127 | { |
ee582a61 | 128 | va_list ap; |
8ec3a57b | 129 | |
ee582a61 | 130 | va_start (ap, comment); |
ca98eb0a | 131 | |
a08b74c8 | 132 | #ifdef ASM_OUTPUT_DWARF_DELTA |
133 | ASM_OUTPUT_DWARF_DELTA (asm_out_file, size, lab1, lab2); | |
134 | #else | |
58356836 | 135 | dw2_assemble_integer (size, |
136 | gen_rtx_MINUS (Pmode, | |
137 | gen_rtx_SYMBOL_REF (Pmode, lab1), | |
138 | gen_rtx_SYMBOL_REF (Pmode, lab2))); | |
a08b74c8 | 139 | #endif |
ca98eb0a | 140 | if (flag_debug_asm && comment) |
141 | { | |
142 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
143 | vfprintf (asm_out_file, comment, ap); | |
144 | } | |
145 | fputc ('\n', asm_out_file); | |
146 | ||
ee582a61 | 147 | va_end (ap); |
ca98eb0a | 148 | } |
149 | ||
cfe7b52e | 150 | /* Output the difference between two symbols in instruction units |
151 | in a given size. */ | |
152 | ||
153 | void | |
154 | dw2_asm_output_vms_delta (int size ATTRIBUTE_UNUSED, | |
155 | const char *lab1, const char *lab2, | |
156 | const char *comment, ...) | |
157 | { | |
158 | va_list ap; | |
159 | ||
160 | va_start (ap, comment); | |
161 | ||
162 | #ifndef ASM_OUTPUT_DWARF_VMS_DELTA | |
9d75589a | 163 | /* VMS Delta is only special on ia64-vms, but this function also gets |
cfe7b52e | 164 | called on alpha-vms so it has to do something sane. */ |
165 | dw2_asm_output_delta (size, lab1, lab2, comment); | |
166 | #else | |
167 | ASM_OUTPUT_DWARF_VMS_DELTA (asm_out_file, size, lab1, lab2); | |
168 | if (flag_debug_asm && comment) | |
169 | { | |
170 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
171 | vfprintf (asm_out_file, comment, ap); | |
172 | } | |
173 | fputc ('\n', asm_out_file); | |
174 | #endif | |
175 | ||
176 | va_end (ap); | |
177 | } | |
178 | ||
d08d29c0 | 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. */ | |
19e5668c | 185 | |
ca98eb0a | 186 | void |
e056afd2 | 187 | dw2_asm_output_offset (int size, const char *label, |
188 | section *base ATTRIBUTE_UNUSED, | |
ee582a61 | 189 | const char *comment, ...) |
ca98eb0a | 190 | { |
ee582a61 | 191 | va_list ap; |
8ec3a57b | 192 | |
ee582a61 | 193 | va_start (ap, comment); |
ca98eb0a | 194 | |
19e5668c | 195 | #ifdef ASM_OUTPUT_DWARF_OFFSET |
d08d29c0 | 196 | ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, base); |
19e5668c | 197 | #else |
58356836 | 198 | dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label)); |
ca98eb0a | 199 | #endif |
200 | ||
201 | if (flag_debug_asm && comment) | |
202 | { | |
203 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
204 | vfprintf (asm_out_file, comment, ap); | |
205 | } | |
206 | fputc ('\n', asm_out_file); | |
207 | ||
ee582a61 | 208 | va_end (ap); |
ca98eb0a | 209 | } |
210 | ||
31ac8297 | 211 | #if 0 |
212 | ||
19e5668c | 213 | /* Output a self-relative reference to a label, possibly in a |
214 | different section or object file. */ | |
215 | ||
ca98eb0a | 216 | void |
ee582a61 | 217 | dw2_asm_output_pcrel (int size ATTRIBUTE_UNUSED, |
218 | const char *label ATTRIBUTE_UNUSED, | |
219 | const char *comment, ...) | |
ca98eb0a | 220 | { |
ee582a61 | 221 | va_list ap; |
8ec3a57b | 222 | |
ee582a61 | 223 | va_start (ap, comment); |
ca98eb0a | 224 | |
19e5668c | 225 | #ifdef ASM_OUTPUT_DWARF_PCREL |
226 | ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, label); | |
227 | #else | |
58356836 | 228 | dw2_assemble_integer (size, |
229 | gen_rtx_MINUS (Pmode, | |
230 | gen_rtx_SYMBOL_REF (Pmode, label), | |
231 | pc_rtx)); | |
19e5668c | 232 | #endif |
233 | ||
234 | if (flag_debug_asm && comment) | |
235 | { | |
236 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
237 | vfprintf (asm_out_file, comment, ap); | |
238 | } | |
239 | fputc ('\n', asm_out_file); | |
240 | ||
ee582a61 | 241 | va_end (ap); |
19e5668c | 242 | } |
31ac8297 | 243 | #endif /* 0 */ |
19e5668c | 244 | |
245 | /* Output an absolute reference to a label. */ | |
246 | ||
247 | void | |
ee582a61 | 248 | dw2_asm_output_addr (int size, const char *label, |
249 | const char *comment, ...) | |
19e5668c | 250 | { |
ee582a61 | 251 | va_list ap; |
8ec3a57b | 252 | |
ee582a61 | 253 | va_start (ap, comment); |
19e5668c | 254 | |
58356836 | 255 | dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label)); |
ca98eb0a | 256 | |
257 | if (flag_debug_asm && comment) | |
258 | { | |
259 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
260 | vfprintf (asm_out_file, comment, ap); | |
261 | } | |
262 | fputc ('\n', asm_out_file); | |
263 | ||
ee582a61 | 264 | va_end (ap); |
ca98eb0a | 265 | } |
266 | ||
19e5668c | 267 | /* Similar, but use an RTX expression instead of a text label. */ |
268 | ||
ca98eb0a | 269 | void |
ee582a61 | 270 | dw2_asm_output_addr_rtx (int size, rtx addr, |
271 | const char *comment, ...) | |
ca98eb0a | 272 | { |
ee582a61 | 273 | va_list ap; |
8ec3a57b | 274 | |
ee582a61 | 275 | va_start (ap, comment); |
ca98eb0a | 276 | |
58356836 | 277 | dw2_assemble_integer (size, addr); |
ca98eb0a | 278 | |
279 | if (flag_debug_asm && comment) | |
280 | { | |
281 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
282 | vfprintf (asm_out_file, comment, ap); | |
283 | } | |
284 | fputc ('\n', asm_out_file); | |
285 | ||
ee582a61 | 286 | va_end (ap); |
ca98eb0a | 287 | } |
288 | ||
21f8688e | 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. */ | |
48e1416a | 295 | |
ca98eb0a | 296 | void |
ee582a61 | 297 | dw2_asm_output_nstring (const char *str, size_t orig_len, |
298 | const char *comment, ...) | |
ca98eb0a | 299 | { |
0903457a | 300 | size_t i, len; |
ee582a61 | 301 | va_list ap; |
ca98eb0a | 302 | |
ee582a61 | 303 | va_start (ap, comment); |
ca98eb0a | 304 | |
0903457a | 305 | len = orig_len; |
ca98eb0a | 306 | |
307 | if (len == (size_t) -1) | |
308 | len = strlen (str); | |
309 | ||
310 | if (flag_debug_asm && comment) | |
311 | { | |
312 | fputs ("\t.ascii \"", asm_out_file); | |
313 | for (i = 0; i < len; i++) | |
314 | { | |
315 | int c = str[i]; | |
316 | if (c == '\"' || c == '\\') | |
317 | fputc ('\\', asm_out_file); | |
9af5ce0c | 318 | if (ISPRINT (c)) |
ca98eb0a | 319 | fputc (c, asm_out_file); |
320 | else | |
321 | fprintf (asm_out_file, "\\%o", c); | |
322 | } | |
323 | fprintf (asm_out_file, "\\0\"\t%s ", ASM_COMMENT_START); | |
324 | vfprintf (asm_out_file, comment, ap); | |
325 | fputc ('\n', asm_out_file); | |
326 | } | |
327 | else | |
328 | { | |
329 | /* If an explicit length was given, we can't assume there | |
330 | is a null termination in the string buffer. */ | |
331 | if (orig_len == (size_t) -1) | |
332 | len += 1; | |
333 | ASM_OUTPUT_ASCII (asm_out_file, str, len); | |
334 | if (orig_len != (size_t) -1) | |
58356836 | 335 | assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1); |
ca98eb0a | 336 | } |
337 | ||
ee582a61 | 338 | va_end (ap); |
ca98eb0a | 339 | } |
340 | \f | |
341 | ||
342 | /* Return the size of an unsigned LEB128 quantity. */ | |
343 | ||
344 | int | |
8ec3a57b | 345 | size_of_uleb128 (unsigned HOST_WIDE_INT value) |
ca98eb0a | 346 | { |
805e22b2 | 347 | int size = 0; |
ca98eb0a | 348 | |
349 | do | |
350 | { | |
ca98eb0a | 351 | value >>= 7; |
352 | size += 1; | |
353 | } | |
354 | while (value != 0); | |
355 | ||
356 | return size; | |
357 | } | |
358 | ||
359 | /* Return the size of a signed LEB128 quantity. */ | |
360 | ||
361 | int | |
8ec3a57b | 362 | size_of_sleb128 (HOST_WIDE_INT value) |
ca98eb0a | 363 | { |
364 | int size = 0, byte; | |
365 | ||
366 | do | |
367 | { | |
368 | byte = (value & 0x7f); | |
369 | value >>= 7; | |
370 | size += 1; | |
371 | } | |
372 | while (!((value == 0 && (byte & 0x40) == 0) | |
373 | || (value == -1 && (byte & 0x40) != 0))); | |
374 | ||
375 | return size; | |
376 | } | |
377 | ||
631413ff | 378 | /* Given an encoding, return the number of bytes the format occupies. |
1eefe280 | 379 | This is only defined for fixed-size encodings, and so does not |
631413ff | 380 | include leb128. */ |
381 | ||
382 | int | |
8ec3a57b | 383 | size_of_encoded_value (int encoding) |
631413ff | 384 | { |
385 | if (encoding == DW_EH_PE_omit) | |
386 | return 0; | |
387 | ||
388 | switch (encoding & 0x07) | |
389 | { | |
390 | case DW_EH_PE_absptr: | |
391 | return POINTER_SIZE / BITS_PER_UNIT; | |
392 | case DW_EH_PE_udata2: | |
393 | return 2; | |
394 | case DW_EH_PE_udata4: | |
395 | return 4; | |
396 | case DW_EH_PE_udata8: | |
397 | return 8; | |
7bd4f6b6 | 398 | default: |
399 | gcc_unreachable (); | |
631413ff | 400 | } |
631413ff | 401 | } |
402 | ||
9b84bf7d | 403 | /* Yield a name for a given pointer encoding. */ |
404 | ||
405 | const char * | |
8ec3a57b | 406 | eh_data_format_name (int format) |
9b84bf7d | 407 | { |
408 | #if HAVE_DESIGNATED_INITIALIZERS | |
409 | #define S(p, v) [p] = v, | |
410 | #else | |
411 | #define S(p, v) case p: return v; | |
412 | #endif | |
413 | ||
414 | #if HAVE_DESIGNATED_INITIALIZERS | |
415 | __extension__ static const char * const format_names[256] = { | |
416 | #else | |
417 | switch (format) { | |
418 | #endif | |
419 | ||
420 | S(DW_EH_PE_absptr, "absolute") | |
421 | S(DW_EH_PE_omit, "omit") | |
9a4d22ba | 422 | S(DW_EH_PE_aligned, "aligned absolute") |
9b84bf7d | 423 | |
424 | S(DW_EH_PE_uleb128, "uleb128") | |
425 | S(DW_EH_PE_udata2, "udata2") | |
426 | S(DW_EH_PE_udata4, "udata4") | |
427 | S(DW_EH_PE_udata8, "udata8") | |
428 | S(DW_EH_PE_sleb128, "sleb128") | |
429 | S(DW_EH_PE_sdata2, "sdata2") | |
430 | S(DW_EH_PE_sdata4, "sdata4") | |
431 | S(DW_EH_PE_sdata8, "sdata8") | |
432 | ||
ffaf0c47 | 433 | S(DW_EH_PE_absptr | DW_EH_PE_pcrel, "pcrel") |
9b84bf7d | 434 | S(DW_EH_PE_uleb128 | DW_EH_PE_pcrel, "pcrel uleb128") |
435 | S(DW_EH_PE_udata2 | DW_EH_PE_pcrel, "pcrel udata2") | |
436 | S(DW_EH_PE_udata4 | DW_EH_PE_pcrel, "pcrel udata4") | |
437 | S(DW_EH_PE_udata8 | DW_EH_PE_pcrel, "pcrel udata8") | |
438 | S(DW_EH_PE_sleb128 | DW_EH_PE_pcrel, "pcrel sleb128") | |
439 | S(DW_EH_PE_sdata2 | DW_EH_PE_pcrel, "pcrel sdata2") | |
440 | S(DW_EH_PE_sdata4 | DW_EH_PE_pcrel, "pcrel sdata4") | |
441 | S(DW_EH_PE_sdata8 | DW_EH_PE_pcrel, "pcrel sdata8") | |
442 | ||
ffaf0c47 | 443 | S(DW_EH_PE_absptr | DW_EH_PE_textrel, "textrel") |
9b84bf7d | 444 | S(DW_EH_PE_uleb128 | DW_EH_PE_textrel, "textrel uleb128") |
445 | S(DW_EH_PE_udata2 | DW_EH_PE_textrel, "textrel udata2") | |
446 | S(DW_EH_PE_udata4 | DW_EH_PE_textrel, "textrel udata4") | |
447 | S(DW_EH_PE_udata8 | DW_EH_PE_textrel, "textrel udata8") | |
448 | S(DW_EH_PE_sleb128 | DW_EH_PE_textrel, "textrel sleb128") | |
449 | S(DW_EH_PE_sdata2 | DW_EH_PE_textrel, "textrel sdata2") | |
450 | S(DW_EH_PE_sdata4 | DW_EH_PE_textrel, "textrel sdata4") | |
451 | S(DW_EH_PE_sdata8 | DW_EH_PE_textrel, "textrel sdata8") | |
452 | ||
ffaf0c47 | 453 | S(DW_EH_PE_absptr | DW_EH_PE_datarel, "datarel") |
9b84bf7d | 454 | S(DW_EH_PE_uleb128 | DW_EH_PE_datarel, "datarel uleb128") |
455 | S(DW_EH_PE_udata2 | DW_EH_PE_datarel, "datarel udata2") | |
456 | S(DW_EH_PE_udata4 | DW_EH_PE_datarel, "datarel udata4") | |
457 | S(DW_EH_PE_udata8 | DW_EH_PE_datarel, "datarel udata8") | |
458 | S(DW_EH_PE_sleb128 | DW_EH_PE_datarel, "datarel sleb128") | |
459 | S(DW_EH_PE_sdata2 | DW_EH_PE_datarel, "datarel sdata2") | |
460 | S(DW_EH_PE_sdata4 | DW_EH_PE_datarel, "datarel sdata4") | |
461 | S(DW_EH_PE_sdata8 | DW_EH_PE_datarel, "datarel sdata8") | |
462 | ||
ffaf0c47 | 463 | S(DW_EH_PE_absptr | DW_EH_PE_funcrel, "funcrel") |
9b84bf7d | 464 | S(DW_EH_PE_uleb128 | DW_EH_PE_funcrel, "funcrel uleb128") |
465 | S(DW_EH_PE_udata2 | DW_EH_PE_funcrel, "funcrel udata2") | |
466 | S(DW_EH_PE_udata4 | DW_EH_PE_funcrel, "funcrel udata4") | |
467 | S(DW_EH_PE_udata8 | DW_EH_PE_funcrel, "funcrel udata8") | |
468 | S(DW_EH_PE_sleb128 | DW_EH_PE_funcrel, "funcrel sleb128") | |
469 | S(DW_EH_PE_sdata2 | DW_EH_PE_funcrel, "funcrel sdata2") | |
470 | S(DW_EH_PE_sdata4 | DW_EH_PE_funcrel, "funcrel sdata4") | |
471 | S(DW_EH_PE_sdata8 | DW_EH_PE_funcrel, "funcrel sdata8") | |
472 | ||
c4cf26ad | 473 | S(DW_EH_PE_indirect | DW_EH_PE_absptr, "indirect absolute") |
474 | ||
ffaf0c47 | 475 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_pcrel, |
476 | "indirect pcrel") | |
9b84bf7d | 477 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_pcrel, |
478 | "indirect pcrel uleb128") | |
479 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_pcrel, | |
480 | "indirect pcrel udata2") | |
481 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_pcrel, | |
482 | "indirect pcrel udata4") | |
483 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_pcrel, | |
484 | "indirect pcrel udata8") | |
485 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_pcrel, | |
486 | "indirect pcrel sleb128") | |
487 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_pcrel, | |
488 | "indirect pcrel sdata2") | |
489 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_pcrel, | |
490 | "indirect pcrel sdata4") | |
491 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_pcrel, | |
492 | "indirect pcrel sdata8") | |
493 | ||
ffaf0c47 | 494 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_textrel, |
495 | "indirect textrel") | |
9b84bf7d | 496 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_textrel, |
497 | "indirect textrel uleb128") | |
498 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_textrel, | |
499 | "indirect textrel udata2") | |
500 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_textrel, | |
501 | "indirect textrel udata4") | |
502 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_textrel, | |
503 | "indirect textrel udata8") | |
504 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_textrel, | |
505 | "indirect textrel sleb128") | |
506 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_textrel, | |
507 | "indirect textrel sdata2") | |
508 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_textrel, | |
509 | "indirect textrel sdata4") | |
510 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_textrel, | |
511 | "indirect textrel sdata8") | |
512 | ||
ffaf0c47 | 513 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_datarel, |
514 | "indirect datarel") | |
9b84bf7d | 515 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_datarel, |
516 | "indirect datarel uleb128") | |
517 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_datarel, | |
518 | "indirect datarel udata2") | |
519 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_datarel, | |
520 | "indirect datarel udata4") | |
521 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_datarel, | |
522 | "indirect datarel udata8") | |
523 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_datarel, | |
524 | "indirect datarel sleb128") | |
525 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_datarel, | |
526 | "indirect datarel sdata2") | |
527 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_datarel, | |
528 | "indirect datarel sdata4") | |
529 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_datarel, | |
530 | "indirect datarel sdata8") | |
531 | ||
ffaf0c47 | 532 | S(DW_EH_PE_indirect | DW_EH_PE_absptr | DW_EH_PE_funcrel, |
533 | "indirect funcrel") | |
9b84bf7d | 534 | S(DW_EH_PE_indirect | DW_EH_PE_uleb128 | DW_EH_PE_funcrel, |
535 | "indirect funcrel uleb128") | |
536 | S(DW_EH_PE_indirect | DW_EH_PE_udata2 | DW_EH_PE_funcrel, | |
537 | "indirect funcrel udata2") | |
538 | S(DW_EH_PE_indirect | DW_EH_PE_udata4 | DW_EH_PE_funcrel, | |
539 | "indirect funcrel udata4") | |
540 | S(DW_EH_PE_indirect | DW_EH_PE_udata8 | DW_EH_PE_funcrel, | |
541 | "indirect funcrel udata8") | |
542 | S(DW_EH_PE_indirect | DW_EH_PE_sleb128 | DW_EH_PE_funcrel, | |
543 | "indirect funcrel sleb128") | |
544 | S(DW_EH_PE_indirect | DW_EH_PE_sdata2 | DW_EH_PE_funcrel, | |
545 | "indirect funcrel sdata2") | |
546 | S(DW_EH_PE_indirect | DW_EH_PE_sdata4 | DW_EH_PE_funcrel, | |
547 | "indirect funcrel sdata4") | |
548 | S(DW_EH_PE_indirect | DW_EH_PE_sdata8 | DW_EH_PE_funcrel, | |
549 | "indirect funcrel sdata8") | |
550 | ||
551 | #if HAVE_DESIGNATED_INITIALIZERS | |
552 | }; | |
553 | ||
7bd4f6b6 | 554 | gcc_assert (format >= 0 && format < 0x100 && format_names[format]); |
48e1416a | 555 | |
9b84bf7d | 556 | return format_names[format]; |
557 | #else | |
558 | } | |
7bd4f6b6 | 559 | gcc_unreachable (); |
9b84bf7d | 560 | #endif |
561 | } | |
562 | ||
fb39ff6e | 563 | /* Output an unsigned LEB128 quantity, but only the byte values. */ |
564 | ||
565 | void | |
566 | dw2_asm_output_data_uleb128_raw (unsigned HOST_WIDE_INT value) | |
567 | { | |
568 | while (1) | |
569 | { | |
570 | int byte = (value & 0x7f); | |
571 | value >>= 7; | |
572 | if (value != 0) | |
573 | /* More bytes to follow. */ | |
574 | byte |= 0x80; | |
575 | ||
3eb9ad16 | 576 | fprintf (asm_out_file, "%#x", byte); |
fb39ff6e | 577 | if (value == 0) |
578 | break; | |
579 | fputc (',', asm_out_file); | |
580 | } | |
581 | } | |
582 | ||
ca98eb0a | 583 | /* Output an unsigned LEB128 quantity. */ |
584 | ||
585 | void | |
ee582a61 | 586 | dw2_asm_output_data_uleb128 (unsigned HOST_WIDE_INT value, |
587 | const char *comment, ...) | |
ca98eb0a | 588 | { |
ee582a61 | 589 | va_list ap; |
8ec3a57b | 590 | |
ee582a61 | 591 | va_start (ap, comment); |
ca98eb0a | 592 | |
593 | #ifdef HAVE_AS_LEB128 | |
c0e76f1f | 594 | fputs ("\t.uleb128 ", asm_out_file); |
595 | fprint_whex (asm_out_file, value); | |
ca98eb0a | 596 | |
597 | if (flag_debug_asm && comment) | |
598 | { | |
599 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
600 | vfprintf (asm_out_file, comment, ap); | |
601 | } | |
602 | #else | |
603 | { | |
604 | unsigned HOST_WIDE_INT work = value; | |
58356836 | 605 | const char *byte_op = targetm.asm_out.byte_op; |
ca98eb0a | 606 | |
58356836 | 607 | if (byte_op) |
608 | fputs (byte_op, asm_out_file); | |
ca98eb0a | 609 | do |
610 | { | |
611 | int byte = (work & 0x7f); | |
612 | work >>= 7; | |
613 | if (work != 0) | |
614 | /* More bytes to follow. */ | |
615 | byte |= 0x80; | |
616 | ||
58356836 | 617 | if (byte_op) |
618 | { | |
3eb9ad16 | 619 | fprintf (asm_out_file, "%#x", byte); |
58356836 | 620 | if (work != 0) |
621 | fputc (',', asm_out_file); | |
622 | } | |
623 | else | |
624 | assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1); | |
ca98eb0a | 625 | } |
626 | while (work != 0); | |
627 | ||
628 | if (flag_debug_asm) | |
629 | { | |
85aa12f7 | 630 | fprintf (asm_out_file, "\t%s uleb128 " HOST_WIDE_INT_PRINT_HEX, |
631 | ASM_COMMENT_START, value); | |
ca98eb0a | 632 | if (comment) |
633 | { | |
634 | fputs ("; ", asm_out_file); | |
635 | vfprintf (asm_out_file, comment, ap); | |
636 | } | |
637 | } | |
638 | } | |
639 | #endif | |
c0e76f1f | 640 | putc ('\n', asm_out_file); |
ca98eb0a | 641 | |
ee582a61 | 642 | va_end (ap); |
ca98eb0a | 643 | } |
644 | ||
fb39ff6e | 645 | /* Output an signed LEB128 quantity, but only the byte values. */ |
646 | ||
647 | void | |
648 | dw2_asm_output_data_sleb128_raw (HOST_WIDE_INT value) | |
649 | { | |
650 | int byte, more; | |
651 | ||
652 | while (1) | |
653 | { | |
654 | byte = (value & 0x7f); | |
655 | value >>= 7; | |
656 | more = !((value == 0 && (byte & 0x40) == 0) | |
657 | || (value == -1 && (byte & 0x40) != 0)); | |
658 | if (more) | |
659 | byte |= 0x80; | |
660 | ||
3eb9ad16 | 661 | fprintf (asm_out_file, "%#x", byte); |
fb39ff6e | 662 | if (!more) |
663 | break; | |
664 | fputc (',', asm_out_file); | |
665 | } | |
666 | } | |
667 | ||
edc2a478 | 668 | /* Output a signed LEB128 quantity. */ |
ca98eb0a | 669 | |
670 | void | |
ee582a61 | 671 | dw2_asm_output_data_sleb128 (HOST_WIDE_INT value, |
672 | const char *comment, ...) | |
ca98eb0a | 673 | { |
ee582a61 | 674 | va_list ap; |
8ec3a57b | 675 | |
ee582a61 | 676 | va_start (ap, comment); |
ca98eb0a | 677 | |
678 | #ifdef HAVE_AS_LEB128 | |
85aa12f7 | 679 | fprintf (asm_out_file, "\t.sleb128 " HOST_WIDE_INT_PRINT_DEC, value); |
ca98eb0a | 680 | |
681 | if (flag_debug_asm && comment) | |
682 | { | |
683 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
684 | vfprintf (asm_out_file, comment, ap); | |
685 | } | |
686 | #else | |
687 | { | |
688 | HOST_WIDE_INT work = value; | |
689 | int more, byte; | |
58356836 | 690 | const char *byte_op = targetm.asm_out.byte_op; |
ca98eb0a | 691 | |
58356836 | 692 | if (byte_op) |
693 | fputs (byte_op, asm_out_file); | |
ca98eb0a | 694 | do |
695 | { | |
696 | byte = (work & 0x7f); | |
697 | /* arithmetic shift */ | |
698 | work >>= 7; | |
699 | more = !((work == 0 && (byte & 0x40) == 0) | |
700 | || (work == -1 && (byte & 0x40) != 0)); | |
701 | if (more) | |
702 | byte |= 0x80; | |
703 | ||
58356836 | 704 | if (byte_op) |
705 | { | |
3eb9ad16 | 706 | fprintf (asm_out_file, "%#x", byte); |
58356836 | 707 | if (more) |
708 | fputc (',', asm_out_file); | |
709 | } | |
710 | else | |
711 | assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1); | |
ca98eb0a | 712 | } |
713 | while (more); | |
714 | ||
715 | if (flag_debug_asm) | |
716 | { | |
85aa12f7 | 717 | fprintf (asm_out_file, "\t%s sleb128 " HOST_WIDE_INT_PRINT_DEC, |
718 | ASM_COMMENT_START, value); | |
ca98eb0a | 719 | if (comment) |
720 | { | |
721 | fputs ("; ", asm_out_file); | |
722 | vfprintf (asm_out_file, comment, ap); | |
723 | } | |
724 | } | |
725 | } | |
726 | #endif | |
727 | fputc ('\n', asm_out_file); | |
728 | ||
ee582a61 | 729 | va_end (ap); |
ca98eb0a | 730 | } |
731 | ||
732 | void | |
ee582a61 | 733 | dw2_asm_output_delta_uleb128 (const char *lab1 ATTRIBUTE_UNUSED, |
734 | const char *lab2 ATTRIBUTE_UNUSED, | |
735 | const char *comment, ...) | |
ca98eb0a | 736 | { |
ee582a61 | 737 | va_list ap; |
738 | ||
739 | va_start (ap, comment); | |
ca98eb0a | 740 | |
741 | #ifdef HAVE_AS_LEB128 | |
8de0b9f7 | 742 | fputs ("\t.uleb128 ", asm_out_file); |
ca98eb0a | 743 | assemble_name (asm_out_file, lab1); |
c0e76f1f | 744 | putc ('-', asm_out_file); |
ca98eb0a | 745 | assemble_name (asm_out_file, lab2); |
746 | #else | |
7bd4f6b6 | 747 | gcc_unreachable (); |
ca98eb0a | 748 | #endif |
749 | ||
750 | if (flag_debug_asm && comment) | |
751 | { | |
752 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
753 | vfprintf (asm_out_file, comment, ap); | |
754 | } | |
755 | fputc ('\n', asm_out_file); | |
756 | ||
ee582a61 | 757 | va_end (ap); |
ca98eb0a | 758 | } |
759 | ||
31ac8297 | 760 | #if 0 |
761 | ||
ca98eb0a | 762 | void |
ee582a61 | 763 | dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED, |
764 | const char *lab2 ATTRIBUTE_UNUSED, | |
765 | const char *comment, ...) | |
ca98eb0a | 766 | { |
ee582a61 | 767 | va_list ap; |
8ec3a57b | 768 | |
ee582a61 | 769 | va_start (ap, comment); |
ca98eb0a | 770 | |
771 | #ifdef HAVE_AS_LEB128 | |
8de0b9f7 | 772 | fputs ("\t.sleb128 ", asm_out_file); |
ca98eb0a | 773 | assemble_name (asm_out_file, lab1); |
c0e76f1f | 774 | putc ('-', asm_out_file); |
ca98eb0a | 775 | assemble_name (asm_out_file, lab2); |
776 | #else | |
7bd4f6b6 | 777 | gcc_unreachable (); |
ca98eb0a | 778 | #endif |
779 | ||
780 | if (flag_debug_asm && comment) | |
781 | { | |
782 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
783 | vfprintf (asm_out_file, comment, ap); | |
784 | } | |
785 | fputc ('\n', asm_out_file); | |
786 | ||
ee582a61 | 787 | va_end (ap); |
ca98eb0a | 788 | } |
31ac8297 | 789 | #endif /* 0 */ |
ad5818ae | 790 | \f |
8ec3a57b | 791 | static int dw2_output_indirect_constant_1 (splay_tree_node, void *); |
ad5818ae | 792 | |
573aba85 | 793 | static GTY((param1_is (char *), param2_is (tree))) splay_tree indirect_pool; |
794 | ||
795 | static GTY(()) int dw2_const_labelno; | |
ad5818ae | 796 | |
293c8430 | 797 | #if defined(HAVE_GAS_HIDDEN) |
798 | # define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY) | |
403cf343 | 799 | #else |
800 | # define USE_LINKONCE_INDIRECT 0 | |
801 | #endif | |
802 | ||
d9ab39c7 | 803 | /* Comparison function for a splay tree in which the keys are strings. |
804 | K1 and K2 have the dynamic type "const char *". Returns <0, 0, or | |
805 | >0 to indicate whether K1 is less than, equal to, or greater than | |
806 | K2, respectively. */ | |
807 | ||
808 | static int | |
809 | splay_tree_compare_strings (splay_tree_key k1, splay_tree_key k2) | |
810 | { | |
811 | const char *s1 = (const char *)k1; | |
812 | const char *s2 = (const char *)k2; | |
813 | int ret; | |
814 | ||
815 | if (s1 == s2) | |
816 | return 0; | |
817 | ||
818 | ret = strcmp (s1, s2); | |
819 | ||
820 | /* The strings are always those from IDENTIFIER_NODEs, and, | |
821 | therefore, we should never have two copies of the same | |
822 | string. */ | |
823 | gcc_assert (ret); | |
824 | ||
825 | return ret; | |
826 | } | |
827 | ||
9b84bf7d | 828 | /* Put X, a SYMBOL_REF, in memory. Return a SYMBOL_REF to the allocated |
829 | memory. Differs from force_const_mem in that a single pool is used for | |
830 | the entire unit of translation, and the memory is not guaranteed to be | |
6659485c | 831 | "near" the function in any interesting sense. IS_PUBLIC controls whether |
42e07529 | 832 | the symbol can be shared across the entire application (or DSO). */ |
9b84bf7d | 833 | |
fb39ff6e | 834 | rtx |
6659485c | 835 | dw2_force_const_mem (rtx x, bool is_public) |
ad5818ae | 836 | { |
837 | splay_tree_node node; | |
215ba52a | 838 | const char *key; |
1e03a59b | 839 | tree decl_id; |
ad5818ae | 840 | |
841 | if (! indirect_pool) | |
d9ab39c7 | 842 | /* We use strcmp, rather than just comparing pointers, so that the |
843 | sort order will not depend on the host system. */ | |
ba72912a | 844 | indirect_pool = splay_tree_new_ggc (splay_tree_compare_strings, |
845 | ggc_alloc_splay_tree_str_tree_node_splay_tree_s, | |
846 | ggc_alloc_splay_tree_str_tree_node_splay_tree_node_s); | |
ad5818ae | 847 | |
7bd4f6b6 | 848 | gcc_assert (GET_CODE (x) == SYMBOL_REF); |
dc4303d7 | 849 | |
215ba52a | 850 | key = XSTR (x, 0); |
851 | node = splay_tree_lookup (indirect_pool, (splay_tree_key) key); | |
ad5818ae | 852 | if (node) |
1e03a59b | 853 | decl_id = (tree) node->value; |
ad5818ae | 854 | else |
855 | { | |
ad5818ae | 856 | tree id; |
215ba52a | 857 | const char *str = targetm.strip_name_encoding (key); |
ad5818ae | 858 | |
6659485c | 859 | if (is_public && USE_LINKONCE_INDIRECT) |
403cf343 | 860 | { |
364c0c59 | 861 | char *ref_name = XALLOCAVEC (char, strlen (str) + sizeof "DW.ref."); |
403cf343 | 862 | |
dc4303d7 | 863 | sprintf (ref_name, "DW.ref.%s", str); |
1e03a59b | 864 | gcc_assert (!maybe_get_identifier (ref_name)); |
865 | decl_id = get_identifier (ref_name); | |
866 | TREE_PUBLIC (decl_id) = 1; | |
403cf343 | 867 | } |
868 | else | |
869 | { | |
403cf343 | 870 | char label[32]; |
871 | ||
573aba85 | 872 | ASM_GENERATE_INTERNAL_LABEL (label, "LDFCM", dw2_const_labelno); |
873 | ++dw2_const_labelno; | |
1e03a59b | 874 | gcc_assert (!maybe_get_identifier (label)); |
875 | decl_id = get_identifier (label); | |
403cf343 | 876 | } |
ad5818ae | 877 | |
dc4303d7 | 878 | id = maybe_get_identifier (str); |
ad5818ae | 879 | if (id) |
880 | TREE_SYMBOL_REFERENCED (id) = 1; | |
881 | ||
215ba52a | 882 | splay_tree_insert (indirect_pool, (splay_tree_key) key, |
1e03a59b | 883 | (splay_tree_value) decl_id); |
ad5818ae | 884 | } |
885 | ||
1e03a59b | 886 | return gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (decl_id)); |
ad5818ae | 887 | } |
888 | ||
9b84bf7d | 889 | /* A helper function for dw2_output_indirect_constants called through |
890 | splay_tree_foreach. Emit one queued constant to memory. */ | |
891 | ||
ad5818ae | 892 | static int |
8ec3a57b | 893 | dw2_output_indirect_constant_1 (splay_tree_node node, |
894 | void *data ATTRIBUTE_UNUSED) | |
ad5818ae | 895 | { |
403cf343 | 896 | const char *sym; |
ad5818ae | 897 | rtx sym_ref; |
1e03a59b | 898 | tree id, decl; |
ad5818ae | 899 | |
ad5818ae | 900 | sym = (const char *) node->key; |
1e03a59b | 901 | id = (tree) node->value; |
902 | ||
e60a6f7b | 903 | decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node); |
f53d8360 | 904 | SET_DECL_ASSEMBLER_NAME (decl, id); |
1e03a59b | 905 | DECL_ARTIFICIAL (decl) = 1; |
906 | DECL_IGNORED_P (decl) = 1; | |
907 | DECL_INITIAL (decl) = decl; | |
6834c43a | 908 | TREE_READONLY (decl) = 1; |
2fd796fd | 909 | TREE_STATIC (decl) = 1; |
1e03a59b | 910 | |
911 | if (TREE_PUBLIC (id)) | |
912 | { | |
913 | TREE_PUBLIC (decl) = 1; | |
ecd88073 | 914 | make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); |
b9099475 | 915 | if (USE_LINKONCE_INDIRECT) |
916 | DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; | |
1e03a59b | 917 | } |
1e03a59b | 918 | |
ad5818ae | 919 | sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym); |
42e07529 | 920 | assemble_variable (decl, 1, 1, 1); |
d24cc82a | 921 | assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); |
ad5818ae | 922 | |
923 | return 0; | |
924 | } | |
925 | ||
9b84bf7d | 926 | /* Emit the constants queued through dw2_force_const_mem. */ |
927 | ||
ad5818ae | 928 | void |
8ec3a57b | 929 | dw2_output_indirect_constants (void) |
ad5818ae | 930 | { |
403cf343 | 931 | if (indirect_pool) |
932 | splay_tree_foreach (indirect_pool, dw2_output_indirect_constant_1, NULL); | |
ad5818ae | 933 | } |
934 | ||
42e07529 | 935 | /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed. |
936 | If PUBLIC is set and the encoding is DW_EH_PE_indirect, the indirect | |
937 | reference is shared across the entire application (or DSO). */ | |
9b84bf7d | 938 | |
ad5818ae | 939 | void |
6659485c | 940 | dw2_asm_output_encoded_addr_rtx (int encoding, rtx addr, bool is_public, |
ee582a61 | 941 | const char *comment, ...) |
ad5818ae | 942 | { |
943 | int size; | |
ee582a61 | 944 | va_list ap; |
8ec3a57b | 945 | |
ee582a61 | 946 | va_start (ap, comment); |
9b84bf7d | 947 | |
948 | size = size_of_encoded_value (encoding); | |
ad5818ae | 949 | |
9a4d22ba | 950 | if (encoding == DW_EH_PE_aligned) |
951 | { | |
952 | assemble_align (POINTER_SIZE); | |
104eedee | 953 | assemble_integer (addr, size, POINTER_SIZE, 1); |
451c8e2f | 954 | va_end (ap); |
104eedee | 955 | return; |
9a4d22ba | 956 | } |
957 | ||
1c6585ca | 958 | /* NULL is _always_ represented as a plain zero, as is 1 for Ada's |
959 | "all others". */ | |
960 | if (addr == const0_rtx || addr == const1_rtx) | |
09d688ff | 961 | assemble_integer (addr, size, BITS_PER_UNIT, 1); |
9b84bf7d | 962 | else |
ad5818ae | 963 | { |
9b84bf7d | 964 | restart: |
965 | /* Allow the target first crack at emitting this. Some of the | |
1eefe280 | 966 | special relocations require special directives instead of |
9b84bf7d | 967 | just ".4byte" or whatever. */ |
ad5818ae | 968 | #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX |
9b84bf7d | 969 | ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX (asm_out_file, encoding, size, |
970 | addr, done); | |
ad5818ae | 971 | #endif |
972 | ||
9b84bf7d | 973 | /* Indirection is used to get dynamic relocations out of a |
974 | read-only section. */ | |
975 | if (encoding & DW_EH_PE_indirect) | |
976 | { | |
977 | /* It is very tempting to use force_const_mem so that we share data | |
978 | with the normal constant pool. However, we've already emitted | |
979 | the constant pool for this function. Moreover, we'd like to | |
42e07529 | 980 | share these constants across the entire unit of translation and |
981 | even, if possible, across the entire application (or DSO). */ | |
6659485c | 982 | addr = dw2_force_const_mem (addr, is_public); |
9b84bf7d | 983 | encoding &= ~DW_EH_PE_indirect; |
984 | goto restart; | |
985 | } | |
ad5818ae | 986 | |
9b84bf7d | 987 | switch (encoding & 0xF0) |
988 | { | |
989 | case DW_EH_PE_absptr: | |
58356836 | 990 | dw2_assemble_integer (size, addr); |
9b84bf7d | 991 | break; |
ad5818ae | 992 | |
9b84bf7d | 993 | case DW_EH_PE_pcrel: |
7bd4f6b6 | 994 | gcc_assert (GET_CODE (addr) == SYMBOL_REF); |
ad5818ae | 995 | #ifdef ASM_OUTPUT_DWARF_PCREL |
9b84bf7d | 996 | ASM_OUTPUT_DWARF_PCREL (asm_out_file, size, XSTR (addr, 0)); |
ad5818ae | 997 | #else |
58356836 | 998 | dw2_assemble_integer (size, gen_rtx_MINUS (Pmode, addr, pc_rtx)); |
ad5818ae | 999 | #endif |
9b84bf7d | 1000 | break; |
ad5818ae | 1001 | |
9b84bf7d | 1002 | default: |
1eefe280 | 1003 | /* Other encodings should have been handled by |
9b84bf7d | 1004 | ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX. */ |
7bd4f6b6 | 1005 | gcc_unreachable (); |
9b84bf7d | 1006 | } |
ad5818ae | 1007 | |
1008 | #ifdef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX | |
9b84bf7d | 1009 | done:; |
ad5818ae | 1010 | #endif |
9b84bf7d | 1011 | } |
1012 | ||
1013 | if (flag_debug_asm && comment) | |
1014 | { | |
1015 | fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); | |
1016 | vfprintf (asm_out_file, comment, ap); | |
1017 | } | |
ad5818ae | 1018 | fputc ('\n', asm_out_file); |
9b84bf7d | 1019 | |
ee582a61 | 1020 | va_end (ap); |
ad5818ae | 1021 | } |
573aba85 | 1022 | |
1023 | #include "gt-dwarf2asm.h" |