mjhouse / deaf

A library for inspecting/modifying ELF binaries
GNU General Public License v3.0
7 stars 0 forks source link

Investigate propagating changes as they are made #39

Closed mjhouse closed 1 year ago

mjhouse commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, sections can be changed in ways that will break the binary. For example, if a new string is inserted into the section header string table (.shstrtable), then offsets for section names that reference later strings will be invalid.

Describe the solution you'd like There should be a minimum of boilerplate necessary to apply updates that are necessary due to changes in sections, symbols etc. (one function call to apply changes, ideally), and the updates themselves should be discrete and minimal- no massive for-loops with hard-coded checks. Complicating this, I'd also like to avoid every component, symbol, and section carrying around a boxed mutable reference to the binary.

Currently, I'm thinking-

I'm not sure where the logic to apply the changes should live- in the previous example, we insert a string into the section header string table, which generates a Change object, which is captured by the binary, then passed to all components to apply. Should the components all have a method to accept change objects? Should "ChangeAppliers" be defined that accept both a component and a change object? Should the binary handle this?

There are going to be hundreds of changes that will be applied to different components, it makes sense that they should be outside of the sections/symbols etc.

mjhouse commented 1 year ago

Resolved by #40.

In the final design, the update queue stores a collection of lambdas that target a particular struct like Section or FileHeader. Binary updates by calling update on each section, sections update section headers etc. Probably need to also update Table/TableMut references.