From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 24 18:53:10 2009 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 E5DEF1065692 for ; Tue, 24 Nov 2009 18:53:10 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-pw0-f44.google.com (mail-pw0-f44.google.com [209.85.160.44]) by mx1.freebsd.org (Postfix) with ESMTP id C1B598FC27 for ; Tue, 24 Nov 2009 18:53:10 +0000 (UTC) Received: by pwj15 with SMTP id 15so4725583pwj.3 for ; Tue, 24 Nov 2009 10:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=NrQlWj9TBZin9+vL0xDySQ+EqQYuxOWnGhInmzygcy0=; b=CY/9WLBk6O1rdca3yGIQ7LA3rrySYHeGaIkTV5GcrEARSpgGRbVlUXLT2dOVGFKO3Q Peui1/OB1/8B5S2d7HhHYoX4ddfMfQ+zMLr2im0v6pLWz/JTcboHwg9jWJDlKyFbwNVD Je5uoiXc1EVprhV8Hfkt7ztQAFmtLqC0BX8/E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=I2912ZUjIWDsmLahvqqA01WqcDS/8M0PLFlqz2oVH4PzrFC+E2f1NxP/dWi3sTd2V3 1wnsJfi/AcKM3a2gOmJiBnkl5iBJ+r4Oy1tuZLc9zxNU/JQkZJVjk1QXh3pB6jbZmdC1 vby5QwePRkYBF92mbHpeYskEdYP0ppkpfYDik= MIME-Version: 1.0 Received: by 10.142.117.6 with SMTP id p6mr708727wfc.343.1259087379015; Tue, 24 Nov 2009 10:29:39 -0800 (PST) Date: Tue, 24 Nov 2009 10:29:38 -0800 Message-ID: From: Navdeep Parhar To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: zero size set_pcpu linker sets 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: Tue, 24 Nov 2009 18:53:11 -0000 objdump -h shows that most, but not all, KLDs on amd64 have a "set_pcpu" section of size 0. Why? What is the difference between having a 0 sized set_pcpu vs. not having it at all? The kernel linker considers the alignment requirements of these empty sections and advances mapsize/mapbase. This bothers my kgdb (which is slightly modified to deal with amd64 KLDs). I'm using the patch shown here as a stopgap measure. I think the correct fix is to not have these empty sections in the KLD to begin with. Regards, Navdeep diff -r 09b877bb00f2 sys/kern/link_elf_obj.c --- a/sys/kern/link_elf_obj.c Mon Nov 23 12:42:09 2009 -0800 +++ b/sys/kern/link_elf_obj.c Tue Nov 24 10:13:02 2009 -0800 @@ -680,10 +680,12 @@ switch (shdr[i].sh_type) { case SHT_PROGBITS: case SHT_NOBITS: - alignmask = shdr[i].sh_addralign - 1; - mapsize += alignmask; - mapsize &= ~alignmask; - mapsize += shdr[i].sh_size; + if (shdr[i].sh_size) { + alignmask = shdr[i].sh_addralign - 1; + mapsize += alignmask; + mapsize &= ~alignmask; + mapsize += shdr[i].sh_size; + } break; } } @@ -740,9 +742,15 @@ switch (shdr[i].sh_type) { case SHT_PROGBITS: case SHT_NOBITS: - alignmask = shdr[i].sh_addralign - 1; - mapbase += alignmask; - mapbase &= ~alignmask; + if (shdr[i].sh_size) { + alignmask = shdr[i].sh_addralign - 1; + mapbase += alignmask; + mapbase &= ~alignmask; + } if (ef->shstrtab && shdr[i].sh_name != 0) ef->progtab[pb].name = ef->shstrtab + shdr[i].sh_name;