lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 6 Dec 2006 16:04:22 +0100
From:	"Jan Blunck" <jblunck@...e.de>
To:	"Phil Endecott" <phil_arcwk_endecott@...zphil.org>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: Subtleties of __attribute__((packed))

On 12/6/06, Phil Endecott <phil_arcwk_endecott@...zphil.org> wrote:
> Dear All,
>
> I used to think that this:
>
> struct foo {
>    int a  __attribute__((packed));
>    char b __attribute__((packed));
>    ... more fields, all packed ...
> };
>
> was exactly the same as this:
>
> struct foo {
>    int a;
>    char b;
>    ... more fields ...
> } __attribute__((packed));
>
> but it is not, in a subtle way.
>

The same code is generated. The difference is that usually packing the
whole struct isn't as error-prone as packing every element. Besides
that the gcc warns about packing objects that have an alignment of 1.
This is the reason why we should use the second approach.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ