OpenSolaris

Discussions Communities Projects Download Source Browser

Home » OpenSolaris Forums » tools » linking

Thread: Question on an LD option "-M mapfile"

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 3 - Last Post: Oct 29, 2008 9:10 PM by: johnfred
Alfred Peng
Alfred.Peng@Sun.COM
Question on an LD option "-M mapfile"
Posted: Jan 4, 2006 8:07 PM

  Click to reply to this thread Reply

Hi there,

I'm a software engineer from the JDS browser group, and working on a
bug to add the non-execution stack function to Mozilla/Firefox.

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?

Thanks,

-Alfred

_______________________________________________
tools-linking mailing list
tools-linking at opensolaris dot org



rie

Posts: 295
From: US

Registered: 3/9/05
Re: Question on an LD option "-M mapfile"
Posted: Jan 4, 2006 10:22 PM   in response to: Alfred Peng

  Click to reply to this thread Reply

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
_______________________________________________
tools-linking mailing list
tools-linking at opensolaris dot org



Alfred Peng
Alfred.Peng@Sun.COM
Re: Question on an LD option "-M mapfile"
Posted: Jan 4, 2006 11:41 PM   in response to: rie

  Click to reply to this thread Reply

Your instructions work on the Firefox build I've got. And the
non-execution stack function has been enabled in Firefox.

Thanks,

-Alfred

Rod Evans wrote:
> 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 ]
>
>
>

_______________________________________________
tools-linking mailing list
tools-linking at opensolaris dot org



johnfred

Posts: 1
From:

Registered: 10/29/08
Re: Question on an LD option "-M mapfile"
Posted: Oct 29, 2008 9:10 PM   in response to: Alfred Peng
To: Communities » tools » linking
  Click to reply to this thread Reply

This website is very useful software engineers like me also.We can clarify our doubts about solaris in here.Thanks to this website.
================================

john

Link Building




Terms of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.
Copyright © 1995-2005 Sun Microsystems, Inc.