| OLD | NEW |
| 1 /* | 1 /* |
| 2 * DWARF2 debugging format | 2 * DWARF2 debugging format |
| 3 * | 3 * |
| 4 * Copyright (C) 2006-2007 Peter Johnson | 4 * Copyright (C) 2006-2007 Peter Johnson |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
| 12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
| 13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
| 14 * | 14 * |
| 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' | 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' |
| 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE | 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
| 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 * POSSIBILITY OF SUCH DAMAGE. | 25 * POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 #include <util.h> | 27 #include <util.h> |
| 28 /*@unused@*/ RCSID("$Id: dwarf2-dbgfmt.c 2130 2008-10-07 05:38:11Z peter $"); | |
| 29 | 28 |
| 30 #include <libyasm.h> | 29 #include <libyasm.h> |
| 31 | 30 |
| 32 #include "dwarf2-dbgfmt.h" | 31 #include "dwarf2-dbgfmt.h" |
| 33 | 32 |
| 34 struct dwarf2_head { | 33 struct dwarf2_head { |
| 35 yasm_bytecode *start_prevbc; | 34 yasm_bytecode *start_prevbc; |
| 36 yasm_bytecode *end_prevbc; | 35 yasm_bytecode *end_prevbc; |
| 37 /*@null@*/ yasm_section *debug_ptr; | 36 /*@null@*/ yasm_section *debug_ptr; |
| 38 int with_address; | 37 int with_address; |
| 39 int with_segment; | 38 int with_segment; |
| 40 }; | 39 }; |
| 41 | 40 |
| 42 /* Bytecode callback function prototypes */ | 41 /* Bytecode callback function prototypes */ |
| 43 static void dwarf2_head_bc_destroy(void *contents); | 42 static void dwarf2_head_bc_destroy(void *contents); |
| 44 static void dwarf2_head_bc_print(const void *contents, FILE *f, | 43 static void dwarf2_head_bc_print(const void *contents, FILE *f, |
| 45 int indent_level); | 44 int indent_level); |
| 46 static int dwarf2_head_bc_calc_len | 45 static int dwarf2_head_bc_calc_len |
| 47 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); | 46 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); |
| 48 static int dwarf2_head_bc_tobytes | 47 static int dwarf2_head_bc_tobytes |
| 49 (yasm_bytecode *bc, unsigned char **bufp, void *d, | 48 (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, |
| 50 yasm_output_value_func output_value, | 49 yasm_output_value_func output_value, |
| 51 /*@null@*/ yasm_output_reloc_func output_reloc); | 50 /*@null@*/ yasm_output_reloc_func output_reloc); |
| 52 | 51 |
| 53 /* Bytecode callback structures */ | 52 /* Bytecode callback structures */ |
| 54 static const yasm_bytecode_callback dwarf2_head_bc_callback = { | 53 static const yasm_bytecode_callback dwarf2_head_bc_callback = { |
| 55 dwarf2_head_bc_destroy, | 54 dwarf2_head_bc_destroy, |
| 56 dwarf2_head_bc_print, | 55 dwarf2_head_bc_print, |
| 57 yasm_bc_finalize_common, | 56 yasm_bc_finalize_common, |
| 58 NULL, | 57 NULL, |
| 59 dwarf2_head_bc_calc_len, | 58 dwarf2_head_bc_calc_len, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 static int | 240 static int |
| 242 dwarf2_head_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, | 241 dwarf2_head_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, |
| 243 void *add_span_data) | 242 void *add_span_data) |
| 244 { | 243 { |
| 245 yasm_internal_error(N_("tried to calc_len a dwarf2 head bytecode")); | 244 yasm_internal_error(N_("tried to calc_len a dwarf2 head bytecode")); |
| 246 /*@notreached@*/ | 245 /*@notreached@*/ |
| 247 return 0; | 246 return 0; |
| 248 } | 247 } |
| 249 | 248 |
| 250 static int | 249 static int |
| 251 dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, | 250 dwarf2_head_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, |
| 251 unsigned char *bufstart, void *d, |
| 252 yasm_output_value_func output_value, | 252 yasm_output_value_func output_value, |
| 253 yasm_output_reloc_func output_reloc) | 253 yasm_output_reloc_func output_reloc) |
| 254 { | 254 { |
| 255 yasm_object *object = yasm_section_get_object(bc->section); | 255 yasm_object *object = yasm_section_get_object(bc->section); |
| 256 yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; | 256 yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2 = (yasm_dbgfmt_dwarf2 *)object->dbgfmt; |
| 257 dwarf2_head *head = (dwarf2_head *)bc->contents; | 257 dwarf2_head *head = (dwarf2_head *)bc->contents; |
| 258 unsigned char *buf = *bufp; | 258 unsigned char *buf = *bufp; |
| 259 yasm_intnum *intn, *cval; | 259 yasm_intnum *intn, *cval; |
| 260 | 260 |
| 261 if (dbgfmt_dwarf2->format == DWARF2_FORMAT_64BIT) { | 261 if (dbgfmt_dwarf2->format == DWARF2_FORMAT_64BIT) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 281 buf += 2; | 281 buf += 2; |
| 282 | 282 |
| 283 /* Pointer to another debug section */ | 283 /* Pointer to another debug section */ |
| 284 if (head->debug_ptr) { | 284 if (head->debug_ptr) { |
| 285 yasm_value value; | 285 yasm_value value; |
| 286 yasm_value_init_sym(&value, | 286 yasm_value_init_sym(&value, |
| 287 yasm_dwarf2__bc_sym(object->symtab, | 287 yasm_dwarf2__bc_sym(object->symtab, |
| 288 yasm_section_bcs_first(head->debug_ptr)), | 288 yasm_section_bcs_first(head->debug_ptr)), |
| 289 dbgfmt_dwarf2->sizeof_offset*8); | 289 dbgfmt_dwarf2->sizeof_offset*8); |
| 290 output_value(&value, buf, dbgfmt_dwarf2->sizeof_offset, | 290 output_value(&value, buf, dbgfmt_dwarf2->sizeof_offset, |
| 291 (unsigned long)(buf-*bufp), bc, 0, d); | 291 (unsigned long)(buf-bufstart), bc, 0, d); |
| 292 buf += dbgfmt_dwarf2->sizeof_offset; | 292 buf += dbgfmt_dwarf2->sizeof_offset; |
| 293 } | 293 } |
| 294 | 294 |
| 295 /* Size of the offset portion of the address */ | 295 /* Size of the offset portion of the address */ |
| 296 if (head->with_address) | 296 if (head->with_address) |
| 297 YASM_WRITE_8(buf, dbgfmt_dwarf2->sizeof_address); | 297 YASM_WRITE_8(buf, dbgfmt_dwarf2->sizeof_address); |
| 298 | 298 |
| 299 /* Size of a segment descriptor. 0 = flat address space */ | 299 /* Size of a segment descriptor. 0 = flat address space */ |
| 300 if (head->with_segment) | 300 if (head->with_segment) |
| 301 YASM_WRITE_8(buf, 0); | 301 YASM_WRITE_8(buf, 0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 /* Define dbgfmt structure -- see dbgfmt.h for details */ | 340 /* Define dbgfmt structure -- see dbgfmt.h for details */ |
| 341 yasm_dbgfmt_module yasm_dwarf2_LTX_dbgfmt = { | 341 yasm_dbgfmt_module yasm_dwarf2_LTX_dbgfmt = { |
| 342 "DWARF2 debugging format", | 342 "DWARF2 debugging format", |
| 343 "dwarf2", | 343 "dwarf2", |
| 344 dwarf2_directives, | 344 dwarf2_directives, |
| 345 dwarf2_dbgfmt_create, | 345 dwarf2_dbgfmt_create, |
| 346 dwarf2_dbgfmt_destroy, | 346 dwarf2_dbgfmt_destroy, |
| 347 dwarf2_dbgfmt_generate | 347 dwarf2_dbgfmt_generate |
| 348 }; | 348 }; |
| OLD | NEW |