tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: A binary that has PT_LOAD more than 2



On Tue, Sep 25, 2018 at 20:24:24 +0900, Ryo ONODERA wrote:

> From: Valery Ushakov <uwe%stderr.spb.ru@localhost>, Date: Tue, 25 Sep 2018 13:13:45 +0300
> 
> > On Tue, Sep 25, 2018 at 17:57:19 +0900, Ryo ONODERA wrote:
> > 
> >> The Go language compiler (pkgsrc/lang/go111) produces
> >> three PT_LOAD in a ELF executable.
> >> And I found that LLD linker from LLVM also produces three PT_LOAD.
> >> 
> >> Our ldd(8) command cannot accept three PT_LOAD now.
> >> Can we accept three or more PT_LOAD in our ldd(8)?
> >> 
> >> Are there any other issues to be discussed to support three PT_LOAD
> >> binaries?
> > 
> > Define "our"?
> > 
> > libexec/ld.elf_so/headers.c:
> > 
> >  revision 1.62
> >  date: 2017-06-23 18:29:21 +0300;  author: joerg;  state: Exp;  lines: +11 -12;  commitid: 9duF2Q9DPoICLvWz;
> >  branches:  1.62.4;
> >  Remove old assert that only two segments exist. The rest of the code has
> >  been changed to cope with more and at least Go actively creates them.
> >  Adjust the mapping size computation to use the maximum and not depend on
> >  PT_LOAD segments to be in order.
> > 
> > and this is in current and -8.
> > 
> > http://gnats.netbsd.org/16983
> 
> Thanks for your pointer.
> I understand that executing executables that have PT_LOAD more than 2
> is valid for NetBSD 8 and current.
> It is very good news for me.
> 
> However, ldd(8) uses _rtld_map_object() in
> src/libexec/ld.elf_so/map_object.c file.
> It has the following condition.
> 
>         if (nsegs != 2) {
>                 _rtld_error("%s: wrong number of segments (%d != 2)", path,
>                     nsegs);
>                 goto bad;
>         }
> 
> This part can be removed safely?

Oh, sorry, I was not paying enough attention.

This check can't be just removed b/c Elf_Phdr *segs[2]; so I've
reopened bin/16983.

-uwe


Home | Main Index | Thread Index | Old Index