bug-cpio
[Top][All Lists]
Advanced

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

[Bug-cpio] Re: Bug#438155: cpio: FTBFS: testsuite failure on ARM


From: Clint Adams
Subject: [Bug-cpio] Re: Bug#438155: cpio: FTBFS: testsuite failure on ARM
Date: Wed, 15 Aug 2007 22:39:18 -0400
User-agent: Mutt/1.5.16 (2007-06-11)

Problems with cpio on Debian's arm port.

On Wed, Aug 15, 2007 at 05:38:05PM +0200, Aurelien Jarno wrote:
> Versions >= 2.8 of cpio fails to build on ARM due to a testsuite
> failure, but the bug is already present in version 2.7.
> 
> cpio uses structures to map the file header, and the whole structure is
> read at once. This does not work on all architectures (like ARM), as
> they may use padding. The structures should be declared as packed to
> avoid padding.
> 
> You will find a patch below to fix the problem.
> 
> --- cpio-2.9.orig/src/cpiohdr.h
> +++ cpio-2.9/src/cpiohdr.h
> @@ -35,7 +35,7 @@
>    unsigned short c_mtimes[2];
>    unsigned short c_namesize;
>    unsigned short c_filesizes[2];
> -};
> +} __attribute__((packed));
>  
>  struct old_ascii_header
>  {
> @@ -50,7 +50,7 @@
>    char c_mtime[11];
>    char c_namesize[6];
>    char c_filesize[11];
> -};
> +} __attribute__((packed));
>  
>  /* "New" portable format and CRC format:
>  
> @@ -80,7 +80,7 @@
>    char c_namesize[8];  /* count includes terminating NUL in pathname */
>    char c_chksum[8];    /* 0 for "new" portable format; for CRC format
>                         the sum of all the bytes in the file  */
> -};
> +} __attribute__((packed));
>  
>  struct cpio_file_stat /* Internal representation of a CPIO header */
>  {
> 

On Wed, Aug 15, 2007 at 07:31:49PM +0100, Stephen Gran wrote:
> (disclaimer: not related to cpio in any way)
> 
> This patch certainly looks good enough to be a dpatch or whatever system
> is in use, but I just wanted to mention that before pushing this
> upstream, you might want to add tests for how to pack the structures
> depending on compiler capabilities. 
> 
> This is the first example I happened on (clamav, from configure.in)
> 
> dnl check for __attribute__((packed))
> AC_MSG_CHECKING([for structure packing via __attribute__((packed))])
> AC_CACHE_VAL(have_attrib_packed,[
>         AC_TRY_COMPILE(,
>                 [struct { int i __attribute__((packed)); } s; ],
>                 [have_attrib_packed=yes],
>                 [have_attrib_packed=no])
>         ])
> AC_MSG_RESULT($have_attrib_packed)
> 
> if test "$have_attrib_packed" = no; then
>         AC_MSG_CHECKING(for structure packing via pragma)
>         AC_CACHE_VAL(have_pragma_pack,[
>                 AC_TRY_RUN([int main(int argc, char **argv) {
> #pragma pack(1)                 /* has to be in column 1 ! */
>                         struct { char c; long l; } s;
>                         return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
>                         [have_pragma_pack=yes],
>                         [have_pragma_pack=no])
>                 ])
>         AC_MSG_RESULT($have_pragma_pack)
>         if test "$have_pragma_pack" = yes; then
>                 AC_DEFINE(HAVE_PRAGMA_PACK, 1, "pragma pack")
>         else
>                 AC_MSG_CHECKING(for structure packing via hppa/hp-ux pragma)
>                 AC_CACHE_VAL(have_pragma_pack_hpux,[
>                         AC_TRY_RUN([
>                         /* hppa/hp-ux wants pragma outside of function */
> #pragma pack 1 /* has to be in column 1 ! */
>                         struct { char c; long l; } s;
>                             int main(int argc, char **argv) {
>                         return sizeof(s)==sizeof(s.c)+sizeof(s.l) ? 0:1; } ],
>                         [have_pragma_pack_hpux=yes],
>                         [have_pragma_pack_hpux=no])
>                 ])
>                 AC_MSG_RESULT($have_pragma_pack_hpux)
>                 AC_DEFINE(HAVE_PRAGMA_PACK_HPPA, 1, "pragma pack hppa/hp-ux 
> style")
>         fi
> fi
> 
> if test "$have_attrib_packed" = no && test "$have_pragma_pack" = no && test 
> "$have_pragma_pack_hpux" = no; then
>         AC_MSG_ERROR(Need to know how to pack structures with this compiler)
> fi
> 
> if test "$have_attrib_packed" = yes; then
>         AC_DEFINE(HAVE_ATTRIB_PACKED, 1, [attrib packed])
> fi
> 
> And then later test for HAVE_ATTRIB_PACKED, HAVE_PRAGMA_PACK or 
> HAVE_PRAGMA_PACK_HPPA.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]