From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 2 08:30:07 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D123106566B; Fri, 2 Jul 2010 08:30:07 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mail.cksoft.de (mail.cksoft.de [IPv6:2001:4068:10::3]) by mx1.freebsd.org (Postfix) with ESMTP id 340538FC30; Fri, 2 Jul 2010 08:30:07 +0000 (UTC) Received: from localhost (amavis.fra.cksoft.de [192.168.74.71]) by mail.cksoft.de (Postfix) with ESMTP id 8B9B241C707; Fri, 2 Jul 2010 10:30:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at cksoft.de Received: from mail.cksoft.de ([192.168.74.103]) by localhost (amavis.fra.cksoft.de [192.168.74.71]) (amavisd-new, port 10024) with ESMTP id 1tRcRzzVfR7n; Fri, 2 Jul 2010 10:30:05 +0200 (CEST) Received: by mail.cksoft.de (Postfix, from userid 66) id B506341C6DB; Fri, 2 Jul 2010 10:30:05 +0200 (CEST) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id 04E0F4448EC; Fri, 2 Jul 2010 08:29:30 +0000 (UTC) Date: Fri, 2 Jul 2010 08:29:30 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: Andriy Gapon In-Reply-To: <4C246CD0.3020606@freebsd.org> Message-ID: <20100702082754.S14969@maildrop.int.zabbadoz.net> References: <4C246CD0.3020606@freebsd.org> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org, Konstantin Belousov , Navdeep Parhar , Peter Wemm Subject: Re: elf obj load: skip zero-sized sections early X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jul 2010 08:30:07 -0000 On Fri, 25 Jun 2010, Andriy Gapon wrote: Hey, > Proposed patch skips zero sized sections without going into trouble of > allocating section entry (progtab), doing zero-sized memory allocs and copies. > I observe that sometimes zero-sized set_pcpu sections are produced in module > objects, maybe when a module doesn't create any per cpu data of its one, but > references external pcpu data. Not sure. > > Main goal of this patch is to play nice with external debugging tools (e.g. > kgdb) which ignore zero-sized sections outright. Current code effectively > ignores but may apply their alignment to the next non-zero section if its > required alignment is smaller. So the patch should get rid of that side effect > as well as do some very tiny resource conservation. > > This work is based on np@'s investigation and original patch: > http://lists.freebsd.org/pipermail/freebsd-hackers/2009-November/030093.html Have you guys figured this out already? Adding kib to Cc: in case he can help. /bz > diff --git a/sys/boot/common/load_elf_obj.c b/sys/boot/common/load_elf_obj.c > index 4b3aaea..6f3b349 100644 > --- a/sys/boot/common/load_elf_obj.c > +++ b/sys/boot/common/load_elf_obj.c > @@ -221,6 +221,8 @@ __elfN(obj_loadimage)(struct preloaded_file *fp, elf_file_t > ef, u_int64_t off) > for (i = 0; i < hdr->e_shnum; i++) > shdr[i].sh_addr = 0; > for (i = 0; i < hdr->e_shnum; i++) { > + if (shdr[i].sh_size == 0) > + continue; > switch (shdr[i].sh_type) { > case SHT_PROGBITS: > case SHT_NOBITS: > diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c > index a337fd0..b0df57d 100644 > --- a/sys/kern/link_elf_obj.c > +++ b/sys/kern/link_elf_obj.c > @@ -555,6 +555,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, > symtabindex = -1; > symstrindex = -1; > for (i = 0; i < hdr->e_shnum; i++) { > + if (shdr[i].sh_size == 0) > + continue; > switch (shdr[i].sh_type) { > case SHT_PROGBITS: > case SHT_NOBITS: > @@ -677,6 +679,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, > /* Size up code/data(progbits) and bss(nobits). */ > alignmask = 0; > for (i = 0; i < hdr->e_shnum; i++) { > + if (shdr[i].sh_size == 0) > + continue; > switch (shdr[i].sh_type) { > case SHT_PROGBITS: > case SHT_NOBITS: > @@ -737,6 +741,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, > ra = 0; > alignmask = 0; > for (i = 0; i < hdr->e_shnum; i++) { > + if (shdr[i].sh_size == 0) > + continue; > switch (shdr[i].sh_type) { > case SHT_PROGBITS: > case SHT_NOBITS: > > -- Bjoern A. Zeeb From August on I will have a life. It's now up to you to do the maths and count to 64. -- Bondorf, Germany, 14th June 2010