> x0152532@unx0152532:~/mydroid$ readelf --segments ./linker
>
> Elf file type is EXEC (Executable file)
> Entry point 0xb0001000
> There are 5 program headers, starting at offset 52
>
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x0000d4 0x00000000 0xb0000000 0x00000 0x00000 R 0x1000
> LOAD 0x001000 0xb0001000 0xb0001000 0x073bc 0x073bc R E 0x1000
> LOAD 0x009000 0xb0009000 0xb0009000 0x0068c 0x0969c RW 0x1000
OK, so there are TWO bugs, one in the construction of ./linker
and one in valgrind's load_ELF(). The Phdr for an empty region (0==.p_memsz):
LOAD 0x0000d4 0x00000000 0xb0000000 0x00000 0x00000 R 0x1000
is a bug in the construction of ./linker because it is a waste of space.
Empty regions occur _EVERYWHERE_, no one needs to be told about them.
And it isn't even aligned properly: .p_align should divide (.p_vaddr -
.p_offset).
If you want a one-page "guard" hole with no access allowed, then:
LOAD 0x000000 0xb0000000 0xb0000000 0x00000 0x01000 0x1000
Note that .p_flags is 0 (no PF_X, no PF_R, no PF_W) and .p_align does divide
(.p_vaddr - .p_offset), and that .p_vaddr==.p_paddr because there is no reason
for them to differ.
However, because of the stupidity in ./linker, then load_ELF() must defend
itself
by ignoring empty regions:
if (iph->p_type != PT_LOAD
|| iph->p_memsz == 0) /* ignore empty PT_LOAD */
continue;
--
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users