Skip to main content
Home
Diablo

Main navigation

  • Home
  • Download
  • Manual
  • Links
  • FAQ
  • Publications
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Diablo manual
  3. How To ...

... link in an additional object file

By admin, 27 April, 2018

You can link in an additional object file through the function.

LinkObjectFileNew(t_object * obj, t_string object_filename, t_string symbol_prefix, t_bool read_debug);

This function can be called after LinkEmulate. The functions from object_filename are then known as symbol_prefix concatenated with the name of the function in the objectfile.

To prevent the newly added functions from being removed by unreachable code elimination, they should be passed in force_reachable to

ObjectFlowgraph (t_object * obj, t_string * force_leader, t_string * force_reachable)

If you want the newly added functions to use a function from the original program, you need to create an alias the name of that function. For example, if the additional object file calls printf, but does not define it, it can use the printf function of the original program by:

  t_symbol * sym = SymbolTableGetSymbolByName (OBJECT_SUB_SYMBOL_TABLE(obj), "printf");
  SymbolTableAddSymbolToSubSection(OBJECT_SUB_SYMBOL_TABLE(obj), SYMBOL_TYPE(sym), SYMBOL_BASE(sym),
    AddressAdd(SYMBOL_OFFSET_FROM_START(sym),SECTION_CADDRESS(SYMBOL_BASE(sym))), 
    StringConcat2(symbol_prefix,"printf"), SYMBOL_LOCAL(sym));

Book traversal links for ... link in an additional object file

  • ... create a new section
  • Up
  • The stack machine for relocations

Book navigation

  • Coding style
  • Installation
  • Input files
  • Invocation
  • Infrastructure and support API
  • High-level overview of Diablo data types
  • How To ...
    • ... create a new section
    • ... link in an additional object file
    • The stack machine for relocations
  • Submitting patches
  • PLDI tutorial slides
  • Miscellaneous slides
RSS feed
Powered by Drupal