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