LIEF icon indicating copy to clipboard operation
LIEF copied to clipboard

MACHO: Section class inconsistency

Open rammy22 opened this issue 8 years ago • 5 comments

Both load commands and segments have an associated data field with the underlying raw data. Why not expose one for the section, that would have the underlying raw data used to parse the section from?

rammy22 avatar Sep 08 '17 13:09 rammy22

Does sections are mandatory in a MachO File ?

romainthomas avatar Sep 08 '17 13:09 romainthomas

You can have a binary without sections, like the micro_macho has shown. But if you do have sections, I'd like to have access to the raw data of it, without reparsing myself, from the segment raw data.

rammy22 avatar Sep 08 '17 13:09 rammy22

I'm not sure to understand your question

romainthomas avatar Sep 08 '17 13:09 romainthomas

How would you calculate the entropy of a particular section header? I'm asking to add a data field to the MachO.Section class that will hold the underlying raw data of the section.

rammy22 avatar Sep 08 '17 13:09 rammy22

I suggest to not add an attribute since it would be a duplication of the other attributes. Instead we could have a method let's say raw_header that would return the same raw as:

https://github.com/lief-project/LIEF/blob/master/src/MachO/Builder.tcc#L87-L95

romainthomas avatar Sep 08 '17 13:09 romainthomas