Browse Source

Fix reading of >1 byte data in .debug_info

master
aolo2 3 years ago
parent
commit
26d9799be5
  1. 17
      dwarf.c

17
dwarf.c

@ -187,7 +187,8 @@ find_subroutine_offset(u8 *file, u64 header_size, u8 address_size,
switch (form) { switch (form) {
case DW_FORM_sec_offset: case DW_FORM_sec_offset:
case DW_FORM_strp: { case DW_FORM_strp: {
u32 data = file[data_offset]; u32 data;
memcpy(&data, file + data_offset, 4);
data_offset += 4; // 8 bytes for x64 DWARF! data_offset += 4; // 8 bytes for x64 DWARF!
if (form == DW_FORM_strp) { if (form == DW_FORM_strp) {
@ -232,7 +233,8 @@ find_subroutine_offset(u8 *file, u64 header_size, u8 address_size,
} }
case DW_FORM_ref4: { case DW_FORM_ref4: {
u32 data = file[data_offset]; u32 data;
memcpy(&data, file + data_offset, 4);
data_offset += 4; data_offset += 4;
//printf("%#x\n", data); //printf("%#x\n", data);
u32 referenced_data = file[original_data_offset - header_size + data]; u32 referenced_data = file[original_data_offset - header_size + data];
@ -262,21 +264,24 @@ find_subroutine_offset(u8 *file, u64 header_size, u8 address_size,
}; };
case DW_FORM_data2: { case DW_FORM_data2: {
u16 data = file[data_offset]; u16 data;
memcpy(&data, file + data_offset, 2);
data_offset += 2; data_offset += 2;
//printf("%#x\n", data); //printf("%#x\n", data);
break; break;
}; };
case DW_FORM_data4: { case DW_FORM_data4: {
u32 data = file[data_offset]; u32 data;
memcpy(&data, file + data_offset, 4);
data_offset += 4; data_offset += 4;
//printf("%#x\n", data); //printf("%#x\n", data);
break; break;
}; };
case DW_FORM_data8: { case DW_FORM_data8: {
u64 data = file[data_offset]; u64 data;
memcpy(&data, file + data_offset, 8);
data_offset += 8; data_offset += 8;
//printf("%#lx\n", data); //printf("%#lx\n", data);
break; break;
@ -284,7 +289,7 @@ find_subroutine_offset(u8 *file, u64 header_size, u8 address_size,
default: { default: {
if (form) { if (form) {
//printf("unknown attribute form %d\n", form); printf("unknown attribute form %d\n", form);
} }
} }
} }

Loading…
Cancel
Save