compiler.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 _rodata_start;
  18. // extern char _rodata_end;
  19. extern char _irom0_text_start;
  20. extern char _irom0_text_end;
  21. // modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
  22. // #define RODATA_START_ADDRESS (&_rodata_start)
  23. // #define RODATA_END_ADDRESS (&_rodata_end)
  24. #define RODATA_START_ADDRESS (&_irom0_text_start)
  25. #define RODATA_END_ADDRESS (&_irom0_text_end)
  26. #else // other compilers
  27. /* Firstly, modify rodata's start/end address. Then, comment the line below */
  28. #error "Please modify RODATA_START_ADDRESS and RODATA_END_ADDRESS below."
  29. /* Perhaps you can use start/end address of flash */
  30. #define RODATA_START_ADDRESS ((char*)0x40200000)
  31. #define RODATA_END_ADDRESS ((char*)0x40280000)
  32. #endif
  33. #endif // __COMPILER_H__