•On ARM, when compiling for ARMv6 (but not ARMv6-M), ARMv7-A, ARMv7-R, or ARMv7-M,
the new option -munaligned-access is active by default, which for some sources generates
code that accesses memory on unaligned addresses. This requires the kernel of those
systems to enable such accesses (controlled by CP15 register c1, refer to ARM documentation).
Alternatively, or for compatibility with kernels where unaligned accesses are not supported,
all code has to be compiled with -mno-unaligned-access. Upstream Linux kernel releases have
automatically and unconditionally supported unaligned accesses as emitted by GCC due to this
option being active since version 2.6.28.
后来在makefile中强制指定-mno-unaligned-access, 问题一解决。
STD_CCFLAGS+=-mno-unaligned-access
问题二:原因: arm mode call 的指令编译正常。下载到Trace32里面, memory view显示正常。
但是执行到特定指令时,该arm instruction被解释成为 两条 thumb 指令, 从而导致 abort 错误。
后来发现是从thumb mode 调用 arm call 时,不能正确找到对应的 function symbol. 需要显式声明.
GCC 4.7 升级文档中,可能对应如下说明
<pre code_snippet_id="157946" snippet_file_name="blog_20140115_3_8233781"
class="java" name="code">•Link-time optimization (LTO) improvements: ◦Improved scalability and reduced memory usage. Link time optimization of Firefox now requires 3GB of RAM on a 64-bit system, while over 8GB was needed previously. Linking time has been improved, too. The serial stage of linking Firefox has been sped up by about a factor of 10.
◦Reduced size of object files and temporary storage used during linking.
◦Streaming performance (both outbound and inbound) has been improved.
◦ld -r is now supported with LTO.
◦Several bug fixes, especially in symbol table handling and merging.</pre><p></p>
<pre></pre>
<p></p>
<p></p>
<p>具体举例说明如下。</p>
<pre code_snippet_id="157946" snippet_file_name="blog_20140328_4_9178606"
class="cpp" name="code">Here is ASM code (file test.S):
===========================
.syntax unified
.text
.code 32
.global test
.func test
test:
nop
bx lr
.endfunc
Here is C code (file c.c):
============================
void test (void);
int test2 (void)
{
test();
}
Script for compilation
============================
</pre>
<p><br>
编译过程如下</p>
<pre code_snippet_id="157946" snippet_file_name="blog_20140328_5_4750741"
class="cpp" name="code">Script for compilation