serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
720 stars 155 forks source link

Seeing correct endian struct values while debugging #47

Closed BullyWiiPlaza closed 4 years ago

BullyWiiPlaza commented 4 years ago

First of, it's great that this library can handle 32-bit, 64-bit and little/big endian ELFs so seemlessly.

However, in terms of endian support, if the host OS is e.g. little endian and the binary being parsed is big endian, the values loaded into the structs will show up with reversed endians in debuggers which can be confusing. This is of course corrected by the library by flipping the byte order as necessary when calling one of its getters. Maybe it's better to flip every struct member's endian immediately after parsing (if necessary) so that during debugging the correct values can be seen inside the structs as well and the specific getter methods which so far handle the byte order swapping can be replaced with struct accessors instead.

serge1 commented 4 years ago

Hi,

The structures are just a "view" of data resided in section memory. And the section memory is exact to its serialized form. Converting in advance and keeping this data would require additional data layer that I would like to avoid.

The points you are raising. definitely, have the place. But, the these difficulties are on the library implementer (or researcher) and are transparent for the library user.

Best regards, Serge