add support of arm standard c library, support using armcc to compile lua

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2429 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
xiongyihui3@gmail.com
2012-11-22 03:39:22 +00:00
parent 3968445d4a
commit 74bf69110e
7 changed files with 238 additions and 12 deletions
+6 -5
View File
@@ -2,7 +2,7 @@
## 简介
RT-Thread中的Lua修改自[eLua](http://www.eluaproject.net/)的Lua-5.1.4版本。
采用gcc工具链时,Lua依赖于newlib库,其它工具链暂时还不支持
采用gcc工具链时,Lua依赖于newlib库,采用keil时,Lua依赖于arm的标准c库
启动lua的RAM占用情况
- 标准的lua 17.1904296875 KB
- 优化的lua 5.01953125 KB
@@ -24,11 +24,12 @@ RT-Thread中的Lua修改自[eLua](http://www.eluaproject.net/)的Lua-5.1.4版本
3.更多的配置项可以在luaconf.h中找到
## 开发相关
- 采用gcc工具链时,依赖于newlib,需在rtconfig.h中定义RT_USING_NEWLIB
- 采用gcc工具链时,依赖于newlib,需在rtconfig.h中定义RT_USING_NEWLIB
采用keil工具链时,依赖于arm的标准c库,需在rtconfig.h中定义RT_USING_ARM_LIBC
- 开启编译器对C99的支持,如MDK中,在C/C++选项的Misc Controls输入框中添加--c99
- 需要在链接脚本中定义_stext和_etext.ordata*放在两者之间。
用于判断数据是read-only和writable。MDK中如何实现??
- 添加新的模块,参见lexample.c
- 使用gcc时,需要在链接脚本中定义_stext和_etext.ordata*放在两者之间。用于判断数据是read-only和writable
使用keil时,需要在分散加载文件中把rodata放在ER_IROM1区
- 添加新的模块,参见exlibs/lexamplelib.c
## 目录说明
- lua:从eLua获得Lua-5.1.4版本代码
+43
View File
@@ -0,0 +1,43 @@
/**
* define start/end address of ro data.
* different compiler with different implementation.
*/
#ifndef __COMPILER_H__
#define __COMPILER_H__
#if defined(__CC_ARM) // armcc
#warning "Please check scatter file to ensure rodata is in ER_IROM1 region."
/* symbols reference to the scatter file */
extern char Image$$ER_IROM1$$Base;
extern char Image$$ER_IROM1$$Limit;
#define RODATA_START_ADDRESS (&Image$$ER_IROM1$$Base)
#define RODATA_END_ADDRESS (&Image$$ER_IROM1$$Limit)
#elif defined(__GNUC__) // gcc
#warning "Please check linker script to ensure rodata is between _stext and _etext."
/* symbols defined in linker script */
extern char _stext;
extern char _etext;
#define RODATA_START_ADDRESS (&_stext)
#define RODATA_END_ADDRESS (&_etext)
#else // other compilers
/* Firstly, modify rodata's start/end address. Then, comment the line below */
#error "Please modify RODATA_START_ADDRESS and RODATA_END_ADDRESS below */
/* Perhaps you can use start/end address of flash */
#define RODATA_START_ADDRESS ((char*)0x08000000)
#define RODATA_END_ADDRESS ((char*)0x08080000)
#endif
#endif // __COMPILER_H__
+4 -3
View File
@@ -126,9 +126,10 @@ void luaR_getcstr(char *dest, const TString *src, size_t maxsize) {
/* Return 1 if the given pointer is a rotable */
#ifdef LUA_META_ROTABLES
extern char _stext;
extern char _etext;
#include "compiler.h"
int luaR_isrotable(void *p) {
return &_stext <= ( char* )p && ( char* )p <= &_etext;
return RODATA_START_ADDRESS <= (char*)p && (char*)p <= RODATA_END_ADDRESS;
}
#endif
+4 -4
View File
@@ -100,14 +100,14 @@ static TString *luaS_newlstr_helper (lua_State *L, const char *str, size_t l, in
return newlstr(L, str, l, h, readonly); /* not found */
}
extern char _stext;
extern char _etext;
static int lua_is_ptr_in_ro_area(const char *p) {
#ifdef LUA_CROSS_COMPILER
return 0;
#else
return p >= &_stext && p <= &_etext;
#include "compiler.h"
return p >= RODATA_START_ADDRESS && p <= RODATA_END_ADDRESS;
#endif
}