简体   繁体   English

通过地址从另一个项目的地图文件中调用函数

[英]Function call by address from map file of another project

Hi everyone here is my issue. 大家好,这是我的问题。

I have two distincts projects, first has a linker file mapped as the following: 我有两个不同的项目,第一个有一个链接器文件,映射如下:

MEMORY
{
    rom (rx)  : ORIGIN = 0x08000000, LENGTH = 0x0000C400 
    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

Second a linker file as the following: 其次是一个链接器文件,如下所示:

MEMORY
{
    rom (rx)  : ORIGIN = 0x0800C400, LENGTH = 0x00019CFC 
    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

Both of the projects runs on the same MCU and are burned in flash separatly. 这两个项目都在同一MCU上运行,并分别在Flash中刻录。 In my second project I would like to map pointers on functions declared in the first project. 在第二个项目中,我想将指针映射到第一个项目中声明的函数上。 I tried the code below but it doesn't work, at execution debugger tels me that the symbol could not be found, but according to the .map file of the first project the address (0x0800458C) is mapped on the function I want to use. 我尝试了下面的代码,但是它不起作用,在执行调试器时告诉我找不到该符号,但是根据第一个项目的.map文件,地址(0x0800458C)映射到了我要使用的函数上。

uint32_t (*Myfunction)(void);

int main(void)
{
    Myfunction = ((uint32_t(*) (void)) 0x0800458C); // address in the first project
    Myfunction();
} 

Does anybody have experienced this ? 有人经历过吗? Thanks !! 谢谢 !!

EDIT: It seems to work with Keil IDE when in directly include .symbols file in project. 编辑:在项目中直接包含.symbols文件时,它似乎可以与Keil IDE一起使用。 But with CoIDE (eclipse based) it doesn't work. 但是使用CoIDE(基于日食)无法正常工作。 I'm still trying to figure out this issue. 我仍在尝试找出此问题。

Did you try this: Linker script: insert absolute address of the function to the generated code 您是否尝试过: 链接程序脚本:将函数的绝对地址插入到生成的代码中

I think the last answer might be what your looking for. 我认为最后的答案可能是您要寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM