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

Script to relocate code/data/bss sections to different memory types. #10892

Merged
merged 14 commits into from
Dec 7, 2018

Commits on Dec 5, 2018

  1. scripts: gen_relocate_app.py: Script for relocating files in memory.

    This script will relocate .text .data and .bss sections from
    required files and places it in the required memory region. This
    memory region and file are given to this python script in the form
    of a string. Refer to the script for the format of this string and
    the procedure to invoke it.
    
    The main goal of this script is to provide a robust way to re-order
    the memory contents without actually having to modify the code
    (C source code and the linker code).
    In simple terms this script will do the job of
    __attribute__((section("name"))) for a bunch of files together.
    
    Signed-off-by: Varun Sharma <[email protected]>
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    8907960 View commit details
    Browse the repository at this point in the history
  2. cmake: Added rule and helper functions for code relocation.

    This patch creates a rule in the cmake to trigger the generation
    of linker_relocate.ld and code_relocation.c files.
    The linker_relocate.ld will create appropriate sections and will
    link the required functions or variables from all the selected
    files.
    The code_relocation.c will have code that is needed for
    initializing data sections and copy of text sections(if XIP).
    Also this will contain code that is needed for zeroing of bss.
    
    The procedure to invoke this feature is:
    1. Enable CONFIG_CODE_RELOCATION in the prj.conf
    
    2. Inside CMakeList.txt in the project we need to mention
       all the files that needs to get relocated.
    
       zephyr_kernel_code_relocate(src/*.c SRAM2)
    
       Where the first argument is the file/files and the second
       argument is the memory where it has be placed.
       NOTE: The file argument supports glob expressions.
    
    NOTE: Step 2 can be done as many times as required. And relative
    paths can be given here.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    be46803 View commit details
    Browse the repository at this point in the history
  3. kernel: init.c: Added required hooks for the relocation

    This patch splits the text section into 2 parts. The first section
    will have some info regarding vector tables and debug info. The
    second section will have the complete text section.
    This is needed to force the required functions and data variables
    the correct locations.
    This is due to the behavior of the linker. The linker will only link
    once and hence this text section had to be split to make room
    for the generated linker script.
    
    Added a new Kconfig CODE_DATA_RELOCATION which when enabled will
    invoke the script, which does the required relocation.
    
    Added hooks inside init.c for bss zeroing and data copy operations.
    Needed when we have to copy data from ROM to required memory type.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    73fb55a View commit details
    Browse the repository at this point in the history
  4. arch: Kconfig: Increased the text area for kobject and priv stack

    When code relocation feature with userspace mode is turned on we
    need a bit more memory to fit the text section for these 2
    generated files.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    a8626f4 View commit details
    Browse the repository at this point in the history
  5. samples: code_relocation: An example for code relocation feature.

    This sample provides an example for using the code relocation
    feature. This example will place text,data,bss from 3 files to
    various parts in the SRAM. For this a custom linker file is used
    which is derived from include/arch/arm/cortex_m/scripts/linker.ld.
    
    Signed-off-by: Varun Sharma <[email protected]>
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    229b96b View commit details
    Browse the repository at this point in the history
  6. doc: code_data_relocation: Details about code data relocation feature

    Added basic working details of code/data/bss relocation feature,
    how to use with examples & code sample details
    
    Signed-off-by: Varun Sharma <[email protected]>
    varun-sha authored and AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    aa00b35 View commit details
    Browse the repository at this point in the history
  7. tests: benchmarks: timing_info: Remove common variables

    This patch ensures that there are no .common variables in the
    test case.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    c3c69fe View commit details
    Browse the repository at this point in the history
  8. drivers: ipm: ipm_quark_se: Remove object declaration from header

    The header ipm_quark_se.h was creating a object. Hence removed it
    and placed the same in ipm_quark_se.c
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    6890855 View commit details
    Browse the repository at this point in the history
  9. include: drivers: pci: pci_mgr.h: Create a typdef instead of obj.

    This header was creating an object instead of a typdef. Fixed the
    bug.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    046f387 View commit details
    Browse the repository at this point in the history
  10. include: stats.h: Packed attribute was incorrect.

    This header was actually creating a struct in the bss. Fixed it.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    03ca77f View commit details
    Browse the repository at this point in the history
  11. soc: ti_simplelink: cc32xx: soc.h: Incorrect enum definition.

    Instead of creating an typedef enum it was creating an object.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    ba73813 View commit details
    Browse the repository at this point in the history
  12. tests: subsys: fs: Fixed headers which were creating objects.

    These tests were creating objects from header file in the bss.
    Fixed it by moving the objects to appropriate object files.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    15501a3 View commit details
    Browse the repository at this point in the history
  13. samples: rpl_border_router: Fixed headers files.

    This sample was creating objects from header file in the bss.
    Fixed it by moving the objects to appropriate object files.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    fd8f82b View commit details
    Browse the repository at this point in the history
  14. CMakeLists.txt: Enable -fno-common globally.

    This is needed to force the .common type to .bss type.
    This will force the .common variables to go into bss section
    in the compiled object file.
    As of now the movement to the .bss section was happening only
    during the final linking stage.
    
    The -fno-common option specifies that the compiler should place
    uninitialized global variables in the data section of the object
    file, rather than generating them as common blocks.  This has the
    effect that if the same variable is declared (without "extern")
    in two different compilations, you will get a multiple-definition
    error when you link them.
    
    e.g:
    // file a.c
    // file-scope
    
    int b;
    
    // file b.c
    // file-scope
    
    int b;
    
    If there exist two non-extern declarations of the same variable
    then no-common will cause a linker error.
    This sequence would have compiled before, but will now cause a
    linker error.
    
    Signed-off-by: Adithya Baglody <[email protected]>
    AdithyaBaglody committed Dec 5, 2018
    Configuration menu
    Copy the full SHA
    ff312b3 View commit details
    Browse the repository at this point in the history