Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/yasm/patched-yasm/modules/dbgfmts/codeview/cv-symline.c

Issue 11364046: Update Yasm to 1.2.0 (Yasm Part 1/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * CodeView debugging format - symbol and line information 2 * CodeView debugging format - symbol and line information
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.
(...skipping 10 matching lines...) Expand all
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE. 28 * POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 #include <util.h> 30 #include <util.h>
31 /*@unused@*/ RCSID("$Id: cv-symline.c 2258 2010-01-03 01:04:18Z peter $");
32 31
33 #include <libyasm.h> 32 #include <libyasm.h>
34 33
35 #include "cv-dbgfmt.h" 34 #include "cv-dbgfmt.h"
36 35
37 enum cv8_symheadtype { 36 enum cv8_symheadtype {
38 CV8_DEBUG_SYMS = 0xF1, /* CV5 symbol information */ 37 CV8_DEBUG_SYMS = 0xF1, /* CV5 symbol information */
39 CV8_LINE_NUMS = 0xF2, /* line numbers for a section */ 38 CV8_LINE_NUMS = 0xF2, /* line numbers for a section */
40 CV8_FILE_STRTAB = 0xF3, /* filename string table */ 39 CV8_FILE_STRTAB = 0xF3, /* filename string table */
41 CV8_FILE_INFO = 0xF4 /* source file info */ 40 CV8_FILE_INFO = 0xF4 /* source file info */
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } args[10]; 155 } args[10];
157 } cv_sym; 156 } cv_sym;
158 157
159 /* Bytecode callback function prototypes */ 158 /* Bytecode callback function prototypes */
160 static void cv8_symhead_bc_destroy(void *contents); 159 static void cv8_symhead_bc_destroy(void *contents);
161 static void cv8_symhead_bc_print(const void *contents, FILE *f, 160 static void cv8_symhead_bc_print(const void *contents, FILE *f,
162 int indent_level); 161 int indent_level);
163 static int cv8_symhead_bc_calc_len 162 static int cv8_symhead_bc_calc_len
164 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); 163 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
165 static int cv8_symhead_bc_tobytes 164 static int cv8_symhead_bc_tobytes
166 (yasm_bytecode *bc, unsigned char **bufp, void *d, 165 (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
167 yasm_output_value_func output_value, 166 yasm_output_value_func output_value,
168 /*@null@*/ yasm_output_reloc_func output_reloc); 167 /*@null@*/ yasm_output_reloc_func output_reloc);
169 168
170 static void cv8_fileinfo_bc_destroy(void *contents); 169 static void cv8_fileinfo_bc_destroy(void *contents);
171 static void cv8_fileinfo_bc_print(const void *contents, FILE *f, 170 static void cv8_fileinfo_bc_print(const void *contents, FILE *f,
172 int indent_level); 171 int indent_level);
173 static int cv8_fileinfo_bc_calc_len 172 static int cv8_fileinfo_bc_calc_len
174 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); 173 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
175 static int cv8_fileinfo_bc_tobytes 174 static int cv8_fileinfo_bc_tobytes
176 (yasm_bytecode *bc, unsigned char **bufp, void *d, 175 (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
177 yasm_output_value_func output_value, 176 yasm_output_value_func output_value,
178 /*@null@*/ yasm_output_reloc_func output_reloc); 177 /*@null@*/ yasm_output_reloc_func output_reloc);
179 178
180 static void cv8_lineinfo_bc_destroy(void *contents); 179 static void cv8_lineinfo_bc_destroy(void *contents);
181 static void cv8_lineinfo_bc_print(const void *contents, FILE *f, 180 static void cv8_lineinfo_bc_print(const void *contents, FILE *f,
182 int indent_level); 181 int indent_level);
183 static int cv8_lineinfo_bc_calc_len 182 static int cv8_lineinfo_bc_calc_len
184 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); 183 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
185 static int cv8_lineinfo_bc_tobytes 184 static int cv8_lineinfo_bc_tobytes
186 (yasm_bytecode *bc, unsigned char **bufp, void *d, 185 (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
187 yasm_output_value_func output_value, 186 yasm_output_value_func output_value,
188 /*@null@*/ yasm_output_reloc_func output_reloc); 187 /*@null@*/ yasm_output_reloc_func output_reloc);
189 188
190 static void cv_sym_bc_destroy(void *contents); 189 static void cv_sym_bc_destroy(void *contents);
191 static void cv_sym_bc_print(const void *contents, FILE *f, int indent_level); 190 static void cv_sym_bc_print(const void *contents, FILE *f, int indent_level);
192 static int cv_sym_bc_calc_len 191 static int cv_sym_bc_calc_len
193 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); 192 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data);
194 static int cv_sym_bc_tobytes 193 static int cv_sym_bc_tobytes
195 (yasm_bytecode *bc, unsigned char **bufp, void *d, 194 (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d,
196 yasm_output_value_func output_value, 195 yasm_output_value_func output_value,
197 /*@null@*/ yasm_output_reloc_func output_reloc); 196 /*@null@*/ yasm_output_reloc_func output_reloc);
198 197
199 /* Bytecode callback structures */ 198 /* Bytecode callback structures */
200 static const yasm_bytecode_callback cv8_symhead_bc_callback = { 199 static const yasm_bytecode_callback cv8_symhead_bc_callback = {
201 cv8_symhead_bc_destroy, 200 cv8_symhead_bc_destroy,
202 cv8_symhead_bc_print, 201 cv8_symhead_bc_print,
203 yasm_bc_finalize_common, 202 yasm_bc_finalize_common,
204 NULL, 203 NULL,
205 cv8_symhead_bc_calc_len, 204 cv8_symhead_bc_calc_len,
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); 630 cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline));
632 } 631 }
633 632
634 /* Already aligned 4 */ 633 /* Already aligned 4 */
635 634
636 /* Output debugging symbols */ 635 /* Output debugging symbols */
637 head = cv8_add_symhead(info.debug_symline, CV8_DEBUG_SYMS, 0); 636 head = cv8_add_symhead(info.debug_symline, CV8_DEBUG_SYMS, 0);
638 /* add object and compile flag first */ 637 /* add object and compile flag first */
639 cv8_add_sym_objname(info.debug_symline, 638 cv8_add_sym_objname(info.debug_symline,
640 yasm__abspath(object->obj_filename)); 639 yasm__abspath(object->obj_filename));
641 cv8_add_sym_compile(object, info.debug_symline, 640 if (getenv("YASM_TEST_SUITE"))
642 yasm__xstrdup(PACKAGE_NAME " " PACKAGE_INTVER "." 641 cv8_add_sym_compile(object, info.debug_symline,
643 PACKAGE_BUILD)); 642 yasm__xstrdup("yasm HEAD"));
643 else
644 cv8_add_sym_compile(object, info.debug_symline,
645 yasm__xstrdup(PACKAGE_STRING));
644 /* then iterate through symbol table */ 646 /* then iterate through symbol table */
645 yasm_symtab_traverse(object->symtab, &info, cv_generate_sym); 647 yasm_symtab_traverse(object->symtab, &info, cv_generate_sym);
646 cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline)); 648 cv8_set_symhead_end(head, yasm_section_bcs_last(info.debug_symline));
647 649
648 /* Align 4 at end */ 650 /* Align 4 at end */
649 bc = yasm_bc_create_align 651 bc = yasm_bc_create_align
650 (yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), 0), 652 (yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(4)), 0),
651 NULL, NULL, NULL, 0); 653 NULL, NULL, NULL, 0);
652 yasm_bc_finalize(bc, yasm_cv__append_bc(info.debug_symline, bc)); 654 yasm_bc_finalize(bc, yasm_cv__append_bc(info.debug_symline, bc));
653 yasm_bc_calc_len(bc, NULL, NULL); 655 yasm_bc_calc_len(bc, NULL, NULL);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 static int 719 static int
718 cv8_symhead_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, 720 cv8_symhead_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
719 void *add_span_data) 721 void *add_span_data)
720 { 722 {
721 yasm_internal_error(N_("tried to calc_len a codeview symhead bytecode")); 723 yasm_internal_error(N_("tried to calc_len a codeview symhead bytecode"));
722 /*@notreached@*/ 724 /*@notreached@*/
723 return 0; 725 return 0;
724 } 726 }
725 727
726 static int 728 static int
727 cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, 729 cv8_symhead_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
730 unsigned char *bufstart, void *d,
728 yasm_output_value_func output_value, 731 yasm_output_value_func output_value,
729 yasm_output_reloc_func output_reloc) 732 yasm_output_reloc_func output_reloc)
730 { 733 {
731 yasm_object *object = yasm_section_get_object(bc->section); 734 yasm_object *object = yasm_section_get_object(bc->section);
732 cv8_symhead *head = (cv8_symhead *)bc->contents; 735 cv8_symhead *head = (cv8_symhead *)bc->contents;
733 unsigned char *buf = *bufp; 736 unsigned char *buf = *bufp;
734 yasm_intnum *intn, *cval; 737 yasm_intnum *intn, *cval;
735 738
736 cval = yasm_intnum_create_uint(4); 739 cval = yasm_intnum_create_uint(4);
737 /* Output "version" if first */ 740 /* Output "version" if first */
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 static int 793 static int
791 cv8_fileinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, 794 cv8_fileinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
792 void *add_span_data) 795 void *add_span_data)
793 { 796 {
794 yasm_internal_error(N_("tried to calc_len a codeview fileinfo bytecode")); 797 yasm_internal_error(N_("tried to calc_len a codeview fileinfo bytecode"));
795 /*@notreached@*/ 798 /*@notreached@*/
796 return 0; 799 return 0;
797 } 800 }
798 801
799 static int 802 static int
800 cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, 803 cv8_fileinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
804 unsigned char *bufstart, void *d,
801 yasm_output_value_func output_value, 805 yasm_output_value_func output_value,
802 yasm_output_reloc_func output_reloc) 806 yasm_output_reloc_func output_reloc)
803 { 807 {
804 yasm_object *object = yasm_section_get_object(bc->section); 808 yasm_object *object = yasm_section_get_object(bc->section);
805 cv8_fileinfo *fi = (cv8_fileinfo *)bc->contents; 809 cv8_fileinfo *fi = (cv8_fileinfo *)bc->contents;
806 unsigned char *buf = *bufp; 810 unsigned char *buf = *bufp;
807 yasm_intnum *cval; 811 yasm_intnum *cval;
808 int i; 812 int i;
809 813
810 /* Offset in filename string table */ 814 /* Offset in filename string table */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 static int 861 static int
858 cv8_lineinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, 862 cv8_lineinfo_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
859 void *add_span_data) 863 void *add_span_data)
860 { 864 {
861 yasm_internal_error(N_("tried to calc_len a codeview linehead bytecode")); 865 yasm_internal_error(N_("tried to calc_len a codeview linehead bytecode"));
862 /*@notreached@*/ 866 /*@notreached@*/
863 return 0; 867 return 0;
864 } 868 }
865 869
866 static int 870 static int
867 cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, 871 cv8_lineinfo_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
872 unsigned char *bufstart, void *d,
868 yasm_output_value_func output_value, 873 yasm_output_value_func output_value,
869 yasm_output_reloc_func output_reloc) 874 yasm_output_reloc_func output_reloc)
870 { 875 {
871 yasm_object *object = yasm_section_get_object(bc->section); 876 yasm_object *object = yasm_section_get_object(bc->section);
872 cv8_lineinfo *li = (cv8_lineinfo *)bc->contents; 877 cv8_lineinfo *li = (cv8_lineinfo *)bc->contents;
873 unsigned char *buf = *bufp; 878 unsigned char *buf = *bufp;
874 yasm_intnum *cval; 879 yasm_intnum *cval;
875 unsigned long i; 880 unsigned long i;
876 cv8_lineset *ls; 881 cv8_lineset *ls;
877 882
878 /* start offset and section */ 883 /* start offset and section */
879 cv_out_sym(li->sectsym, 0, bc, &buf, d, output_value); 884 cv_out_sym(li->sectsym, (unsigned long)(buf - bufstart), bc, &buf,
885 d, output_value);
880 886
881 /* Two bytes of pad/alignment */ 887 /* Two bytes of pad/alignment */
882 YASM_WRITE_8(buf, 0); 888 YASM_WRITE_8(buf, 0);
883 YASM_WRITE_8(buf, 0); 889 YASM_WRITE_8(buf, 0);
884 890
885 /* Section length covered by line number info */ 891 /* Section length covered by line number info */
886 cval = yasm_calc_bc_dist(yasm_section_bcs_first(li->sect), 892 cval = yasm_calc_bc_dist(yasm_section_bcs_first(li->sect),
887 yasm_section_bcs_last(li->sect)); 893 yasm_section_bcs_last(li->sect));
888 yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0); 894 yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, bc, 0);
889 buf += 4; 895 buf += 4;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 static int 1018 static int
1013 cv_sym_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, 1019 cv_sym_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
1014 void *add_span_data) 1020 void *add_span_data)
1015 { 1021 {
1016 yasm_internal_error(N_("tried to calc_len a codeview sym bytecode")); 1022 yasm_internal_error(N_("tried to calc_len a codeview sym bytecode"));
1017 /*@notreached@*/ 1023 /*@notreached@*/
1018 return 0; 1024 return 0;
1019 } 1025 }
1020 1026
1021 static int 1027 static int
1022 cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, 1028 cv_sym_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
1029 unsigned char *bufstart, void *d,
1023 yasm_output_value_func output_value, 1030 yasm_output_value_func output_value,
1024 yasm_output_reloc_func output_reloc) 1031 yasm_output_reloc_func output_reloc)
1025 { 1032 {
1026 yasm_object *object = yasm_section_get_object(bc->section); 1033 yasm_object *object = yasm_section_get_object(bc->section);
1027 cv_sym *cvs = (cv_sym *)bc->contents; 1034 cv_sym *cvs = (cv_sym *)bc->contents;
1028 unsigned char *buf = *bufp; 1035 unsigned char *buf = *bufp;
1029 yasm_intnum *cval; 1036 yasm_intnum *cval;
1030 const char *ch = cvs->format; 1037 const char *ch = cvs->format;
1031 size_t len; 1038 size_t len;
1032 int arg = 0; 1039 int arg = 0;
(...skipping 21 matching lines...) Expand all
1054 buf += 2; 1061 buf += 2;
1055 break; 1062 break;
1056 case 'w': 1063 case 'w':
1057 yasm_intnum_set_uint(cval, cvs->args[arg++].i); 1064 yasm_intnum_set_uint(cval, cvs->args[arg++].i);
1058 yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, 1065 yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0,
1059 bc, 0); 1066 bc, 0);
1060 buf += 4; 1067 buf += 4;
1061 break; 1068 break;
1062 case 'Y': 1069 case 'Y':
1063 cv_out_sym((yasm_symrec *)cvs->args[arg++].p, 1070 cv_out_sym((yasm_symrec *)cvs->args[arg++].p,
1064 (unsigned long)(buf-(*bufp)), bc, &buf, d, 1071 (unsigned long)(buf-bufstart), bc, &buf, d,
1065 output_value); 1072 output_value);
1066 break; 1073 break;
1067 case 'T': 1074 case 'T':
1068 yasm_intnum_set_uint(cval, cvs->args[arg++].i); 1075 yasm_intnum_set_uint(cval, cvs->args[arg++].i);
1069 yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0, 1076 yasm_arch_intnum_tobytes(object->arch, cval, buf, 4, 32, 0,
1070 bc, 0); 1077 bc, 0);
1071 buf += 4; /* XXX: will be 2 in CV4 */ 1078 buf += 4; /* XXX: will be 2 in CV4 */
1072 break; 1079 break;
1073 case 'S': 1080 case 'S':
1074 len = strlen((char *)cvs->args[arg].p); 1081 len = strlen((char *)cvs->args[arg].p);
(...skipping 13 matching lines...) Expand all
1088 yasm_internal_error(N_("unknown leaf format character")); 1095 yasm_internal_error(N_("unknown leaf format character"));
1089 } 1096 }
1090 ch++; 1097 ch++;
1091 } 1098 }
1092 1099
1093 *bufp = buf; 1100 *bufp = buf;
1094 1101
1095 yasm_intnum_destroy(cval); 1102 yasm_intnum_destroy(cval);
1096 return 0; 1103 return 0;
1097 } 1104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698