由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - Arm 32-bit alignment question
相关主题
vim text alignment弱问编译器是executable吗?
Partition 1 does not start on physical sector boundary?about compiling new glibc/gcc in fc14
用了很久的硬盘发现alignment有问题... (转载)GIT 问题
Mono Wins Product of the Year Awardhow to copy one file into another?
how to make linux cluster?linux克隆搞不定
Anyone cross compiled SNMP to the ARM ?考验一下大家的浏览器
值得在嵌入式中直接使用gcc吗?问个swap space的问题
请教一个基础C++问题 (转载)今天升级ubuntu 9.10
相关话题的讨论汇总
话题: arm话题: byte话题: access话题: aligned话题: bit
进入Linux版参与讨论
1 (共1页)
w*s
发帖数: 7227
1
Q:
Alignment issue in Arm is like this, correct me if i'm wrong,

if i have
char a[40];
int *b = a;
later on b could cause crash

From web,
For example, on ARM-based systems you cannot address a 32-bit word that
is not aligned to a 4-byte boundary. Doing so will result in an access
violation exception. On x86 you can access such non-aligned data, though the
performance suffers a little since two words have to fetched from memory
instead of just one.
So how to fix this easier, any compile options ?
G*****h
发帖数: 33134
2
compiler should already handle it.
and *(int *)(&a[0]) should be fine
*(int *)(&a[1]) will crash for sure.

that
the

【在 w*s 的大作中提到】
: Q:
: Alignment issue in Arm is like this, correct me if i'm wrong,
:
: if i have
: char a[40];
: int *b = a;
: later on b could cause crash
:
: From web,
: For example, on ARM-based systems you cannot address a 32-bit word that

w*s
发帖数: 7227
3
well, we're porting code from CE to linux,
so we do have the
*(int *)(&a[1])
in CE which works fine, guess CE compiler is better.
any quick solution for us ?

【在 G*****h 的大作中提到】
: compiler should already handle it.
: and *(int *)(&a[0]) should be fine
: *(int *)(&a[1]) will crash for sure.
:
: that
: the

G*****h
发帖数: 33134
4
easy
rewrite the code wherever crashes.
though ARM usually has config register that you can enable byte boundary
access

【在 w*s 的大作中提到】
: well, we're porting code from CE to linux,
: so we do have the
: *(int *)(&a[1])
: in CE which works fine, guess CE compiler is better.
: any quick solution for us ?

w*s
发帖数: 7227
5
rewrite code will take time. i'm looking for some compiler options.

【在 G*****h 的大作中提到】
: easy
: rewrite the code wherever crashes.
: though ARM usually has config register that you can enable byte boundary
: access

G*****h
发帖数: 33134
6
there is CPU option
Compiler cannot stop you using *(int *)(&a[1])

【在 w*s 的大作中提到】
: rewrite code will take time. i'm looking for some compiler options.
w*s
发帖数: 7227
7
curious how winCE made it work, still the same ARM cpu ...

【在 G*****h 的大作中提到】
: there is CPU option
: Compiler cannot stop you using *(int *)(&a[1])

w*s
发帖数: 7227
8
sorry more questions on byte boundary access,
http://www.atmel.com/Images/doc6438.pdf
9.4.4 Memory Access
The ARM9EJ-S core supports byte (8-bit), half-word (16-bit) and word (32-bit
) access. Words
must be aligned to four-byte boundaries, half-words must be aligned to two-
byte boundaries and
bytes can be placed on any byte boundary.
so for the case of (int *)(&array[1]),
it's still treated as int, which must be aligned to four-byte boundaries.
does this conflict to what you are saying on "ARM usually has config
register that you can enable byte boundary access" ?

【在 G*****h 的大作中提到】
: easy
: rewrite the code wherever crashes.
: though ARM usually has config register that you can enable byte boundary
: access

h****d
发帖数: 1305
9
is it the limitation of gcc?

that
the

【在 w*s 的大作中提到】
: Q:
: Alignment issue in Arm is like this, correct me if i'm wrong,
:
: if i have
: char a[40];
: int *b = a;
: later on b could cause crash
:
: From web,
: For example, on ARM-based systems you cannot address a 32-bit word that

1 (共1页)
进入Linux版参与讨论
相关主题
今天升级ubuntu 9.10how to make linux cluster?
C 89的话,怎么方便的把一个文件的行重排Anyone cross compiled SNMP to the ARM ?
急急急!请问如何撤消mv操作?值得在嵌入式中直接使用gcc吗?
ping的问题请教一个基础C++问题 (转载)
vim text alignment弱问编译器是executable吗?
Partition 1 does not start on physical sector boundary?about compiling new glibc/gcc in fc14
用了很久的硬盘发现alignment有问题... (转载)GIT 问题
Mono Wins Product of the Year Awardhow to copy one file into another?
相关话题的讨论汇总
话题: arm话题: byte话题: access话题: aligned话题: bit