Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadable modules: add support for loading modules on Xtensa #62433

Merged
merged 17 commits into from
Dec 1, 2023

Commits on Nov 21, 2023

  1. llext: add support for shared objects

    Add support for linking PIC shared object, which only require
    linking, using their PLT and GOT lists and don't need any relocation
    otherwise.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    9061fd5 View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2023

  1. llext: xtensa: add support for local symbol relocations

    Add support for relocating local symbols, as specified in the
    .rela.dyn section.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    ef49e2d View commit details
    Browse the repository at this point in the history
  2. llext: add a function for finding ELF sections

    Applications can use custom ELF sections for their own purposes, add
    a function for finding them.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    78b1b3c View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2023

  1. llext: export some symbols

    Export some symbols for loadable modules. Also add an
    EXPORT_SYSCALL() helper macro for exporting system calls by their
    official names.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    b45d544 View commit details
    Browse the repository at this point in the history
  2. llext: make local relocations optional

    Some applications can decide to link their loadable objects for
    exactly the same addresses, where they will be loaded. In those cases
    local relocations aren't needed any more and can in fact break the
    object if applied while the object is in a temporary storage. Add a
    parameter to skip such local relocations.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    0376bb0 View commit details
    Browse the repository at this point in the history
  3. llext: make buffer access functions accessible externally

    llext_seek(), llext_read() and llext_peek() are needed outside of the
    extension code too, move them to a header.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    babc051 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2023

  1. llext: add Xtensa test support

    Add support for running a modular "Hello world" example on Xtensa.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    1befc75 View commit details
    Browse the repository at this point in the history
  2. llext: add support for global functions

    Loadable modules can contain global (not "static") functions, even if
    they aren't exported for use by other modules, e.g. when a module is
    built from multiple .c files. Such functions are then also included
    in link tables and have to be re-linked.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    6285e1f View commit details
    Browse the repository at this point in the history
  3. llext: add reference counting

    Extend the llext_load() / llext_unload() API to let it be called
    repeatedly for the same extension to increment or decrement its
    reference counter respectively. We use a mutex to protect the counter
    and make both llext_load() and llext_unload() return the use-count to
    let the caller identify when the first loading and the last unloading
    took place.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    3cfc799 View commit details
    Browse the repository at this point in the history
  4. llext: fix a memory leak in an error case

    If a function fails it should release all the resources it has
    managed to acquire. Fix llext_load() to free memory that it has
    allocated in case of an error.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    58a5381 View commit details
    Browse the repository at this point in the history
  5. llext: add support for exporting symbols from extensions

    Extensions should be able to selectively export their global symbols.
    Add a LL_EXTENSION_SYMBOL() macro for that. Change the present
    .sym_tab to be a temporary symbol table of all global symbols in an
    extensions, used only during linking for internal purposes. Add a new
    .exp_tab symbol table to store symbols, exported by an extension
    permanently.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    4db0bad View commit details
    Browse the repository at this point in the history
  6. llext: clarify section map allocation size

    Use an element size explicitly when calculating the array size and
    use the calculated size for memset().
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    9e3d184 View commit details
    Browse the repository at this point in the history
  7. llext: remove llext list scanning from shell.c

    The llext list should be internal to llext.c, remove its scanning
    from shell.c, export a function for that instead.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    3bb8c9c View commit details
    Browse the repository at this point in the history
  8. llext: remove llext_list()

    llext_list() is an exported function that returns a pointer to the
    llext internal extension list. That list should only be accessible
    directly inside llext, while holding a lock. Remove the function.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    71e36d6 View commit details
    Browse the repository at this point in the history
  9. llext: remove redundant initialisation

    a new llext object is completely initialised with zeros after
    allocation, no need to additionally set members of an embedded into
    it array to NULL.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    03b03a8 View commit details
    Browse the repository at this point in the history
  10. llext: protect the global llext list

    Use an existing mutex to also protect the global llext list.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    b75a618 View commit details
    Browse the repository at this point in the history
  11. llext: fix read-only extension image

    When using the LLEXT buffer loader we now avoid copying extensions
    from storage to allocated memory by pointing directly into the stored
    image. We then also perform linking and relocation in that memory,
    which modifies its contents. However, this is impossible if that
    storage is read-only. Add a Kconfig flag to distinguish between
    writable and read-only storage types. Also use that flag to decide,
    whether the extension image in test_llext_simple.c should be defined
    as const or not.
    
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    lyakh committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    1c56b9d View commit details
    Browse the repository at this point in the history