[lkml]   [2015]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[RFC PATCH 0/1] Wrong structure alignment due to compiler attribute "section"


I came across a problem concerning structure alignment on ARM architectures (in
this case the "clock_provider" struct) when structures are placed by means of the
"section" compiler attribute. I noticed that with a certain cross compiler one
byte padding is inserted in between the structures:

c074cec0 T __clk_of_table
c074cec0 t __of_table_fixed_factor_clk
c074cec0 T __stop_kprobe_blacklist
c074cf88 t __of_table_fixed_clk
c074d050 t __of_table_gpio_gate_clk
c074d118 t __of_table_mv88f6180_clk
c074d1e0 t __of_table_kirkwood_clk
c074d2a8 t __clk_of_table_sentinel

As one can see the difference between the adresses are 200 bytes although a
clock_provider only is 196 bytes in size.

The problem is that in of_clk_init() the __clk_of_table is used as the base of
an array. Due to the padding the values in all array elements but the first one
are corruped. However with another cross compiler I could not trigger this. So
this issue seems to be compiler/linker dependent. With the attached patch
applied the layout is correct:

c074ce58 T __clk_of_table
c074ce58 t __of_table_fixed_factor_clk
c074ce58 T __stop_kprobe_blacklist
c074cf1c t __of_table_fixed_clk
c074cfe0 t __of_table_gpio_gate_clk
c074d0a4 t __of_table_mv88f6180_clk
c074d168 t __of_table_kirkwood_clk
c074d22c t __clk_of_table_sentinel

I can trigger the issue with this compiler:

Note that this issue popped up some years ago for x86 too:

I am not sure that this is the right fix though, thats why I sent that as an


Lino Sanfilippo (1):
ARM: Ensure correct structure alignment when using compiler attribute

include/linux/compiler.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)


 \ /
  Last update: 2015-03-02 11:41    [W:0.067 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site