<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><br>Thanks Prabhunath!<br><br>The following is section header table:<br>==============================<br> readelf -S /bin/cat <br><br>There are 28 section headers, starting at offset 0xb260:<br><br>Section Headers:<br> [Nr] Name Type Addr Off Size ES Flg Lk Inf Al<br> [ 0] NULL 00000000 000000 000000 00 0 0 0<br> [ 1] .interp PROGBITS 08048154 000154 000013 00 A 0 0 1<br> [ 2] .note.ABI-tag NOTE 08048168 000168 000020 00 A 0 0 4<br> [ 3] .note.gnu.build-i NOTE 08048188 000188 000024 00 A 0 0 4<br> [ 4] .gnu.hash GNU_HASH 080481ac 0001ac 000044 04 A 5 0 4<br> [ 5] .dynsym DYNSYM 080481f0 0001f0 0004e0 10 A 6 1 4<br> [ 6] .dynstr STRTAB 080486d0 0006d0 000349 00 A 0 0 1<br> [ 7] .gnu.version VERSYM 08048a1a 000a1a 00009c 02 A 5 0 2<br> [ 8] .gnu.version_r VERNEED 08048ab8 000ab8 000090 00 A 6 1 4<br> [ 9] .rel.dyn REL 08048b48 000b48 000030 08 A 5 0 4<br> [10] .rel.plt REL 08048b78 000b78 000228 08 A 5 12 4<br> [11] .init PROGBITS 08048da0 000da0 000024 00 AX 0 0 4<br> [12] .plt PROGBITS 08048dd0 000dd0 000460 04 AX 0 0 16<br> [13] .text PROGBITS 08049230 001230 006f2c 00 AX 0 0 16<br> [14] .fini PROGBITS 0805015c 00815c 000015 00 AX 0 0 4<br> [15] .rodata PROGBITS 08050180 008180 000e86 00 A 0 0 32<br> [16] .eh_frame_hdr PROGBITS 08051008 009008 0002d4 00 A 0 0 4<br> [17] .eh_frame PROGBITS 080512dc 0092dc 000d30 00 A 0 0 4<br> [18] .init_array INIT_ARRAY 08053f04 00af04 000004 00 WA 0 0 4<br> [19] .fini_array FINI_ARRAY 08053f08 00af08 000004 00 WA 0 0 4<br> [20] .jcr PROGBITS 08053f0c 00af0c 000004 00 WA 0 0 4<br> [21] .dynamic DYNAMIC 08053f10 00af10 0000e8 08 WA 6 0 4<br> [22] .got PROGBITS 08053ff8 00aff8 000008 04 WA 0 0 4<br> [23] .got.plt PROGBITS 08054000 00b000 000120 04 WA 0 0 4<br> [24] .data PROGBITS 08054120 00b120 00003c 00 WA 0 0 4<br> [25] .bss NOBITS 08054160 00b15c 0005c4 00 WA 0 0 32<br> [26] .gnu_debuglink PROGBITS 00000000 00b15c 000008 00 0 0 1<br> [27] .shstrtab STRTAB 00000000 00b164 0000fc 00 0 0 1<br>Key to Flags:<br> W (write), A (alloc), X (execute), M (merge), S (strings)<br> I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)<br> O (extra OS processing required) o (OS specific), p (processor specific)<br>==============================<br><br>But, according the kernel elf loader :<br><br>linux-3.7.4/fs/binfmt_elf.c:<br>static int load_elf_binary(...)<br>{<br> ...<br> for(i = 0, elf_ppnt = elf_phdata;<br> i < loc->elf_ex.e_phnum; i++, elf_ppnt++) {<br> ...<br> if (elf_ppnt->p_type != PT_LOAD)<br> continue;<br> ...<br>}<br><br>The kernel elf loader just load PT_LOAD segment, but GNU_RELRO is not PT_LOAD type ?<br><br>At 2013-03-07 18:53:46,"Prabhu nath" <gprabhunath@gmail.com> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Looks like they have added a new section GNU_RELRO in the later versions. The one you are referring is read-only section. It would be nice if you share the section header table. <br>Plz see inline<br><br clear="all"><div>Regards,<br>
Prabhunath G<br>Linux Trainer<br>Bangalore<br></div>
<br><br><div class="gmail_quote">On Thu, Mar 7, 2013 at 3:31 PM, Jacky <span dir="ltr"><<a href="mailto:jackyclivia@163.com" target="_blank">jackyclivia@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-height:1.7;font-size:14px;font-family:arial">Dear all,<br><br>This is the Program Header for "cat" info:<br><br>================================<br>readelf -l /bin/cat <br>...<br>Program Headers:<br>
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align<br> PHDR 0x000034 0x08048034 0x08048034 0x00120 0x00120 R E 0x4<br> INTERP 0x000154 0x08048154 0x08048154 0x00013 0x00013 R 0x1<br>
[Requesting program interpreter: /lib/ld-linux.so.2]<br> LOAD 0x000000 0x08048000 0x08048000 0x0a00c 0x0a00c R E 0x1000<br> LOAD 0x00af04 0x08053f04 0x08053f04 0x00258 0x00820 RW 0x1000<br> DYNAMIC 0x00af10 0x08053f10 0x08053f10 0x000e8 0x000e8 RW 0x4<br>
NOTE 0x000168 0x08048168 0x08048168 0x00044 0x00044 R 0x4<br> GNU_EH_FRAME 0x009008 0x08051008 0x08051008 0x002d4 0x002d4 R 0x4<br> GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4<br>
GNU_RELRO 0x00af04 0x08053f04 0x08053f04 0x000fc 0x000fc R 0x1<br>==============================<br><br>So there are just 2 PT_LOAD segments. But why kernel maps 3 memory regions ? The following is the maps output:<br>
<br></div></blockquote><div>Though the second PT_LOAD starts at the file offset 0xaf04, The first fc bytes belong to GNU_RELRO segment (The last entry in the Program Header). If you add af04 +fc you get afff. Looks like they have placed this section advertently in such a way that the actual DATA segment will start at the next virtual address page boundary 0x08054000. Thus the GNU_RELRO section with read-only permissions is placed in the separate virtual address region. <br>
This is the result of the maps file you see below. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;font-size:14px;font-family:arial">
============================<br>cat /proc/self/maps <br><br>08048000-08053000 r-xp 00000000 08:01 261656 /bin/cat<br>08053000-08054000 r--p 0000a000 08:01 261656 /bin/cat<br>08054000-08055000 rw-p 0000b000 08:01 261656 /bin/cat<br>
09b58000-09b79000 rw-p 00000000 00:00 0 [heap]<br>b75bd000-b75be000 rw-p 00000000 00:00 0 <br>b75be000-b7761000 r-xp 00000000 08:01 523958 /lib/i386-linux-gnu/<a href="http://libc-2.15.so" target="_blank">libc-2.15.so</a><br>
...<br>==================<br><br>The above output, there are 3 memory regions for "/bin/cat", and what is the following segment:<br><br>08053000-08054000 r--p 0000a000 08:01 261656 /bin/cat<br><br>According the 'cat' program header, there is no "r" segment.<br>
<br><br>Regards,<br>Jacky<br><br><br> <br><br><br><br><br><br><br></div><br><br><span title="neteasefooter"><span></span></span><br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br>
</blockquote></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>