不能强迫函数表到指定的地址与IAR ARM编译器 [英] Can't force function table to specific address with IAR ARM compiler
问题描述
我有像这样定义一个函数表型
I have a function table type defined like so
typedef struct
{
uint16_t majorRevision;
uint16_t minorRevision;
uint8_t (*CommInit)(void *);
uint8_t (*CommDeInit)(void);
uint16_t (*Write)(uint8_t *, uint16_t);
uint16_t (*Read)(uint8_t *, uint16_t);
uint8_t (*Attached)(void);
uint8_t (*ExitApp)(uint8_t);
uint8_t (*Jump)(uint32_t address);
uint16_t (*GetCRC)(uint8_t*, uint32_t);
int (*Encrypt)(uint8_t *, uint32_t);
int (*Decrypt)(uint8_t *, uint32_t);
uint8_t (*Reset)(void);
uint32_t (*GetTickCount)(void);
void (*Sleep)(uint32_t);
uint8_t (*ReadASCIIByte)(void);
uint16_t (*ReadASCIIWord)(void);
uint32_t (*ReadASCIIDWord)(void);
void (*WriteASCIIByte)(uint8_t);
void (*WriteASCIIWord)(uint16_t);
void (*WriteASCIIDWord)(uint32_t);
void (*PutChar)(uint8_t);
uint8_t (*GetChar)(void);
uint8_t (*WaitChar)(uint8_t *, uint32_t);
uint8_t (*IsOpen)(void);
} BootFunctionTable_t;
然后我用default_function_attribute编译来迫使它一个特定的地址和我的特定功能填充声明该类型的变量。
Then I declare a variable of that type using the default_function_attribute pragma to force it to a specific address and fill it with my specific functions.
#pragma default_variable_attributes = @ "boottable"
BootFunctionTable_t bootFunctions =
{
MAJOR_REVISION,
MINOR_REVISION,
BootSerialInit, /* Communication Init */
BootSerialDeInit, /* Communication Deinit */
BootSerialWrite,
BootSerialRead,
BootSerialAttached,
BootExitToApp,
BootJump,
BootGetCRC,
NULL,
NULL,
BootReset,
BootGetTickCount,
BootSleep,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
BootSerialPutChar,
BootSerialGetChar,
NULL
};
#pragma default_variable_attributes =
在主我创建了一个新的指针,它指向的地方,我试图强迫该表的地址
In main I create a new pointer and point it to the address of where I attempted to force this table
BootFunctionTable_t * bootf;
bootf = (BootFunctionTable_t *)0x080000200;
最后,我在连接文件创建栏目
Finally, I create the section in my linker file
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000300;
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF;
define symbol __ICFEDIT_region_CCMRAM_start__ = 0x10000000;
define symbol __ICFEDIT_region_CCMRAM_end__ = 0x1000FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_heap__ = 0x200;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define region CCMRAM_region = mem:[from __ICFEDIT_region_CCMRAM_start__ to __ICFEDIT_region_CCMRAM_end__];
define region BOOTTABLE_region = mem:[from 0x08000200 to 0x080002FF];
initialize by copy {section boottable};
place in BOOTTABLE_region { readonly section boottable};
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };
但我不能连接器放置在bootFunctions请求的地址。有人可以告诉我什么,我做错了什么?我甚至不能得到部分地图文件中显示出来。我能找到这样做的唯一的例子是.intvec部分,但向量表是在汇编文件中。我希望把我的boottable在C文件中。
But I can't the linker to place bootFunctions at the requested address. Can someone please tell me what I am doing wrong? I can't even get the section to show up in the map file. The only example I can find of this is the .intvec section but the vector table is defined in an assembly file. I would like to place my boottable in a C file.
推荐答案
@ user694733是正确的。因为我本来就不是用
@user694733 is correct. Because I wasn't actually using
BootFunctionTable_t bootFunctions
而硬codeD解决连接离开它。我改变了code到
but rather the hardcoded address the linker was leaving it out. I changed the code to
BootFunctionTable_t * bootf;
bootf = &bootFunctions;
和也修好了。
这篇关于不能强迫函数表到指定的地址与IAR ARM编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!