[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#414932: linux-image-2.6.18-4-ixp4xx: xfs partition from x86 system can not be used on arm



On Thu, Apr 26, 2007 at 11:34:56PM -0500, Eric Sandeen wrote:

> Root cause seems to be gcc misaligning the xfs shortform directory 
> structures.  In the example below, bar.parent has offset 4, while 
> boo.parent has offset 2.  The union seems to cause extra padding - I 
> believe "c" should be at offset 2 in both structures.
> 
> This is leading to trouble in xfs_dir2_sf_hdr_t and others, and is 
> unfortunately leading to on-disk corruption, I think.  The patch that's 
> been floating around to "fix" this probably only masks the problem, by 
> accommodating the extra padding when calculating sizes.
> 
> #include <stdio.h>
> 
> struct bar {
>         unsigned char   a;
>         unsigned char   b;
>         union {
>                 unsigned char x;
>                 unsigned char y;
>         } c;
> };
> 
> struct boo {
>         unsigned char   a;
>         unsigned char   b;
>         unsigned char   c;
> };
> 
> 
> #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
> 
> int main(int argc, char ** argv) {
> 
>         printf("a: %d\n", offsetof(struct bar, a));
>         printf("b: %d\n", offsetof(struct bar, b));
>         printf("c: %d\n", offsetof(struct bar, c));
> 
>         printf("a: %d\n", offsetof(struct boo, a));
>         printf("b: %d\n", offsetof(struct boo, b));
>         printf("c: %d\n", offsetof(struct boo, c));
> 
>         return 0;
> }
> 
> sandeen@all6500-arm:~$ ./gcc-test
> a: 0
> b: 1
> c: 4
> a: 0
> b: 1
> c: 2

On an EABI ARM system:

$ ./x
a: 0
b: 1
c: 2
a: 0
b: 1
c: 2


> sandeen@all6500-arm:~$ gcc -v
> Using built-in specs.
> Target: arm-linux-gnu
> Configured with: ../src/configure -v 
> --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
> --enable-shared --with-system-zlib --libexecdir=/usr/lib 
> --without-included-gettext --enable-threads=posix --enable-nls 
> --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
> --enable-libstdcxx-debug --enable-mpfr --enable-checking=release 
> arm-linux-gnu
> Thread model: posix
> gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

iop0:~# gcc -v
Using built-in specs.
Target: arm-linux-gnueabi
Configured with: ../src/configure -v
--enable-languages=c,c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-checking=release
arm-linux-gnueabi
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)


> sandeen@all6500-arm:~$ uname -a
> Linux all6500-arm 2.6.18-4-iop32x #1 Thu Feb 22 03:51:25 UTC 2007 
> armv5tel GNU/Linux

iop0:~# uname -a
Linux iop0.wantstofly.org 2.6.20 #9 Thu Mar 29 04:35:38 CEST 2007
armv5tel GNU/Linux



Reply to: