Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14 closed enhancement (fixed)

Change ElfLoader to BinaryFileLoader

Reported by: Nicolas Pouillon Owned by: somebody
Priority: major Component: component1
Keywords: Cc:

Description (last modified by Nicolas Pouillon)

Once upon a time when binary file loading was easy, only ELF was supported and used with the ElfLoader module.

This evolved.

Some want (and implemented) COFF support, which means we now have a CoffLoader module, and I know some asked for raw binary support. I assume there wont be long before a.out, MachO, intel hex or <insert your prefed blob here> support is asked for too.

In a C++ world, the most straightforward way to implement a loader for anything would be to have a Loader abstract class, and implement classes inheriting the loading functionnality. But as I think we will sooner or later need support for loading more than one binary file in a platform (like one for a DSP and one for a GP-CPU), this may be a problem.

So here is my proposal for an evolving API:

  • Have a loader class, containing the loadable sections and indexing symbols.
  • Have different pluggables loaders which are tried one after another when a file is opened.
  • If a loader manages to load a file, it must add its sections and symbols to the BinaryFileLoader object.

That means a BinaryFileLoader doesn't directly parse files, but uses registered handlers for this task. This way, API is always stable, new file types can be added transparently.

This change could be done transparently, just making the internals of ElfLoader change. Unfortunately, the module name itself, "ElfLoader", will become misleading.

It would be more accurate to have a "BinaryFileLoader", with "BinaryFileSection" and "BinaryFileSymbol" inside it.

I propose the following approach

  • Add-in new modules
  • "typedef BinaryFileLoader ElfLoader" so that current code does not directly break, but mark it deprecated
  • remove ElfLoader quickly (1 week)

In topcells and platform_desc, and DSX usage, all that needs to be changed is the following sed:


and add a Uses('common:loader'), (or any other support module needed)

Attachments (2)

binary_file_loader.diff (49.9 KB) - added by Nicolas Pouillon 14 years ago.
Patch to modules and lib
binary_file_loader_platform.diff (62.8 KB) - added by Nicolas Pouillon 14 years ago.
Associated platform patch

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by Nicolas Pouillon

Attachment: binary_file_loader.diff added

Patch to modules and lib

Changed 14 years ago by Nicolas Pouillon

Associated platform patch

comment:1 Changed 14 years ago by Nicolas Pouillon

Description: modified (diff)

comment:2 Changed 14 years ago by Nicolas Pouillon

Resolution: fixed
Status: newclosed

Done in [835]

comment:3 Changed 14 years ago by Nicolas Pouillon

Description: modified (diff)
Note: See TracTickets for help on using tickets.