|
|
|
|
 about arm gnu compiler - front999 [ 2006-07-17 11:59 | 438 byte(s)]
 Re: about arm gnu compiler - front999 [ 2006-07-17 13:18 | 1,282 byte(s)]
 Re: about arm gnu compiler - front999 [ 2006-07-25 16:37 | 41 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
我使用www.codesourcery.com/gnu_toolchains/arm/download.html的交叉编译器编译
iptable1.3.3,发觉ipt_counter因为包含了两个64位的成员,而被交叉编译器扩展到了
64位对齐方式,但是,手头的内核中的ipt_counter却是32位对齐的。
于是,尝试使用-mstructure-size-boundary=32来编译iptable1.3.3,结果没有任何效果。
请问,如何才能使这种数据结构在编译时,强制对齐到32位?
谢谢!
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
刚才看了arm gnu gcc的源代码,
在encoding.c中:
1.
layout->record_align = MAX (layout->record_align, STRUCTURE_SIZE_BOUNDARY);
2.
还找到了这样一段注释:
/* Record must have at least as much alignment as any field.
Otherwise, the alignment of the field within the record
is meaningless. */
我没有深入研究过gcc的代码,但是根据以上两点看来,如果数据结构
含有64位的数据类型如:int64 . 而-mstructure-size-boundary=32,那么
layout->record_align = MAX (layout->record_align, STRUCTURE_SIZE_BOUNDARY);
=>
layout->record_align = MAX (64, 32);
=>
layout->record_align = 64
那么按照注释里的话来说就是,对齐的大小必须至少大于等于任何一个
成员的对齐,否则成员的对齐就是没有意义的。
如果是这样,问题就变成:在内核里是如何保证iptable的ipt_counter按照
32位对齐的。或者是还有没有办法让所有的代码强制的按照32位对齐,让
layout->record_align = MAX (layout->record_align, STRUCTURE_SIZE_BOUNDARY);
不起作用??
谢谢
|
|
|
[Original]
[Print]
[Top]
|
|
|