logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0003-Avoid-__attribute__-packed-requirement.patch (17981B)


  1. From 45d27217546b0fdbb4cf89beedb75d2675bb14a4 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Mon, 6 Sep 2021 22:51:14 -0700
  4. Subject: [PATCH] Avoid __attribute__((packed)) requirement
  5. Also, use portable get_*/set_* functions. Compilers will optimize
  6. the memory access to a single load/store if possible.
  7. ---
  8. extlinux/main.c | 46 ++++----
  9. libinstaller/setadv.c | 14 +--
  10. libinstaller/syslxint.h | 255 ++++++++++++----------------------------
  11. libinstaller/syslxmod.c | 20 ++--
  12. 4 files changed, 112 insertions(+), 223 deletions(-)
  13. diff --git a/extlinux/main.c b/extlinux/main.c
  14. index 04a2036b..0186baba 100644
  15. --- a/extlinux/main.c
  16. +++ b/extlinux/main.c
  17. @@ -236,7 +236,7 @@ static int patch_file_and_bootblock(int fd, const char *dir, int devfd)
  18. sector_t *sectp;
  19. uint64_t totalbytes, totalsectors;
  20. int nsect;
  21. - struct fat_boot_sector *sbs;
  22. + unsigned char *sbs;
  23. char *dirpath, *subpath, *xdirpath;
  24. int rv;
  25. @@ -293,20 +293,20 @@ static int patch_file_and_bootblock(int fd, const char *dir, int devfd)
  26. early bootstrap share code with the FAT version. */
  27. dprintf("heads = %u, sect = %u\n", geo.heads, geo.sectors);
  28. - sbs = (struct fat_boot_sector *)syslinux_bootsect;
  29. + sbs = syslinux_bootsect;
  30. totalsectors = totalbytes >> SECTOR_SHIFT;
  31. if (totalsectors >= 65536) {
  32. - set_16(&sbs->bsSectors, 0);
  33. + set_16(sbs + FAT_BS_SECTORS, 0);
  34. } else {
  35. - set_16(&sbs->bsSectors, totalsectors);
  36. + set_16(sbs + FAT_BS_SECTORS, totalsectors);
  37. }
  38. - set_32(&sbs->bsHugeSectors, totalsectors);
  39. + set_32(sbs + FAT_BS_HUGE_SECTORS, totalsectors);
  40. - set_16(&sbs->bsBytesPerSec, SECTOR_SIZE);
  41. - set_16(&sbs->bsSecPerTrack, geo.sectors);
  42. - set_16(&sbs->bsHeads, geo.heads);
  43. - set_32(&sbs->bsHiddenSecs, geo.start);
  44. + set_16(sbs + FAT_BS_BYTES_PER_SEC, SECTOR_SIZE);
  45. + set_16(sbs + FAT_BS_SEC_PER_TRACK, geo.sectors);
  46. + set_16(sbs + FAT_BS_HEADS, geo.heads);
  47. + set_32(sbs + FAT_BS_HIDDEN_SECS, geo.start);
  48. /* Construct the boot file map */
  49. @@ -346,8 +346,8 @@ int install_bootblock(int fd, const char *device)
  50. {
  51. struct ext2_super_block sb;
  52. struct btrfs_super_block sb2;
  53. - struct fat_boot_sector sb3;
  54. - struct ntfs_boot_sector sb4;
  55. + unsigned char sb3[512];
  56. + unsigned char sb4[512];
  57. xfs_sb_t sb5;
  58. struct ufs_super_block sb6;
  59. bool ok = false;
  60. @@ -374,7 +374,7 @@ int install_bootblock(int fd, const char *device)
  61. return 1;
  62. }
  63. - if (fat_check_sb_fields(&sb3))
  64. + if (fat_check_sb_fields(sb3))
  65. ok = true;
  66. } else if (fs_type == NTFS) {
  67. if (xpread(fd, &sb4, sizeof(sb4), 0) != sizeof(sb4)) {
  68. @@ -382,7 +382,7 @@ int install_bootblock(int fd, const char *device)
  69. return 1;
  70. }
  71. - if (ntfs_check_sb_fields(&sb4))
  72. + if (ntfs_check_sb_fields(sb4))
  73. ok = true;
  74. } else if (fs_type == XFS) {
  75. if (xpread(fd, &sb5, sizeof sb5, 0) != sizeof sb5) {
  76. @@ -427,21 +427,19 @@ int install_bootblock(int fd, const char *device)
  77. }
  78. if (fs_type == VFAT) {
  79. - struct fat_boot_sector *sbs = (struct fat_boot_sector *)syslinux_bootsect;
  80. - if (xpwrite(fd, &sbs->FAT_bsHead, FAT_bsHeadLen, 0) != FAT_bsHeadLen ||
  81. - xpwrite(fd, &sbs->FAT_bsCode, FAT_bsCodeLen,
  82. - offsetof(struct fat_boot_sector, FAT_bsCode)) != FAT_bsCodeLen) {
  83. + unsigned char *sbs = syslinux_bootsect;
  84. + if (xpwrite(fd, sbs + FAT_BS_HEAD, FAT_BS_HEAD_LEN, 0) != FAT_BS_HEAD_LEN ||
  85. + xpwrite(fd, sbs + FAT_BS_CODE, FAT_BS_CODE_LEN,
  86. + FAT_BS_CODE) != FAT_BS_CODE_LEN) {
  87. perror("writing fat bootblock");
  88. return 1;
  89. }
  90. } else if (fs_type == NTFS) {
  91. - struct ntfs_boot_sector *sbs =
  92. - (struct ntfs_boot_sector *)syslinux_bootsect;
  93. - if (xpwrite(fd, &sbs->NTFS_bsHead,
  94. - NTFS_bsHeadLen, 0) != NTFS_bsHeadLen ||
  95. - xpwrite(fd, &sbs->NTFS_bsCode, NTFS_bsCodeLen,
  96. - offsetof(struct ntfs_boot_sector,
  97. - NTFS_bsCode)) != NTFS_bsCodeLen) {
  98. + unsigned char *sbs = syslinux_bootsect;
  99. + if (xpwrite(fd, sbs + NTFS_BS_HEAD,
  100. + NTFS_BS_HEAD_LEN, 0) != NTFS_BS_HEAD_LEN ||
  101. + xpwrite(fd, sbs + NTFS_BS_CODE, NTFS_BS_CODE_LEN,
  102. + NTFS_BS_CODE) != NTFS_BS_CODE_LEN) {
  103. perror("writing ntfs bootblock");
  104. return 1;
  105. }
  106. diff --git a/libinstaller/setadv.c b/libinstaller/setadv.c
  107. index 214f7fc1..4f1cbc88 100644
  108. --- a/libinstaller/setadv.c
  109. +++ b/libinstaller/setadv.c
  110. @@ -44,14 +44,14 @@ static void cleanup_adv(unsigned char *advbuf)
  111. uint32_t csum;
  112. /* Make sure both copies agree, and update the checksum */
  113. - set_32((uint32_t *) advbuf, ADV_MAGIC1);
  114. + set_32(advbuf, ADV_MAGIC1);
  115. csum = ADV_MAGIC2;
  116. for (i = 8; i < ADV_SIZE - 4; i += 4)
  117. - csum -= get_32((uint32_t *) (advbuf + i));
  118. + csum -= get_32(advbuf + i);
  119. - set_32((uint32_t *) (advbuf + 4), csum);
  120. - set_32((uint32_t *) (advbuf + ADV_SIZE - 4), ADV_MAGIC3);
  121. + set_32(advbuf + 4, csum);
  122. + set_32(advbuf + ADV_SIZE - 4, ADV_MAGIC3);
  123. memcpy(advbuf + ADV_SIZE, advbuf, ADV_SIZE);
  124. }
  125. @@ -138,13 +138,13 @@ static int adv_consistent(const unsigned char *p)
  126. int i;
  127. uint32_t csum;
  128. - if (get_32((uint32_t *) p) != ADV_MAGIC1 ||
  129. - get_32((uint32_t *) (p + ADV_SIZE - 4)) != ADV_MAGIC3)
  130. + if (get_32(p) != ADV_MAGIC1 ||
  131. + get_32(p + ADV_SIZE - 4) != ADV_MAGIC3)
  132. return 0;
  133. csum = 0;
  134. for (i = 4; i < ADV_SIZE - 4; i += 4)
  135. - csum += get_32((uint32_t *) (p + i));
  136. + csum += get_32(p + i);
  137. return csum == ADV_MAGIC2;
  138. }
  139. diff --git a/libinstaller/syslxint.h b/libinstaller/syslxint.h
  140. index 7eee7890..dbc6a0b8 100644
  141. --- a/libinstaller/syslxint.h
  142. +++ b/libinstaller/syslxint.h
  143. @@ -23,56 +23,27 @@
  144. # define X86_MEM 0
  145. #endif
  146. -#ifdef __GNUC__
  147. -# ifdef __MINGW32__
  148. - /* gcc 4.7 miscompiles packed structures in MS-bitfield mode */
  149. -# define PACKED __attribute__((packed,gcc_struct))
  150. -# else
  151. -# define PACKED __attribute__((packed))
  152. -# endif
  153. -#else
  154. -# error "Need to define PACKED for this compiler"
  155. -#endif
  156. -
  157. /*
  158. * Access functions for littleendian numbers, possibly misaligned.
  159. */
  160. -static inline uint8_t get_8(const uint8_t * p)
  161. +static inline uint8_t get_8(const unsigned char* p)
  162. {
  163. return *p;
  164. }
  165. -static inline uint16_t get_16(const uint16_t * p)
  166. +static inline uint16_t get_16(const unsigned char *p)
  167. {
  168. -#if X86_MEM
  169. - /* Littleendian and unaligned-capable */
  170. - return *p;
  171. -#else
  172. - const uint8_t *pp = (const uint8_t *)p;
  173. - return pp[0] + ((uint16_t)pp[1] << 8);
  174. -#endif
  175. + return p[0] | (uint16_t)p[1] << 8;
  176. }
  177. -static inline uint32_t get_32(const uint32_t * p)
  178. +static inline uint32_t get_32(const unsigned char *p)
  179. {
  180. -#if X86_MEM
  181. - /* Littleendian and unaligned-capable */
  182. - return *p;
  183. -#else
  184. - const uint16_t *pp = (const uint16_t *)p;
  185. - return get_16(&pp[0]) + ((uint32_t)get_16(&pp[1]) << 16);
  186. -#endif
  187. + return get_16(&p[0]) | (uint32_t)get_16(&p[2]) << 16;
  188. }
  189. -static inline uint64_t get_64(const uint64_t * p)
  190. +static inline uint64_t get_64(const unsigned char *p)
  191. {
  192. -#if X86_MEM
  193. - /* Littleendian and unaligned-capable */
  194. - return *p;
  195. -#else
  196. - const uint32_t *pp = (const uint32_t *)p;
  197. - return get_32(&pp[0]) + ((uint64_t)get_32(&pp[1]) << 32);
  198. -#endif
  199. + return get_32(&p[0]) | (uint64_t)get_32(&p[2]) << 32;
  200. }
  201. static inline void set_8(uint8_t *p, uint8_t v)
  202. @@ -80,40 +51,22 @@ static inline void set_8(uint8_t *p, uint8_t v)
  203. *p = v;
  204. }
  205. -static inline void set_16(uint16_t *p, uint16_t v)
  206. +static inline void set_16(unsigned char *p, uint16_t v)
  207. {
  208. -#if X86_MEM
  209. - /* Littleendian and unaligned-capable */
  210. - *p = v;
  211. -#else
  212. - uint8_t *pp = (uint8_t *) p;
  213. - pp[0] = v;
  214. - pp[1] = v >> 8;
  215. -#endif
  216. + p[0] = v;
  217. + p[1] = v >> 8;
  218. }
  219. -static inline void set_32(uint32_t *p, uint32_t v)
  220. +static inline void set_32(unsigned char *p, uint32_t v)
  221. {
  222. -#if X86_MEM
  223. - /* Littleendian and unaligned-capable */
  224. - *p = v;
  225. -#else
  226. - uint16_t *pp = (uint16_t *) p;
  227. - set_16(&pp[0], v);
  228. - set_16(&pp[1], v >> 16);
  229. -#endif
  230. + set_16(&p[0], v);
  231. + set_16(&p[2], v >> 16);
  232. }
  233. -static inline void set_64(uint64_t *p, uint64_t v)
  234. +static inline void set_64(unsigned char *p, uint64_t v)
  235. {
  236. -#if X86_MEM
  237. - /* Littleendian and unaligned-capable */
  238. - *p = v;
  239. -#else
  240. - uint32_t *pp = (uint32_t *) p;
  241. - set_32(&pp[0], v);
  242. - set_32(&pp[1], v >> 32);
  243. -#endif
  244. + set_32(&p[0], v);
  245. + set_32(&p[4], v >> 32);
  246. }
  247. /*
  248. @@ -139,35 +92,35 @@ void memset_sl(void _slimg *dst, int c, size_t len);
  249. /* Sane system ... */
  250. static inline uint8_t get_8_sl(const uint8_t _slimg * p)
  251. {
  252. - return get_8((const uint8_t _force *)p);
  253. + return get_8((const unsigned char _force *)p);
  254. }
  255. static inline uint16_t get_16_sl(const uint16_t _slimg * p)
  256. {
  257. - return get_16((const uint16_t _force *)p);
  258. + return get_16((const unsigned char _force *)p);
  259. }
  260. static inline uint32_t get_32_sl(const uint32_t _slimg * p)
  261. {
  262. - return get_32((const uint32_t _force *)p);
  263. + return get_32((const unsigned char _force *)p);
  264. }
  265. static inline uint64_t get_64_sl(const uint64_t _slimg * p)
  266. {
  267. - return get_64((const uint64_t _force *)p);
  268. + return get_64((const unsigned char _force *)p);
  269. }
  270. static inline void set_8_sl(uint8_t _slimg * p, uint8_t v)
  271. {
  272. - set_8((uint8_t _force *)p, v);
  273. + set_8((unsigned char _force *)p, v);
  274. }
  275. static inline void set_16_sl(uint16_t _slimg * p, uint16_t v)
  276. {
  277. - set_16((uint16_t _force *)p, v);
  278. + set_16((unsigned char _force *)p, v);
  279. }
  280. static inline void set_32_sl(uint32_t _slimg * p, uint32_t v)
  281. {
  282. - set_32((uint32_t _force *)p, v);
  283. + set_32((unsigned char _force *)p, v);
  284. }
  285. static inline void set_64_sl(uint64_t _slimg * p, uint64_t v)
  286. {
  287. - set_64((uint64_t _force *)p, v);
  288. + set_64((unsigned char _force *)p, v);
  289. }
  290. static inline void memcpy_to_sl(void _slimg *dst, const void *src, size_t len)
  291. {
  292. @@ -213,130 +166,68 @@ struct ext_patch_area {
  293. uint16_t raidpatch; /* Boot sector RAID mode patch pointer */
  294. };
  295. -/* Sector extent */
  296. -struct syslinux_extent {
  297. - uint64_t lba;
  298. - uint16_t len;
  299. -} PACKED;
  300. -
  301. /* FAT bootsector format, also used by other disk-based derivatives */
  302. -struct fat_boot_sector {
  303. - uint8_t bsJump[3];
  304. - char bsOemName[8];
  305. - uint16_t bsBytesPerSec;
  306. - uint8_t bsSecPerClust;
  307. - uint16_t bsResSectors;
  308. - uint8_t bsFATs;
  309. - uint16_t bsRootDirEnts;
  310. - uint16_t bsSectors;
  311. - uint8_t bsMedia;
  312. - uint16_t bsFATsecs;
  313. - uint16_t bsSecPerTrack;
  314. - uint16_t bsHeads;
  315. - uint32_t bsHiddenSecs;
  316. - uint32_t bsHugeSectors;
  317. -
  318. - union {
  319. - struct {
  320. - uint8_t DriveNumber;
  321. - uint8_t Reserved1;
  322. - uint8_t BootSignature;
  323. - uint32_t VolumeID;
  324. - char VolumeLabel[11];
  325. - char FileSysType[8];
  326. - uint8_t Code[442];
  327. - } PACKED bs16;
  328. - struct {
  329. - uint32_t FATSz32;
  330. - uint16_t ExtFlags;
  331. - uint16_t FSVer;
  332. - uint32_t RootClus;
  333. - uint16_t FSInfo;
  334. - uint16_t BkBootSec;
  335. - uint8_t Reserved0[12];
  336. - uint8_t DriveNumber;
  337. - uint8_t Reserved1;
  338. - uint8_t BootSignature;
  339. - uint32_t VolumeID;
  340. - char VolumeLabel[11];
  341. - char FileSysType[8];
  342. - uint8_t Code[414];
  343. - } PACKED bs32;
  344. - } PACKED;
  345. -
  346. - uint32_t bsMagic;
  347. - uint16_t bsForwardPtr;
  348. - uint16_t bsSignature;
  349. -} PACKED;
  350. +#define FAT_BS_JUMP 0x00
  351. +#define FAT_BS_BYTES_PER_SEC 0x0B
  352. +#define FAT_BS_RES_SECTORS 0x0D
  353. +#define FAT_BS_FATS 0x10
  354. +#define FAT_BS_SECTORS 0x13
  355. +#define FAT_BS_SEC_PER_TRACK 0x18
  356. +#define FAT_BS_HEADS 0x1A
  357. +#define FAT_BS_HIDDEN_SECS 0x1C
  358. +#define FAT_BS_HUGE_SECTORS 0x20
  359. +#define FAT_BS_SIGNATURE 0x1FE
  360. +#define FAT_BS16_FILE_SYS_TYPE 0x36
  361. +#define FAT_BS32_FILE_SYS_TYPE 0x52
  362. +#define FAT_BS32_CODE 0x62
  363. +
  364. +#define FAT_BS_HEAD FAT_BS_JUMP
  365. +#define FAT_BS_HEAD_LEN FAT_BS_BYTES_PER_SEC
  366. +#define FAT_BS_CODE FAT_BS32_CODE /* The common safe choice */
  367. +#define FAT_BS_CODE_LEN FAT_BS_SIGNATURE - FAT_BS_CODE
  368. /* NTFS bootsector format */
  369. -struct ntfs_boot_sector {
  370. - uint8_t bsJump[3];
  371. - char bsOemName[8];
  372. - uint16_t bsBytesPerSec;
  373. - uint8_t bsSecPerClust;
  374. - uint16_t bsResSectors;
  375. - uint8_t bsZeroed_0[3];
  376. - uint16_t bsZeroed_1;
  377. - uint8_t bsMedia;
  378. - uint16_t bsZeroed_2;
  379. - uint16_t bsUnused_0;
  380. - uint16_t bsUnused_1;
  381. - uint32_t bsUnused_2;
  382. - uint32_t bsZeroed_3;
  383. - uint32_t bsUnused_3;
  384. - uint64_t bsTotalSectors;
  385. - uint64_t bsMFTLogicalClustNr;
  386. - uint64_t bsMFTMirrLogicalClustNr;
  387. - uint8_t bsClustPerMFTrecord;
  388. - uint8_t bsUnused_4[3];
  389. - uint8_t bsClustPerIdxBuf;
  390. - uint8_t bsUnused_5[3];
  391. - uint64_t bsVolSerialNr;
  392. - uint32_t bsUnused_6;
  393. -
  394. - uint8_t Code[420];
  395. -
  396. - uint32_t bsMagic;
  397. - uint16_t bsForwardPtr;
  398. - uint16_t bsSignature;
  399. -} PACKED;
  400. -
  401. -#define FAT_bsHead bsJump
  402. -#define FAT_bsHeadLen offsetof(struct fat_boot_sector, bsBytesPerSec)
  403. -#define FAT_bsCode bs32.Code /* The common safe choice */
  404. -#define FAT_bsCodeLen (offsetof(struct fat_boot_sector, bsSignature) - \
  405. - offsetof(struct fat_boot_sector, FAT_bsCode))
  406. -
  407. -#define NTFS_bsHead bsJump
  408. -#define NTFS_bsHeadLen offsetof(struct ntfs_boot_sector, bsOemName)
  409. -#define NTFS_bsCode Code
  410. -#define NTFS_bsCodeLen (offsetof(struct ntfs_boot_sector, bsSignature) - \
  411. - offsetof(struct ntfs_boot_sector, NTFS_bsCode))
  412. +#define NTFS_BS_JUMP 0x00
  413. +#define NTFS_BS_OEM_NAME 0x03
  414. +#define NTFS_BS_RES_SECTORS 0x0E
  415. +#define NTFS_BS_ZEROED_0 0x10
  416. +#define NTFS_BS_ZEROED_1 0x13
  417. +#define NTFS_BS_ZEROED_2 0x16
  418. +#define NTFS_BS_ZEROED_3 0x20
  419. +#define NTFS_BS_CODE 0x54
  420. +#define NTFS_BS_SIGNATURE 0x1FE
  421. +
  422. +#define NTFS_BS_HEAD NTFS_BS_JUMP
  423. +#define NTFS_BS_HEAD_LEN NTFS_BS_OEM_NAME
  424. +#define NTFS_BS_CODE_LEN NTFS_BS_SIGNATURE - NTFS_BS_CODE
  425. /* Check if there are specific zero fields in an NTFS boot sector */
  426. -static inline int ntfs_check_zero_fields(const struct ntfs_boot_sector *sb)
  427. +static inline int ntfs_check_zero_fields(const unsigned char *sb)
  428. {
  429. - return !sb->bsResSectors && (!sb->bsZeroed_0[0] && !sb->bsZeroed_0[1] &&
  430. - !sb->bsZeroed_0[2]) && !sb->bsZeroed_1 && !sb->bsZeroed_2 &&
  431. - !sb->bsZeroed_3;
  432. + return !sb[NTFS_BS_RES_SECTORS] && !sb[NTFS_BS_RES_SECTORS + 1] &&
  433. + !sb[NTFS_BS_ZEROED_0] && !sb[NTFS_BS_ZEROED_0 + 1] &&
  434. + !sb[NTFS_BS_ZEROED_0 + 2] && !sb[NTFS_BS_ZEROED_1] &&
  435. + !sb[NTFS_BS_ZEROED_1 + 1] && !sb[NTFS_BS_ZEROED_2] &&
  436. + !sb[NTFS_BS_ZEROED_2 + 1] && !sb[NTFS_BS_ZEROED_3] &&
  437. + !sb[NTFS_BS_ZEROED_3 + 1] && !sb[NTFS_BS_ZEROED_3 + 2] &&
  438. + !sb[NTFS_BS_ZEROED_3 + 3];
  439. }
  440. -static inline int ntfs_check_sb_fields(const struct ntfs_boot_sector *sb)
  441. +static inline int ntfs_check_sb_fields(const unsigned char *sb)
  442. {
  443. return ntfs_check_zero_fields(sb) &&
  444. - (!memcmp(sb->bsOemName, "NTFS ", 8) ||
  445. - !memcmp(sb->bsOemName, "MSWIN4.0", 8) ||
  446. - !memcmp(sb->bsOemName, "MSWIN4.1", 8));
  447. + (!memcmp(sb + NTFS_BS_OEM_NAME, "NTFS ", 8) ||
  448. + !memcmp(sb + NTFS_BS_OEM_NAME, "MSWIN4.0", 8) ||
  449. + !memcmp(sb + NTFS_BS_OEM_NAME, "MSWIN4.1", 8));
  450. }
  451. -static inline int fat_check_sb_fields(const struct fat_boot_sector *sb)
  452. +static inline int fat_check_sb_fields(const unsigned char *sb)
  453. {
  454. - return sb->bsResSectors && sb->bsFATs &&
  455. - (!memcmp(sb->bs16.FileSysType, "FAT12 ", 8) ||
  456. - !memcmp(sb->bs16.FileSysType, "FAT16 ", 8) ||
  457. - !memcmp(sb->bs16.FileSysType, "FAT ", 8) ||
  458. - !memcmp(sb->bs32.FileSysType, "FAT32 ", 8));
  459. + return (sb[FAT_BS_RES_SECTORS] || sb[FAT_BS_RES_SECTORS + 1]) && sb[FAT_BS_FATS] &&
  460. + (!memcmp(sb + FAT_BS16_FILE_SYS_TYPE, "FAT12 ", 8) ||
  461. + !memcmp(sb + FAT_BS16_FILE_SYS_TYPE, "FAT16 ", 8) ||
  462. + !memcmp(sb + FAT_BS16_FILE_SYS_TYPE, "FAT ", 8) ||
  463. + !memcmp(sb + FAT_BS32_FILE_SYS_TYPE, "FAT32 ", 8));
  464. }
  465. #endif /* SYSLXINT_H */
  466. diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c
  467. index 0ec41641..10f7ccf0 100644
  468. --- a/libinstaller/syslxmod.c
  469. +++ b/libinstaller/syslxmod.c
  470. @@ -32,7 +32,7 @@
  471. /*
  472. * Generate sector extents
  473. */
  474. -static void generate_extents(struct syslinux_extent _slimg *ex, int nptrs,
  475. +static void generate_extents(unsigned char *ex, int nptrs,
  476. const sector_t *sectp, int nsect)
  477. {
  478. uint32_t addr = 0x8000; /* ldlinux.sys starts loading here */
  479. @@ -43,7 +43,7 @@ static void generate_extents(struct syslinux_extent _slimg *ex, int nptrs,
  480. base = addr;
  481. len = lba = 0;
  482. - memset_sl(ex, 0, nptrs * sizeof *ex);
  483. + memset_sl(ex, 0, nptrs * 10);
  484. while (nsect) {
  485. sect = *sectp++;
  486. @@ -58,9 +58,9 @@ static void generate_extents(struct syslinux_extent _slimg *ex, int nptrs,
  487. goto next;
  488. }
  489. - set_64_sl(&ex->lba, lba);
  490. - set_16_sl(&ex->len, len);
  491. - ex++;
  492. + set_64(ex, lba);
  493. + set_16(ex + 8, len);
  494. + ex += 10;
  495. }
  496. base = addr;
  497. @@ -73,9 +73,9 @@ static void generate_extents(struct syslinux_extent _slimg *ex, int nptrs,
  498. }
  499. if (len) {
  500. - set_64_sl(&ex->lba, lba);
  501. - set_16_sl(&ex->len, len);
  502. - ex++;
  503. + set_64(ex, lba);
  504. + set_16(ex + 8, len);
  505. + ex += 10;
  506. }
  507. }
  508. @@ -109,7 +109,7 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
  509. {
  510. struct patch_area _slimg *patcharea;
  511. struct ext_patch_area _slimg *epa;
  512. - struct syslinux_extent _slimg *ex;
  513. + unsigned char *ex;
  514. const uint32_t _slimg *wp;
  515. int nsect = ((boot_image_len + SECTOR_SIZE - 1) >> SECTOR_SHIFT) + 2;
  516. uint32_t csum;
  517. @@ -152,7 +152,7 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
  518. }
  519. /* Set the sector extents */
  520. - ex = slptr(boot_image, &epa->secptroffset);
  521. + ex = ptr(boot_image, &epa->secptroffset);
  522. nptrs = get_16_sl(&epa->secptrcnt);
  523. #if 0
  524. --
  525. 2.32.0