globalthreadx

threadx module allocating module data section in run time


I see that when loading threadx module, the data section is allocated in run time from byte pool (at _txm_module_manager_internal_load).

  1. Is there a way to define in advance (in the module preamble or such) the place where the module data will be located?

  2. How dose the module code knows where its globals are located? the compiler can't know their addresses because the place of the data is determined at run time (I suppose somewhere in the assembly porting there is some relative address to the data section that changes for each module that the globals are accessed through it, but I am not so familiar with arm assembly to find it by myself).


Solution

    1. The location of data for each module is determined at run-time. This is to allow loading the same module more than once, each instance having separate data, in different locations.

    2. Globals are located in the data area. The modules are compiled as position independent code and position independent data. While loading the module the module startup code is provided with the load address of the data. The specifics of how this is achieved are different for each architecture and compiler.