[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-tech-toolchain
Subject:    Re: A binary that has PT_LOAD more than 2
From:       Ryo ONODERA <ryo () tetera ! org>
Date:       2018-09-25 12:23:06
Message-ID: 20180925.212306.568835515629069696.ryo () tetera ! org
[Download RAW message or body]

Hi,

From: Valery Ushakov <uwe@stderr.spb.ru>, Date: Tue, 25 Sep 2018 14:51:21 +0300

> On Tue, Sep 25, 2018 at 20:24:24 +0900, Ryo ONODERA wrote:
> 
> > From: Valery Ushakov <uwe@stderr.spb.ru>, 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.

I understand _rtld_map_object() depends on length of segs[] array is two.
I should read ELF definition again to say more.

Thank you.

> -uwe

--
Ryo ONODERA // ryo@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic