Hi Thomas,
OK, the problem is caused by that the names of region related symbols that IRA compiler generate are different with those of ARMCLANG. The work around below do can solve the problem.
BTW the work around seems not to be a general one. I think another way to solve the problem is adding a macro like SYMBOL_NAME_BASE(region) which is a wrapper of the REGION_NAME on different compilers.
Regards,
Sherry Zhang
From: Thomas Törnblom <thomas.tornblom@iar.com>
Sent: Tuesday, April 28, 2020 6:28 PM
To: Sherry Zhang <Sherry.Zhang2@arm.com>; TF-M <tf-m-bounces@lists.trustedfirmware.org>
Cc: nd <nd@arm.com>
Subject: Re: [TF-M] REGION_DECLARE macros
Hi Sherry,
Yes, I noticed that this change had been integrated and that this symbol was being used.
I ran into a lot of these during the IAR port and as I said they don't work with the IAR linker.
I work around this in CommonConfig.cmake by this define:
---
embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS ${COMMON_COMPILE_FLAGS} "-DImage$$= " "-DLoad$$LR$$= " "-D$$ZI$$Base=$$Base" "-D$$ZI$$Limit=$$Limit" "-D$$RO$$Base=$$Base" "-D$$RO$$Limit=$$Limit" "-D$$RW$$Base=$$Base" "-D$$RW$$Limit=$$Limit"
"-D_DATA$$RW$$Base=_DATA$$Base" "-D_DATA$$RW$$Limit=_DATA$$Limit" "-D_DATA$$ZI$$Base=_DATA$$Base" "-D_DATA$$ZI$$Limit=_DATA$$Limit" "-D_STACK$$ZI$$Base=_STACK$$Base" "-D_STACK$$ZI$$Limit=_STACK$$Limit"
---
i.e. I replace $$ZI$$Base with $$Base, Image$$ and Load$$LR are removed entirely, and so on.
To make this work I need to split the symbol up into its components, which is done with the REGION macros.
So the symbol "Image$$ARM_LIB_STACK_MSP$$ZI$$Base" turns into "ARM_LIB_STACK_MSP$$Base", which is what we use for IAR. For ARMCLANG and GNUARM the macros generate the original symbol.
Cheers,
Thomas
Den 2020-04-28 kl. 12:03, skrev Sherry Zhang:
Hi Thomas,
The diff below is caused by this patch https://review.trustedfirmware.org/c/trusted-firmware-m/+/3942 .
REGION_NAME is used to pasting the input parameters into a string. So there should be no difference between Image$$ARM_LIB_STACK_MSP$$ZI$$Base and REGION_NAME(Image$$, ARM_LIB_STACK_MSP, $$ZI$$Base) basing on the current implementation of REGION_NAME in file platform/include/region.h
So, is there a specific REGION_NAME macro implementation for IAR compiler? Or the automatically generated region related symbols are with different names in IAR compiler?
Regards,
Sherry Zhang
From: TF-M <tf-m-bounces@lists.trustedfirmware.org> On Behalf Of Thomas Törnblom via TF-M
Sent: Tuesday, April 28, 2020 4:58 PM
To: tf-m@lists.trustedfirmware.org
Subject: Re: [TF-M] REGION_DECLARE macros
I have no idea what causes the crap characters in the diff below, they should be blanks. Looks like a problem with the mailing list software.
Trying another type:/* Set Main Stack Pointer limit */- extern uint32_t Image$$ARM_LIB_STACK_MSP$$ZI$$Base;- __set_MSPLIM((uint32_t)&Image$$ARM_LIB_STACK_MSP$$ZI$$Base);+ REGION_DECLARE(Image$$, ARM_LIB_STACK_MSP, $$ZI$$Base);+ __set_MSPLIM((uint32_t)®ION_NAME(Image$$, ARM_LIB_STACK_MSP,+ $$ZI$$Base));
Den 2020-04-28 kl. 10:51, skrev Thomas T�rnblom via TF-M:
With the integration of the IAR toolchain support in TF-M it has become important to use the REGION_DECLARE/REGION_NAME macros in platform/region.h instead of using symbols like "Image$$ARM_LIB_STACK_MSP$$ZI$$Base".
The IAR linker can not use these symbols and the macros in combination with the IAR specific cmake rules creates appropriate symbols for all the supported toolchains.
Example diff:
---
���� /* Set Main Stack Pointer limit */
-��� extern uint32_t Image$$ARM_LIB_STACK_MSP$$ZI$$Base;
-��� __set_MSPLIM((uint32_t)&Image$$ARM_LIB_STACK_MSP$$ZI$$Base);
+��� REGION_DECLARE(Image$$, ARM_LIB_STACK_MSP,� $$ZI$$Base);
+��� __set_MSPLIM((uint32_t)®ION_NAME(Image$$, ARM_LIB_STACK_MSP,
+��������������������������������������� $$ZI$$Base));
---
Thomas--
Thomas T�rnblom, Product Engineer
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
Mobile: +46 76 180 17 80 Fax: +46 18 16 78 01
E-mail: thomas.tornblom@iar.com Website: www.iar.com
Twitter: www.twitter.com/iarsystems
--
Thomas T�rnblom, Product Engineer
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
Mobile: +46 76 180 17 80 Fax: +46 18 16 78 01
E-mail: thomas.tornblom@iar.com Website: www.iar.com
Twitter: www.twitter.com/iarsystems
--
Thomas Törnblom,
Product Engineer
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
Mobile: +46 76 180 17 80 Fax: +46 18 16 78 01
E-mail: thomas.tornblom@iar.com Website:
www.iar.com
Twitter: www.twitter.com/iarsystems