Alfred Peng wrote:

>     The option "-M /usr/lib/ld/map.noexstk" has been added to the build
> configuration, and the content of the file map.noexstk is "stack = STACK
> ?RW;". I just wonder whether there is a way for me to test the function
> after building successfully?

This mapfile creates a program header that tells the kernel that
the process requires a non-executable stack.  You can see this from
the read/write access, but no execute access, assigned to the
program header:

% cc -o main main.c -M/usr/lib/ld/map.noexstk
% elfdump -p main | tail -6

Program Header[5]:
     p_vaddr:      0               p_flags:    [ PF_W  PF_R ]
     p_paddr:      0               p_type:     [ PT_SUNWSTACK ]
     p_filesz:     0               p_memsz:    0
     p_offset:     0               p_align:    0

You can use ptools on the application to verify the stacks
accessibility:

% truss -Texit ./main
.......
% pmap -x 184337
184337: ./main
  Address  Kbytes     RSS    Anon  Locked Mode   Mapped File
00010000       8       8       -       - r-x--  main
00020000       8       8       8       - rwx--  main
........
FFBFE000       8       8       8       - rw---    [ stack ]


-- 
Rod

Reply via email to