]> git.pld-linux.org Git - packages/gcc.git/commitdiff
- fix unaligned accesses with __attribute__(packed) and memcpy.
authorPaweł Sikora <pluto@pld-linux.org>
Mon, 1 May 2006 11:55:07 +0000 (11:55 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    gcc-pr26565.patch -> 1.1.2.1

gcc-pr26565.patch [new file with mode: 0644]

diff --git a/gcc-pr26565.patch b/gcc-pr26565.patch
new file mode 100644 (file)
index 0000000..c1d0a78
--- /dev/null
@@ -0,0 +1,33 @@
+--- gcc/gcc/builtins.c (revision 113409)
++++ gcc/gcc/builtins.c (revision 113410)
+@@ -275,14 +275,28 @@
+       case ADDR_EXPR:
+         /* See what we are pointing at and look at its alignment.  */
+         exp = TREE_OPERAND (exp, 0);
++        inner = max_align;
++        while (handled_component_p (exp))
++          {
++            /* Fields in a structure can be packed, honour DECL_ALIGN
++               of the FIELD_DECL.  For all other references the conservative 
++               alignment is the element type alignment.  */
++            if (TREE_CODE (exp) == COMPONENT_REF)
++              inner = MIN (inner, DECL_ALIGN (TREE_OPERAND (exp, 1)));
++            else
++              inner = MIN (inner, TYPE_ALIGN (TREE_TYPE (exp)));
++            exp = TREE_OPERAND (exp, 0);
++          }
+         if (TREE_CODE (exp) == FUNCTION_DECL)
+           align = FUNCTION_BOUNDARY;
+         else if (DECL_P (exp))
+-          align = DECL_ALIGN (exp);
++          align = MIN (inner, DECL_ALIGN (exp));
+ #ifdef CONSTANT_ALIGNMENT
+         else if (CONSTANT_CLASS_P (exp))
+-          align = CONSTANT_ALIGNMENT (exp, align);
++          align = MIN (inner, (unsigned)CONSTANT_ALIGNMENT (exp, align));
+ #endif
++        else
++          align = MIN (align, inner);
+         return MIN (align, max_align);
+       default:
This page took 0.067133 seconds and 4 git commands to generate.