On Mon, 22 Aug 2016, Mark Kettenis wrote:
...
> +void
> +_dl_run_dtors(elf_object_t *obj)
> +{
> +     if (obj->dyn.fini_array) {
> +             int num = obj->dyn.fini_arraysz / sizeof(Elf_Addr);
> +             int i;
> +
> +             DL_DEB(("doing finiarray obj %p @%p: [%s]\n",
> +                 obj, obj->dyn.fini, obj->load_name));

That should be 
                    obj, obj->dyn.fini_array, obj->load_name));


> --- libexec/ld.so/resolve.h   8 Aug 2016 21:59:20 -0000       1.79
> +++ libexec/ld.so/resolve.h   22 Aug 2016 21:32:31 -0000
> @@ -81,13 +81,23 @@ struct elf_object {
>                       const char      *soname;
>                       const char      *rpath;
>                       Elf_Addr        symbolic;
> -                     Elf_Rel *rel;
> +                     Elf_Rel         *rel;
>                       Elf_Addr        relsz;
>                       Elf_Addr        relent;
>                       Elf_Addr        pltrel;
>                       Elf_Addr        debug;
>                       Elf_Addr        textrel;
>                       Elf_Addr        jmprel;
> +                     Elf_Addr        bind_now;
> +                     void            (**init_array)(void);
> +                     void            (**fini_array)(void);
> +                     Elf_Addr        init_arraysz;
> +                     Elf_Addr        fini_arraysz;
> +                     const char      *runpath;
> +                     Elf_Addr        flags;
> +                     Elf_Addr        encoding;
> +                     void            (**preinit_array)(void);
> +                     Elf_Addr        preinit_arraysz;
>               } u;
>       } Dyn;

This part is wrong and may explode into flames on m88k and 
mips64...because you must increase DT_NUM to match the growth in the Dyn.u 
struct or else the arch-specific DT_* tags starting at DT_LOPROC will 
overlay it starting at the new members!  (mips64 and m88k are the only
archs with DT_PROCNUM large enough to overlay the new bits.)

Right now, DT_NUM is defined in <sys/exec_elf.h>, but that's dumb: it 
should be moved immediately to libexec/ld.so/resolv.h, right above this 
struct, and its value increased to match the growth here.  I killed it's 
use in lib/csu for this, so don't hesitate in pulling it over.

Otherwise the diff looks good to me.


...and maybe once this is in I should resurrect my diff to change the rest 
of ld.so like I did boot.c: eliminate the union of struct+array and cache 
just the tags we care about, because it's wasteful and a horrid trap.


Philip

Reply via email to