verma wrote:
> Dear ALl,
> Could any one help me to sort out my doubt about executable build in solaris 
> using gcc as well as cc.
> 
> #cc -o main main.c
> #elfdump -pN PT_LOAD ./main
> 
> Program Header[2]:
>     p_vaddr:      0x8050000   p_flags:    [ PF_X PF_R ]
>     p_paddr:      0           p_type:     [ PT_LOAD ]
>     p_filesz:     0x8cc       p_memsz:    0x8cc
>     p_offset:     0           p_align:    0x10000
> 
> Program Header[3]:
>     p_vaddr:      0x80608cc   p_flags:    [ PF_X PF_W PF_R ]
>     p_paddr:      0           p_type:     [ PT_LOAD ]
>     p_filesz:     0x158       p_memsz:    0x174
>     p_offset:     0x8cc       p_align:    0x10000
> 
> data segment permission is given 
> p_flags:    [ PF_X PF_W PF_R ]
> 
> why this is given execute permission to data segment.I think executable 
> permission should be only for text segment in executables.

As I said before:

 > The default data segment permissions for sparc and intel are PF_X PF_W PF_R.
 > The default data segment permissions for amd64 is PF_W PF_R.  These are
 > defined by their ABI's.

It's a standards thing.  Note, the sparc family need an executable data
segment as this is where the .plt's reside, which are rewritten at
runtime.  Intel doesn't need execute permission, but the forefathers
that defined the ABI missed this point (I think).

-- 

Rod.

Reply via email to