On Thursday 23 February 2012 05:17 PM, Ulrich Weigand wrote:
Aneesh V<ane...@ti.com>  wrote on 23.02.2012 11:27:40:

The "packed" attribute specifies that all struct elements ought to be
considered to have alignment requirement 1 instead of their default
alignment.  Thus the whole struct ends up having alignment requirement
1;
and since the section contains only a single variable of such struct
type, this is then also the alignment requirement of the section.


Hmm.. Thanks. Removing packed seems to help. The following also helped.

@@ -34,7 +34,7 @@ struct pad_conf_entry {

      u16 val;

-} __attribute__ ((packed));
+} __attribute__ ((packed)) __attribute__ ((aligned(2)));

BTW, just for my understanding:
The effect of adding __attribute__ ((packed)) to a structure is
equivalent to adding it for each field in the structure, right?

Right.

And because the first field doesn't have any alignment requirement,
the struct also doesn't have any alignment requirement right?

Sort of.  The alignment requirement of the struct is the maximum
(actually, the least common multiple, but since we're talking only
powers of two, that amounts to the same) of the alignment requirements
of all members.  However, attribute packed for a struct applies to
each element separately, and thus each element has alignment
requirement 1, which is then also the maximum.

Understand. Thanks for the explanation.

br,
Aneesh

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to