From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 7 06:05:32 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C697C89E for ; Fri, 7 Dec 2012 06:05:32 +0000 (UTC) (envelope-from shrikanth07@gmail.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3EF0D8FC13 for ; Fri, 7 Dec 2012 06:05:31 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so113031lah.13 for ; Thu, 06 Dec 2012 22:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=x/IpW1l0sePx/cjzxYgEhQjDV8bW5tkJLXj64myYAcE=; b=pMaMJKcvpn+jPXoLJ/EbsA/yhD2rUCV8X/prZdI6i7smPaIjd5Q7tqL+sk/m6Nn4K+ 31AUftOWdI2/jesHzacjuQljkcZromADLhkjSRQP8Kcz143EGEZnGMthXi4pce2/nl2z t4y01flvdeceP1VYwrJWyDeTPIlH41YXwR+gf4CJgI4i5zbnafstc+jrfBX4kP5Bb3rq /a3X60IgLffz4+36LYVuS14toIJfiHxa6Iegjznl3vIuysKSnR98AXEVpyvG1Xu+2VAB dSLQKx5jeiYrYkJ1QBwUkiPXQU9xR+E9AiJIcdaBLQw/JLeYt58feuDSiDXnuoOQ58qF +q8Q== MIME-Version: 1.0 Received: by 10.152.108.42 with SMTP id hh10mr4314887lab.4.1354860330733; Thu, 06 Dec 2012 22:05:30 -0800 (PST) Received: by 10.112.139.71 with HTTP; Thu, 6 Dec 2012 22:05:30 -0800 (PST) In-Reply-To: <20121206231122.GE3013@kib.kiev.ua> References: <20121206231122.GE3013@kib.kiev.ua> Date: Fri, 7 Dec 2012 11:35:30 +0530 Message-ID: Subject: Re: ELF symtab and ddbsymtab difference From: Shrikanth Kamath To: Konstantin Belousov Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2012 06:05:32 -0000 Thanks Konstantin, yeah I think there were two levels of strip happening, one removing the debug sections and another was removing the .strtab and .symtab. I have EXPORT_SYMS = YES in my Makefile but that was not helping as the variables in context are declared static (they are going into the .bss). Making it un-static helps or avoiding the second level strip helps too.. -- Shrikanth R K On Fri, Dec 7, 2012 at 4:41 AM, Konstantin Belousov wrote: > On Wed, Dec 05, 2012 at 12:13:24PM +0530, Shrikanth Kamath wrote: >> This is regarding the fields in the structure "elf_file_t" in link_elf.c. >> For some kernel modules the symtab field is different from the ddbsymtab >> field for some it is the same, would like to know what is the difference >> between the two and how to enable ddbsymtab? > Assuming we are talking about the link_elf.c and not about link_elf_obj.c. > The symtab and ddbsymtab are first initialized from the dynamic symbol > table in the module, and later, in the process of loading the module, if > the non-dynamic symbol table is present, ddbsymtab is rewritten to point > to the table. > >> >> Does enabling "-g" in CFLAGS make the binary build the ddbsymtab different >> from symtab? > No. It is strip done on the module which could result in the removal of the > non-dynamic symtab. > >> >> The problem is lookup for some symbols in the kernel module that I built >> returns with undefined, on inspecting it was getting a ENOENT from the >> function >> link_elf_lookup_symbol() >> { >> ... >> /* If we have not found it, look at the full table (if loaded) */ >> if (ef->symtab == ef->ddbsymtab) >> return (ENOENT); >> ... >> } > > It is not the problem. It just means that you dynamic symbol table does > not contain the needed symbol, which is the problem. As a coincident, > you also stripped your module, making the problem to be exposed. > > I guess that you should look at the EXPORT_SYMS feature of the module > Makefiles. But I also remember there were some bugs.