[lkml]   [2004]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build
Paul Jackson wrote:
> Not sure how (no lkml thread that I can see), but it seems from Andrew's
> broken out patch "bssprot.patch" in 2.6.6-rc2-mm2 that John Reiser
> and/or others on the To list above conspired to break the build of
> arch/ia64/ia32/binfmt_elf32.c: elf32_map().

There was no conspiracy. The patch was compiled and linked on three archs,
and ia64 was not one of them. The #define of elf32_map contributed to
the obfuscation.

> Would someone care to recommend a proper fix?

A proper fix might require help from an ia64 maintainer to define macros
and will require ia32_do_munmap(). Below is partial progress,
"completing the parallelogram" from fs/binfmt_elf.c via
arch/x86_64/ia32/ia32_binfmt.c and arch/s390/kernel/binfmt_elf32.c.
This patch requires an ia32_do_munmap(). Until then, Paul's change
is sufficient, and loses no functionality except when PT_LOADs from the
same file designate non-adjacent regions, which was part of the reason
for the bssprot* patch(es) anyway.

When applied after 2.6.6-rc2-mm2, this compiles with warning (no prototype
for ia32_do_munmap), does not link (ia32_do_munmap is undefined), and
has not been executed.

--- ./arch/ia64/ia32/binfmt_elf32.c.orig 2004-04-26 19:17:14.000000000 -0700
+++ ./arch/ia64/ia32/binfmt_elf32.c 2004-04-26 19:57:19.000000000 -0700
@@ -220,10 +220,33 @@

static unsigned long
-elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type)
+elf32_map (struct file *filep, unsigned long addr, struct elf_phdr const *eppnt,
+ int prot, int type, unsigned long total_size)
- unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK;
+ unsigned long const pgoff = eppnt->p_vaddr & ~IA32_PAGE_MASK;

- return ia32_do_mmap(filep, (addr & IA32_PAGE_MASK), eppnt->p_filesz + pgoff, prot, type,
- eppnt->p_offset - pgoff);
+ unsigned long size = eppnt->p_filesz + pgoff;
+ unsigned long off = eppnt->p_offset - pgoff;
+ addr = addr & IA32_PAGE_MASK; /* IA32_ELF_PAGESTART ? */
+ size = IA32_PAGE_ALIGN(size); /* IA32_ELF_PAGEALIGN ? */
+ /*
+ * total_size is the size of the ELF (interpreter) image.
+ * The _first_ mmap needs to know the full size, otherwise
+ * randomization might put this image into an overlapping
+ * position with the ELF binary image. (since size < total_size)
+ * So we first map the 'big' image - and unmap the remainder at
+ * the end. (which unmap is needed for ELF images with holes.)
+ */
+ if (total_size) {
+ unsigned long map_addr;
+ total_size = IA32_PAGE_ALIGN(total_size); /* IA32_ELF_PAGEALIGN ? */
+ map_addr = ia32_do_mmap(filep, addr, total_size, prot, type, off);
+ if (!BAD_ADDR(map_addr))
+ ia32_do_munmap(current->mm, map_addr+size, total_size-size);
+ return map_addr;
+ } else
+ return ia32_do_mmap(filep, addr, size, prot, type, off);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 14:02    [W:0.084 / U:8.596 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site