Как разместить функцию по определенному адресу в C без использования #pragma?C++

Программы на C++. Форум разработчиков
Гость
Как разместить функцию по определенному адресу в C без использования #pragma?

Сообщение Гость »


I want to place a function

Код: Выделить всё

void loadableSW (void)
at a specific location:

Код: Выделить всё

0x3FF802
. In another function

Код: Выделить всё

residentMain()
I will jump to this location using pointer to function. How to declare function

Код: Выделить всё

loadableSW
to accomplish this. I have attached the skeleton of

Код: Выделить всё

residentMain
for clarity.

Update: Target hardware is TMS320C620xDSP. Since this is an aerospace project, deterministic behaviour is a desirable design objective. Ideally, they would like to know what portion of memory contains what at a particular time. The solution as I just got to know is to define a section in memory in the linker file. The section shall start at

Код: Выделить всё

0x3FF802
(Location where to place the function). Since the size of the

Код: Выделить всё

loadableSW
function is known, the size of the memory section can also be determined. And then the directive

Код: Выделить всё

#pragma CODESECTION ("function_name", "section_name")
can place that function in the specified section.

Since directives are not permissible in test scripts, I am wondering if there is any other way to do this without using any linker directives.

Besides I am curious. Is there any placement syntax for functions in C++? I know there is one for objects, but functions?

Код: Выделить всё

    void residentMain (void)     {         void (*loadable_p) (void) = (void (*) (void)) 0x3FF802;         int hardwareOK = 0;              /*Code to check hardware integrity. hardwareOK = 1 if success*/              if (hardwareOK)         {             loadable_p (); /*Jump to Loadable Software*/         }         else         {             dspHalt ();         }     } 


Источник: https://stackoverflow.com/questions/197 ... ing-pragma

Вернуться в «C++»