mjhouse / deaf

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

Investigate combining table structs #16

Closed mjhouse closed 1 year ago

mjhouse commented 1 year ago

String, Relocation, and Symbol tables are very similar, if not identical. I could probably combine them into a single generic struct that works with either Strings, Relocations, or Symbols.

Option 1

  1. Create TableItem trait that has read/write/size methods
  2. Implement TableItem for String, Relocation and Symbol
  3. Create a Table<T: TableItem> struct that has read/write/size methods
  4. Implement TryFrom<SectionHeader> and TryFrom<&SectionHeader> for Table

Notes

Option 2

  1. Create TableItem trait that has read/write/size methods
  2. Implement TableItem for String, Relocation and Symbol
  3. Create a TableBuffer struct
  4. Use it internally in all of the existing Table structs

Notes

This simplifies the code similarly to Option 1, but avoids a bunch of messy generic boilerplate in the TryFrom impls and doesn't force us to map ByteIter creation to TableItem instances.

mjhouse commented 1 year ago

Working on this issue in branch combine_table_structs

mjhouse commented 1 year ago

Resolved in 1a86509bd41b0350150ba14e6b870955eae46d29