1
0
mirror of https://xff.cz/git/u-boot/ synced 2026-01-01 20:27:11 +01:00
Files
u-boot-megous/include
Rasmus Villemoes ee3a46a437 global-data.h: add build-time sanity check of sizeof(struct global_data)
The layout and contents of struct global_data depends on a lot of
CONFIG_* preprocessor macros, not all of which are entirely converted
to Kconfig - not to mention weird games played here and there. This
can result in one translation unit using one definition of struct
global_data while the actual layout is another.

That can be very hard to debug. But we already have a mechanism that
can help catch such bugs at build time, namely the asm-offsets
machinery which is necessary anyway to provide assembly code with the
necessary constants. So make sure that every C translation unit that
include global_data.h actually sees the same size of struct
global_data as that which was seen by the asm-offsets.c TU.

It is likely that this patch will break the build of some boards. For
example, without the patch from Matt Merhar
(https://lists.denx.de/pipermail/u-boot/2021-May/450135.html) or some
other fix, this breaks P2041RDB_defconfig:

  CC      arch/powerpc/lib/traps.o
  AS      arch/powerpc/cpu/mpc85xx/start.o
In file included from include/asm-generic/global_data.h:26,
                 from ./arch/powerpc/include/asm/global_data.h:109,
                 from include/init.h:21,
                 from arch/powerpc/lib/traps.c:7:
include/linux/build_bug.h:99:41: error: static assertion failed: "sizeof(struct global_data) == GD_SIZE"
   99 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
      |                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:98:34: note: in expansion of macro ‘__static_assert’
   98 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
      |                                  ^~~~~~~~~~~~~~~
include/asm-generic/global_data.h:470:1: note: in expansion of macro ‘static_assert’
  470 | static_assert(sizeof(struct global_data) == GD_SIZE);
      | ^~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:266: arch/powerpc/lib/traps.o] Error 1
make: *** [Makefile:1753: arch/powerpc/lib] Error 2
make: *** Waiting for unfinished jobs....

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-01 16:34:32 -04:00
..
2021-06-24 11:53:00 +05:30
2021-06-17 09:40:57 +08:00
2019-12-06 16:44:20 -05:00
2019-10-16 05:42:27 +02:00
2021-06-08 11:39:09 -04:00
2020-05-11 10:16:49 +05:30
2021-01-15 14:36:12 -05:00
2021-01-25 21:52:00 +00:00
2021-01-25 21:52:00 +00:00
2020-07-09 12:33:24 +08:00
2020-05-18 17:33:33 -04:00
2021-01-12 10:58:04 +05:30
2020-12-26 12:37:28 +01:00
2021-01-30 14:25:42 -07:00
2021-06-18 10:09:41 +02:00
2019-04-23 20:26:43 -06:00
2020-02-05 19:33:46 -07:00
2019-10-13 23:34:43 +02:00
2020-05-07 09:01:42 -04:00
2020-08-03 22:19:54 -04:00
2021-04-10 12:00:24 +02:00
2020-05-18 21:19:23 -04:00
2021-04-16 17:32:34 -04:00
2020-08-07 22:31:32 -04:00
2021-04-10 08:04:42 -04:00
2021-02-10 10:00:51 +01:00
2020-10-30 10:56:11 -04:00
2020-05-18 17:33:33 -04:00
2020-06-12 13:14:07 -04:00
2019-02-20 15:27:09 +08:00
2019-10-14 09:31:41 +02:00
2020-01-20 15:38:16 +01:00
2019-11-07 18:39:16 -05:00
2021-06-11 16:34:52 +05:30
2020-05-18 18:36:55 -04:00
2019-08-11 16:43:41 -04:00
2020-04-17 12:32:36 -04:00
2021-06-07 10:48:40 -04:00
2019-12-02 18:23:11 -05:00
2021-06-23 08:45:03 -04:00
2021-06-24 11:54:07 +05:30
2021-04-20 07:31:12 -04:00
2020-07-17 10:47:19 -04:00
2021-04-12 17:44:55 -04:00
2020-06-14 21:07:20 +02:00
2020-02-05 19:33:46 -07:00
2020-06-14 21:07:20 +02:00
2020-07-09 06:02:44 +02:00
2020-09-30 11:55:23 -04:00
2020-02-05 19:33:46 -07:00
2021-03-27 15:04:31 +13:00
2021-01-05 16:20:26 -05:00
2019-05-21 17:33:23 -06:00
2020-10-22 09:54:53 -04:00
2020-08-03 22:19:54 -04:00
2021-01-27 17:03:16 -05:00
2020-08-03 22:19:54 -04:00
2021-01-15 14:36:12 -05:00