Messages in this thread | | | Date | Thu, 5 Mar 2009 11:53:46 +0100 | From | Johannes Weiner <> | Subject | Re: [patch -v2] flat: fix data sections alignment |
| |
On Wed, Mar 04, 2009 at 04:48:04PM -0500, Mike Frysinger wrote: > On Wed, Mar 4, 2009 at 08:51, Johannes Weiner wrote: > > --- a/fs/binfmt_flat.c > > +++ b/fs/binfmt_flat.c > > +#ifdef ARCH_SLAB_MINALIGN > > +#define FLAT_DATA_ALIGN (ARCH_SLAB_MINALIGN) > > +#else > > +#define FLAT_DATA_ALIGN (sizeof(void *)) > > +#endif > > ... > > + sp = (unsigned long *) ((unsigned long)sp & -FLAT_DATA_ALIGN); > > ... > > - datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long); > > + datapos = ALIGN(realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long), > > + FLAT_DATA_ALIGN); > > ... > > - datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long); > > + datapos = ALIGN(realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long), > > + FLAT_DATA_ALIGN); > > why not make FLAT_DATA_ALIGN into a macro ? then it'd naturally > follow the existing ALIGN() behavior.
datapos is aligned to the next higher bound while the stack pointer grows down and is therefor aligned to the next lower bound. A FLAT_DATA_ALIGN() doesn't make sense.
> > - sp = (unsigned long *) ((-(unsigned long)sizeof(char *))&(unsigned long) p); > > - > > - sp -= envc+1; > > - envp = sp; > > - sp -= argc+1; > > - argv = sp; > > + sp = (unsigned long *)p; > > + sp -= (envc + argc + 2) + 1 + (flat_argvp_envp_on_stack() ? 2 : 0); > > + sp = (unsigned long *) ((unsigned long)sp & -FLAT_DATA_ALIGN); > > + argv = sp + 1 + (flat_argvp_envp_on_stack() ? 2 : 0); > > + envp = argv + (argc + 1);
Hannes -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |