I am developing a mutlicore project for embedded architecture using the gnu toolchain. In this architecture, all independent cores have the same global memory space. Each core has its own internal memory, which is addressed from any other core through its global 32-bit address.
There is no OS, and we do low-level programming, but in C instead of assembly. Each core has its own executable file generated with separate compilation. The current method that we use for internuclear communication is the calculation of the absolute addresses of objects in the data space of the target kernel. If we build the same code for all cores, then the objects are located by the linker in the same place, so accessing the object in the remote core simply changes the most significant bits of the address of the object in the current core and makes the transaction. A similar concept allows us to exchange objects located in an external DRAM.
Everything starts to get complicated when:
In two cores, the code does not match, so objects cannot be allocated to the same addresses,
Sometimes we use a “host”, which is another processor that runs some control code that requires access to objects in the kernels, as well as shared objects in external memory.
To overcome this problem, I am looking for an elegant way to place variables during assembly. I would like to avoid modifying the script linker file as much as possible. However, it seemed that at C level, I could only control the placement before using a combination of the section attribute (which is too crude) and the align attribute (which does not guarantee the exact location).
A possible hack is to use the built-in assembly to define objects and place them explicitly (using the .org and .global ), but this seems a little ugly (and we haven't tested this idea yet ...)
So here are the questions:
Is there a semi-standard way or an elegant solution for manually placing objects in C?
Is it possible to declare "uber" -extarnel objects in my code and make the linker resolve its addresses using another executable project?
This question describes a similar situation, but there the user refers to a pre-allocated resource (for example, a peripheral device), whose address is known before the build time.
source share