Looking at DWARFs of bzip2_base I see different offsets between members of a structure type although they are of the same type. Check _IO_FILE structure at the offset 0x9c here. All the way until the 7th member at 0xF0 (_IO_write_end) all members have 12 Byte offset from the previous member, but the 8th member (@ 0xFD) onward the difference in the DIE offset gets 13 Bytes. Can anyone help me understand why? any good text that explains?
1 Answer
The offsets you are quoting are not the offsets of the structure members, but they are offsets of the debug information statements inside the dwarf section. The members itself are all 8 bytes in size. _IO_write_ptr
is at offset 40, _IO_write_end
is at offset 48 and and _IO_buf_base
is at offset 56.
The debug information for _IO_write_end
is bigger than the previous debug information records, because the member _IO_write_end
is declared in line 256 of the source file, and encoding line numbers of 256 or bigger takes more bytes than encoding line numbers zero to 255.
-
Sorry for confusing title. I meant to ask "How is DIE offset calculated for members of struct types?" I forgot to change it. your second paragraph answers my question. When it comes to "DW_AT_data_member_location" attribute of the members, I have another question which I've posted here– SavJun 11, 2020 at 5:09
-
And the answer to the intended question ("How is DIE offset calculated for member of struct types") is "not at all". You do not calculate these offsets, you parse the layout of structure from the first member to the last member. You can't skip single members or "jump" to a specific member easily. Jun 14, 2020 at 22:25