| 1087 | forms, because we don't care about them. */ |
| 1088 | |
| 1089 | static int |
| 1090 | read_attribute (enum dwarf_form form, uint64_t implicit_val, |
| 1091 | struct dwarf_buf *buf, int is_dwarf64, int version, |
| 1092 | int addrsize, const struct dwarf_sections *dwarf_sections, |
| 1093 | struct dwarf_data *altlink, struct attr_val *val) |
| 1094 | { |
| 1095 | /* Avoid warnings about val.u.FIELD may be used uninitialized if |
| 1096 | this function is inlined. The warnings aren't valid but can |
| 1097 | occur because the different fields are set and used |
| 1098 | conditionally. */ |
| 1099 | memset (val, 0, sizeof *val); |
| 1100 | |
| 1101 | switch (form) |
| 1102 | { |
| 1103 | case DW_FORM_addr: |
| 1104 | val->encoding = ATTR_VAL_ADDRESS; |
| 1105 | val->u.uint = read_address (buf, addrsize); |
| 1106 | return 1; |
| 1107 | case DW_FORM_block2: |
| 1108 | val->encoding = ATTR_VAL_BLOCK; |
| 1109 | return advance (buf, read_uint16 (buf)); |
| 1110 | case DW_FORM_block4: |
| 1111 | val->encoding = ATTR_VAL_BLOCK; |
| 1112 | return advance (buf, read_uint32 (buf)); |
| 1113 | case DW_FORM_data2: |
| 1114 | val->encoding = ATTR_VAL_UINT; |
| 1115 | val->u.uint = read_uint16 (buf); |
| 1116 | return 1; |
| 1117 | case DW_FORM_data4: |
| 1118 | val->encoding = ATTR_VAL_UINT; |
| 1119 | val->u.uint = read_uint32 (buf); |
| 1120 | return 1; |
| 1121 | case DW_FORM_data8: |
| 1122 | val->encoding = ATTR_VAL_UINT; |
| 1123 | val->u.uint = read_uint64 (buf); |
| 1124 | return 1; |
| 1125 | case DW_FORM_data16: |
| 1126 | val->encoding = ATTR_VAL_BLOCK; |
| 1127 | return advance (buf, 16); |
| 1128 | case DW_FORM_string: |
| 1129 | val->encoding = ATTR_VAL_STRING; |
| 1130 | val->u.string = read_string (buf); |
| 1131 | return val->u.string == NULL ? 0 : 1; |
| 1132 | case DW_FORM_block: |
| 1133 | val->encoding = ATTR_VAL_BLOCK; |
| 1134 | return advance (buf, read_uleb128 (buf)); |
| 1135 | case DW_FORM_block1: |
| 1136 | val->encoding = ATTR_VAL_BLOCK; |
| 1137 | return advance (buf, read_byte (buf)); |
| 1138 | case DW_FORM_data1: |
| 1139 | val->encoding = ATTR_VAL_UINT; |
| 1140 | val->u.uint = read_byte (buf); |
| 1141 | return 1; |
| 1142 | case DW_FORM_flag: |
| 1143 | val->encoding = ATTR_VAL_UINT; |
| 1144 | val->u.uint = read_byte (buf); |
| 1145 | return 1; |
| 1146 | case DW_FORM_sdata: |
no test coverage detected