compiler.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * define start/end address of ro data.
  3. * different compiler with different implementation.
  4. */
  5. #ifndef __COMPILER_H__
  6. #define __COMPILER_H__
  7. #if defined(__CC_ARM) // armcc
  8. #warning "Please check scatter file to ensure rodata is in ER_IROM1 region."
  9. /* symbols reference to the scatter file */
  10. extern char Image$$ER_IROM1$$Base;
  11. extern char Image$$ER_IROM1$$Limit;
  12. #define RODATA_START_ADDRESS (&Image$$ER_IROM1$$Base)
  13. #define RODATA_END_ADDRESS (&Image$$ER_IROM1$$Limit)
  14. #elif defined(__GNUC__) // gcc
  15. #warning "Please check linker script to ensure rodata is between _stext and _etext."
  16. /* symbols defined in linker script */
  17. extern char _stext;
  18. extern char _etext;
  19. #define RODATA_START_ADDRESS (&_stext)
  20. #define RODATA_END_ADDRESS (&_etext)
  21. #else // other compilers
  22. /* Firstly, modify rodata's start/end address. Then, comment the line below */
  23. #error "Please modify RODATA_START_ADDRESS and RODATA_END_ADDRESS below */
  24. /* Perhaps you can use start/end address of flash */
  25. #define RODATA_START_ADDRESS ((char*)0x08000000)
  26. #define RODATA_END_ADDRESS ((char*)0x08080000)
  27. #endif
  28. #endif // __COMPILER_H__