From owner-svn-src-head@freebsd.org Fri Nov 2 11:38:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6688910F313E for ; Fri, 2 Nov 2018 11:38:38 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E571C84289; Fri, 2 Nov 2018 11:38:37 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id wA2BcR3s057012 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 2 Nov 2018 13:38:30 +0200 (EET) (envelope-from kib@freebsd.org) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua wA2BcR3s057012 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id wA2BcRTn057011; Fri, 2 Nov 2018 13:38:27 +0200 (EET) (envelope-from kib@freebsd.org) X-Authentication-Warning: tom.home: kostik set sender to kib@freebsd.org using -f Date: Fri, 2 Nov 2018 13:38:27 +0200 From: Konstantin Belousov To: Mark Millard Cc: svn-src-head@freebsd.org, Alexander Richardson Subject: Re: svn commit: r339876 - head/libexec/rtld-elf Message-ID: <20181102113827.GM5335@kib.kiev.ua> References: <8E5A5F3A-F1A7-4702-A2F7-65D74CC5B2E5@yahoo.com> <20181102004101.GI5335@kib.kiev.ua> <003A49D7-6E8B-4775-A70B-E0EB44505D4B@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <003A49D7-6E8B-4775-A70B-E0EB44505D4B@yahoo.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2018 11:38:38 -0000 On Fri, Nov 02, 2018 at 12:16:23AM -0700, Mark Millard wrote: > It stops when the dcbst in __syncicache runs into an address in > the p_align 65536 caused hole between the two PT_LOAD's with PF_X. > /bin/ls itself has such a hole, as do the .so libraries involved. Try this. I only compile-tested the change. diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c index e921a4dc7d1..5f21e33bee3 100644 --- a/libexec/rtld-elf/powerpc/reloc.c +++ b/libexec/rtld-elf/powerpc/reloc.c @@ -294,6 +294,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags, { const Elf_Rela *relalim; const Elf_Rela *rela; + const Elf_Phdr *phdr; SymCache *cache; int r = -1; @@ -327,8 +328,18 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags, if (cache != NULL) free(cache); - /* Synchronize icache for text seg in case we made any changes */ - __syncicache(obj->mapbase, obj->textsize); + /* + * Synchronize icache for executable segments in case we made + * any changes. + */ + for (phdr = obj->phdr; + (const char *)phdr < (const char *)obj->phdr + obj->phsize; + phdr++) { + if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X) != 0) { + __syncicache(obj->mapbase + phdr->p_vaddr, + phdr->p_memsz); + } + } return (r); } diff --git a/libexec/rtld-elf/powerpc64/reloc.c b/libexec/rtld-elf/powerpc64/reloc.c index c2d6dac13b1..980b4933afe 100644 --- a/libexec/rtld-elf/powerpc64/reloc.c +++ b/libexec/rtld-elf/powerpc64/reloc.c @@ -291,6 +291,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags, { const Elf_Rela *relalim; const Elf_Rela *rela; + const Elf_Phdr *phdr; SymCache *cache; int bytes = obj->dynsymcount * sizeof(SymCache); int r = -1; @@ -327,8 +328,18 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags, if (cache) munmap(cache, bytes); - /* Synchronize icache for text seg in case we made any changes */ - __syncicache(obj->mapbase, obj->textsize); + /* + * Synchronize icache for executable segments in case we made + * any changes. + */ + for (phdr = obj->phdr; + (const char *)phdr < (const char *)obj->phdr + obj->phsize; + phdr++) { + if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X) != 0) { + __syncicache(obj->mapbase + phdr->p_vaddr, + phdr->p_memsz); + } + } return (r); }