Advertisement
fig02

fix_bss.h

Apr 6th, 2024 (edited)
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.25 KB | None | 0 0
  1. #define DUMMY_STRUCT(line, tens, ones) struct DummyStruct_##line##_##tens##_##ones
  2. #define ONE_DUMMY_STRUCT(line, tens, ones) DUMMY_STRUCT(line, tens, ones)
  3. #define TEN_DUMMY_STRUCTS(line, index)  \
  4.     DUMMY_STRUCT(line, index, 0);       \
  5.     DUMMY_STRUCT(line, index, 1);       \
  6.     DUMMY_STRUCT(line, index, 2);       \
  7.     DUMMY_STRUCT(line, index, 3);       \
  8.     DUMMY_STRUCT(line, index, 4);       \
  9.     DUMMY_STRUCT(line, index, 5);       \
  10.     DUMMY_STRUCT(line, index, 6);       \
  11.     DUMMY_STRUCT(line, index, 7);       \
  12.     DUMMY_STRUCT(line, index, 8);       \
  13.     DUMMY_STRUCT(line, index, 9)
  14.  
  15. // Macros which define dummy structs to increment the IDO block number for BSS ordering.
  16. #define INCREMENT_BLOCK_NUMBER_BY_1() ONE_DUMMY_STRUCT(__LINE__, 0, 0)
  17. #define INCREMENT_BLOCK_NUMBER_BY_10() TEN_DUMMY_STRUCTS(__LINE__, 0)
  18. #define INCREMENT_BLOCK_NUMBER_BY_100() \
  19.     TEN_DUMMY_STRUCTS(__LINE__, 0);     \
  20.     TEN_DUMMY_STRUCTS(__LINE__, 1);     \
  21.     TEN_DUMMY_STRUCTS(__LINE__, 2);     \
  22.     TEN_DUMMY_STRUCTS(__LINE__, 3);     \
  23.     TEN_DUMMY_STRUCTS(__LINE__, 4);     \
  24.     TEN_DUMMY_STRUCTS(__LINE__, 5);     \
  25.     TEN_DUMMY_STRUCTS(__LINE__, 6);     \
  26.     TEN_DUMMY_STRUCTS(__LINE__, 7);     \
  27.     TEN_DUMMY_STRUCTS(__LINE__, 8);     \
  28.     TEN_DUMMY_STRUCTS(__LINE__, 9)
  29.  
  30. // For retail BSS ordering, the block number of sMainThread must be 0 or
  31. // just above (the exact upper bound depends on the block numbers assigned to
  32. // extern variables declared in headers).
  33. #define FIX_MAIN_BSS() \
  34.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  35.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  36.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  37.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  38.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  39.     INCREMENT_BLOCK_NUMBER_BY_10();
  40.  
  41. // For retail BSS ordering, the block number of sFaultInstance must be 0 or
  42. // just above (the exact upper bound depends on the block numbers assigned to
  43. // extern variables declared in headers).
  44. #define FIX_FAULT_BSS() \
  45.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  46.     INCREMENT_BLOCK_NUMBER_BY_10(); \
  47.     #if !OOT_DEBUG
  48.     INCREMENT_BLOCK_NUMBER_BY_1(); \
  49.     INCREMENT_BLOCK_NUMBER_BY_1(); \
  50.     INCREMENT_BLOCK_NUMBER_BY_1(); \
  51.     INCREMENT_BLOCK_NUMBER_BY_1(); \
  52.     INCREMENT_BLOCK_NUMBER_BY_1(); \
  53.     #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement