Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jun 2001 17:53:50 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        hackers@freebsd.org
Cc:        milunovic@sendmail.ru
Subject:   Re: ELF p_offset & p_vaddr
Message-ID:  <200106090053.f590roD50858@vashon.polstra.com>
In-Reply-To: <Pine.BSF.4.21.0106082028430.1244-100000@scorpion.cosmos.all.net>
References:  <Pine.BSF.4.21.0106082028430.1244-100000@scorpion.cosmos.all.net>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <Pine.BSF.4.21.0106082028430.1244-100000@scorpion.cosmos.all.net>,
milunovic  <milunovic@sendmail.ru> wrote:
> 
> I'm little confused.I'm reading ELF specification and I found that
> p_offset and p_vaddr should be congrunet to module PAGE_SIZE.
> So is this correct ? If it isn't can anybody tell me what is correct.

It is correct.  It is done that way so that the file can be loaded
into memory simply by mapping it.  Mapping occurs on page boundaries.

> #define PAGE_SIZE 4096 
> p_offset % PAGE_SIZE == p_vaddr % PAGE_SIZE 

Yes, that's correct.  For example, notice that the final 3 digits are
the same here in the "VMA" and "File off" columns.  PAGE_SIZE == 4096
== 0x1000.

    blake$ objdump -h /usr/bin/id

    /usr/bin/id:     file format elf32-i386

    Sections:
    Idx Name          Size      VMA       LMA       File off  Algn
      0 .interp       00000019  080480f4  080480f4  000000f4  2**0
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      1 .note.ABI-tag 00000018  08048110  08048110  00000110  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      2 .hash         000000d8  08048128  08048128  00000128  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      3 .dynsym       00000230  08048200  08048200  00000200  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      4 .dynstr       00000138  08048430  08048430  00000430  2**0
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      5 .rel.bss      00000010  08048568  08048568  00000568  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      6 .rel.plt      00000098  08048578  08048578  00000578  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      7 .init         0000000b  08048610  08048610  00000610  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      8 .plt          00000140  0804861c  0804861c  0000061c  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      9 .text         00000928  0804875c  0804875c  0000075c  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
     10 .fini         00000006  08049084  08049084  00001084  2**2
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
     11 .rodata       0000035a  080490a0  080490a0  000010a0  2**5
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
     12 .data         0000000c  0804a3fc  0804a3fc  000013fc  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     13 .eh_frame     00000004  0804a408  0804a408  00001408  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     14 .ctors        00000008  0804a40c  0804a40c  0000140c  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     15 .dtors        00000008  0804a414  0804a414  00001414  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     16 .got          00000058  0804a41c  0804a41c  0000141c  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     17 .dynamic      00000088  0804a474  0804a474  00001474  2**2
                      CONTENTS, ALLOC, LOAD, DATA
     18 .bss          00000130  0804a4fc  0804a4fc  000014fc  2**3
                      ALLOC
     19 .comment      000000c8  00000000  00000000  000014fc  2**0
                      CONTENTS, READONLY
     20 .note         00000050  00000000  00000000  000015c4  2**0
                      CONTENTS, READONLY

John
-- 
  John Polstra                                               jdp@polstra.com
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106090053.f590roD50858>