Commit 838c2613 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Fix 32 vs 64 bit size issues in eu-strip

Perhaps counterintuitively, Elf64_Word is 32 bits. Don't use it to
manipulate file sizes.

BUG=780860

Change-Id: I0a80e10b46400dcd0e0e43061755494267d67a06
Reviewed-on: https://chromium-review.googlesource.com/954326
Commit-Queue: Michael Moss <mmoss@chromium.org>
Reviewed-by: default avatarMichael Moss <mmoss@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544032}
parent 808b3941
......@@ -8,7 +8,7 @@ autoheader
aclocal
autoconf
automake --add-missing
patch -p1 < ../fix-double-free.patch
patch -p1 < ../fix-elf-size.patch
mkdir build
cd build
../configure --enable-maintainer-mode
......
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 160f0b88..f3a22a0c 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -163,13 +163,6 @@ elf_end (Elf *elf)
if (scn->data_base != scn->rawdata_base)
free (scn->data_base);
- /* The section data is allocated if we couldn't mmap
- the file. Or if we had to decompress. */
- if (elf->map_address == NULL
- || scn->rawdata_base == scn->zdata_base
- || (scn->flags & ELF_F_MALLOCED) != 0)
- free (scn->rawdata_base);
-
/* Free the list of data buffers for the section.
We don't free the buffers themselves since this
is the users job. */
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index d83c0b3f..507e707b 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -137,7 +137,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
return -1;
/* At least the ELF header is there. */
- off_t size = elf_typesize (LIBELFBITS, ELF_T_EHDR, 1);
+ ElfW2(LIBELFBITS,Off) size = elf_typesize (LIBELFBITS, ELF_T_EHDR, 1);
/* Set the program header position. */
if (elf->state.ELFW(elf,LIBELFBITS).phdr == NULL)
@@ -152,7 +152,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
{
/* The user is supposed to fill out e_phoff. Use it and
e_phnum to determine the maximum extend. */
- size = MAX ((size_t) size,
+ size = MAX (size,
ehdr->e_phoff
+ elf_typesize (LIBELFBITS, ELF_T_PHDR, phnum));
}
@@ -330,7 +330,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
if (elf->flags & ELF_F_LAYOUT)
{
- size = MAX ((GElf_Word) size,
+ size = MAX (size,
(shdr->sh_type != SHT_NOBITS
? shdr->sh_offset + shdr->sh_size : 0));
@@ -352,9 +352,9 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
update_if_changed (shdr->sh_addralign, sh_align,
scn->shdr_flags);
- size = (size + sh_align - 1) & ~(sh_align - 1);
+ size = (size + sh_align - 1) & ~(ElfW2(LIBELFBITS,Off))(sh_align - 1);
int offset_changed = 0;
- update_if_changed (shdr->sh_offset, (GElf_Word) size,
+ update_if_changed (shdr->sh_offset, size,
offset_changed);
changed |= offset_changed;
@@ -416,7 +416,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
/* The user is supposed to fill out e_shoff. Use it and
e_shnum (or sh_size of the dummy, first section header)
to determine the maximum extend. */
- size = MAX ((GElf_Word) size,
+ size = MAX (size,
(ehdr->e_shoff
+ (elf_typesize (LIBELFBITS, ELF_T_SHDR, shnum))));
}
@@ -430,7 +430,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
#define SHDR_ALIGN sizeof (ElfW2(LIBELFBITS,Off))
size = (size + SHDR_ALIGN - 1) & ~(SHDR_ALIGN - 1);
- update_if_changed (ehdr->e_shoff, (GElf_Word) size, elf->flags);
+ update_if_changed (ehdr->e_shoff, size, elf->flags);
/* Account for the section header size. */
size += elf_typesize (LIBELFBITS, ELF_T_SHDR, shnum);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment