From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 29 08:58:27 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 BE4DF1065672 for ; Wed, 29 Sep 2010 08:58:27 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0DA5A8FC2D for ; Wed, 29 Sep 2010 08:58:26 +0000 (UTC) Received: from porto.topspin.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id LAA22107; Wed, 29 Sep 2010 11:58:23 +0300 (EEST) (envelope-from avg@icyb.net.ua) Received: from localhost.topspin.kiev.ua ([127.0.0.1]) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1P0sUZ-0003FR-6X; Wed, 29 Sep 2010 11:58:23 +0300 Message-ID: <4CA2FFAE.6030906@icyb.net.ua> Date: Wed, 29 Sep 2010 11:58:22 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.9) Gecko/20100918 Lightning/1.0b2 Thunderbird/3.1.4 MIME-Version: 1.0 To: PL References: <4ca2f64ee66683.99262397@wp.pl> In-Reply-To: <4ca2f64ee66683.99262397@wp.pl> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: question regarding link_elf.c 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: Wed, 29 Sep 2010 08:58:27 -0000 on 29/09/2010 11:18 PL said the following: > Hi everyone, > I'm not quiet sure if it is proper place to ask the question I have. If > not, please > direct me to the correct place I should post questions like: > > Im working on some modifications around link_elf.c. According to elf(5) > man pages, > Elf_Shdr structure contains field called 'sh_addr', containing the > address at > which first byte of a section shall reside in the memory image. I am > particularily > interested in '.text' and '.data' sections. After link_elf_load_file() > loads the > file into a memory, we have linker_file structure filled in, including > 'address' > field. Now, assuming 'lf' being linker_file_t, already filled in by the > loading > routine, 'text_sh' being 'Elf_Shdr' for text section, and 'data_sh' > being 'Elf_Shdr' > for data section: > - lf->address + text_sh.sh_addr really points to the beginning of a > '.text' section > in memory, however.. > > - lf->address + data_sh.sh_addr does not point to the valid location of > '.data' section > in memory. > > Sorry if my question is stupid, but im wondering why it is so ? I guess > it has something > to do with virtual memory mapping (?). Perhaps the reason is simpler, like a bug in your code :-) You can do 'readelf -a' on a module that you load and check attributes of .data section and then compare with data_sh that you get at run-time. -- Andriy Gapon