将变量添加到特定类时,为什么arm-gnu-eabi链接失败?

问题描述

我在带有编译器arm-none-eabi的LPC2378 IC上使用ARM7裸机,并作为版本4_9-2015-q2-update中的构建库下载。

要编译,我使用以下命令:

arm-none-eabi-g++ -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -Wabi -Wctor-dtor-privacy -Wnoexcept -Wnon-virtual-dtor -Wstrict-null-sentinel -Wsign-promo -Weffc++ <my_local_flags> -I<paths_to_includes> -c -o <path_to_o_file> <path_to_cpp_source>

arm-none-eabi-gcc -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -std=gnu11  -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -Wstrict-prototypes -Wbad-function-cast     <my_local_flags> -I<paths_to_includes> -c -o <path_to_o_file> <path_to_c_source>

arm-none-eabi-g++ -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -fdiagnostics-color=auto -std=gnu++11 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -Wabi -Wctor-dtor-privacy -Wnoexcept -Wnon-virtual-dtor -Wstrict-null-sentinel -Wsign-promo -Weffc++ -D<my_local_flags> -x assembler-with-cpp -I<paths_to_includes> -c -o <path_to_o_file> <path_to_assembler_file>

并用于链接:

arm-none-eabi-g++ -mcpu=arm7tdmi-s -march=armv4t -marm -mlittle-endian -mfloat-abi=soft -Os -fmessage-length=0 -ffunction-sections -fdata-sections -Wunused -Wuninitialized -Wextra -Wconversion -Wpointer-arith -Wpadded -Wshadow -Wlogical-op -Wfloat-equal -Wall -T<path_to_linker_script> -Xlinker --gc-sections -Wl,-Map,<path_to_map> -o <path_to_elf_file> <paths_to_o_files>

出什么问题了?也许在示例中:

class X {
  public:
  uint8_t a;
  uint8_t b;
  uint8_t c;

  X(void) : a(0),b(1),c(2) { }
};

这是基本示例,一切正常。但是当我添加额外的变量时,例如:

class X {
  public:
  uint8_t a;
  uint8_t b;
  uint8_t c;
  uint8_t d; // new variable

  X(void) : a(0),c(2),d(3) { }
};

}

链接器失败,并显示以下消息:

〜/ env / gcc-arm-none-eabi / 4_9-2015-q2-update / bin /../ lib / gcc / arm-none-eabi / 4.9.3 /../../ .. /../arm-none-eabi/bin/ld: 区域ROM溢出了68872个字节

当然,您可以说:“请重构您的代码,您的存储空间不足”。但是,从外观上看,这并不容易;)当我将 uint8_t d 的init从初始化列表更改为构造函数的主体时,或者在声明变量时执行了同样的错误。但是,如果没有初始化(将默认值写入变量),则传递链接,并且我可以运行该程序。为了避免有关代码优化的问题:我可以使用此变量。更改此变量的值后,我写了一个虚拟方法,然后它起作用了。

那么您对损坏的东西有任何想法吗?链接描述文件?编译过程?也许这是一个ARM工具链错误?

感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...