fix-elf-size.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
  2. index d83c0b3f..507e707b 100644
  3. --- a/libelf/elf32_updatenull.c
  4. +++ b/libelf/elf32_updatenull.c
  5. @@ -137,7 +137,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
  6. return -1;
  7. /* At least the ELF header is there. */
  8. - off_t size = elf_typesize (LIBELFBITS, ELF_T_EHDR, 1);
  9. + ElfW2(LIBELFBITS,Off) size = elf_typesize (LIBELFBITS, ELF_T_EHDR, 1);
  10. /* Set the program header position. */
  11. if (elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
  12. @@ -152,7 +152,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
  13. {
  14. /* The user is supposed to fill out e_phoff. Use it and
  15. e_phnum to determine the maximum extend. */
  16. - size = MAX ((size_t) size,
  17. + size = MAX (size,
  18. ehdr->e_phoff
  19. + elf_typesize (LIBELFBITS, ELF_T_PHDR, phnum));
  20. }
  21. @@ -330,7 +330,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
  22. if (elf->flags & ELF_F_LAYOUT)
  23. {
  24. - size = MAX ((GElf_Word) size,
  25. + size = MAX (size,
  26. (shdr->sh_type != SHT_NOBITS
  27. ? shdr->sh_offset + shdr->sh_size : 0));
  28. @@ -352,9 +352,9 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
  29. update_if_changed (shdr->sh_addralign, sh_align,
  30. scn->shdr_flags);
  31. - size = (size + sh_align - 1) & ~(sh_align - 1);
  32. + size = (size + sh_align - 1) & ~(ElfW2(LIBELFBITS,Off))(sh_align - 1);
  33. int offset_changed = 0;
  34. - update_if_changed (shdr->sh_offset, (GElf_Word) size,
  35. + update_if_changed (shdr->sh_offset, size,
  36. offset_changed);
  37. changed |= offset_changed;
  38. @@ -416,7 +416,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
  39. /* The user is supposed to fill out e_shoff. Use it and
  40. e_shnum (or sh_size of the dummy, first section header)
  41. to determine the maximum extend. */
  42. - size = MAX ((GElf_Word) size,
  43. + size = MAX (size,
  44. (ehdr->e_shoff
  45. + (elf_typesize (LIBELFBITS, ELF_T_SHDR, shnum))));
  46. }
  47. @@ -430,7 +430,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
  48. #define SHDR_ALIGN sizeof (ElfW2(LIBELFBITS,Off))
  49. size = (size + SHDR_ALIGN - 1) & ~(SHDR_ALIGN - 1);
  50. - update_if_changed (ehdr->e_shoff, (GElf_Word) size, elf->flags);
  51. + update_if_changed (ehdr->e_shoff, size, elf->flags);
  52. /* Account for the section header size. */
  53. size += elf_typesize (LIBELFBITS, ELF_T_SHDR, shnum);