mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 06:33:34 +08:00
Linux: GCC static data is 16byte aligned, messes up param
GCC 4.8 and higher implement 16 byte static data alignment on 64-bit. This means that the 24-byte param_info_s variables are 16 byte aligned by GCC and that messes up the assumption that the address of the second parameter is at ¶m[0]+sizeof(param[0]). When compiled with clang it is true, with gcc is is not true. See https://llvm.org/bugs/show_bug.cgi?format=multiple&id=18006 The fix is needed for GCC >=4.8 only. Clang works fine without this. Added __attribute__((aligned(16))) to first member of param_info_s. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -374,6 +374,7 @@ union param_value_u {
|
||||
void *p;
|
||||
int32_t i;
|
||||
float f;
|
||||
long long x;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -383,7 +384,23 @@ union param_value_u {
|
||||
* instead.
|
||||
*/
|
||||
struct param_info_s {
|
||||
const char *name;
|
||||
const char *name
|
||||
|
||||
// GCC 4.8 and higher don't implement proper alignment of static data on
|
||||
// 64-bit. This means that the 24-byte param_info_s variables are
|
||||
// 16 byte aligned by GCC and that messes up the assumption that
|
||||
// sequential items in the __param segment can be addressed as an array.
|
||||
// The assumption is that the address of the second parameter is at
|
||||
// ¶m[0]+sizeof(param[0]). When compiled with clang it is
|
||||
// true, with gcc is is not true.
|
||||
// See https://llvm.org/bugs/show_bug.cgi?format=multiple&id=18006
|
||||
// The following hack is for GCC >=4.8 only. Clang works fine without
|
||||
// this.
|
||||
#ifdef __PX4_LINUX
|
||||
__attribute__((aligned(16)));
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
param_type_t type;
|
||||
union param_value_u val;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user