Commit 12694df2 authored by desrt's avatar desrt
Browse files

[project @ 2005-12-15 23:32:29 by desrt]

(( PLEASE MERGE TO STABLE ))

Linker.c: linux/ppc: We call mmap() to allocate additional pages to
                     create jump islands.  In the case where no
                     additional memory was needed the mmap call was
                     being made with a size of 0 which would fail.
                     The call is now conditionalised and documentation
                     has been added to the code.  Closes trac #439.
parent 929f99ce
......@@ -1447,12 +1447,26 @@ static int ocAllocateJumpIslands( ObjectCode* oc, int count, int first )
n = ROUND_UP( oc->fileSize, pagesize );
m = ROUND_UP( aligned + sizeof (ppcJumpIsland) * count, pagesize );
/* If we have a half-page-size file and map one page of it then
* the part of the page after the size of the file remains accessible.
* If, however, we map in 2 pages, the 2nd page is not accessible
* and will give a "Bus Error" on access. To get around this, we check
* if we need any extra pages for the jump islands and map them in
* anonymously. We must check that we actually require extra pages
* otherwise the attempt to mmap 0 pages of anonymous memory will
* fail -EINVAL.
*/
if( m > n )
{
/* The effect of this mremap() call is only the ensure that we have
* a sufficient number of virtually contiguous pages. As returned from
* mremap, the pages past the end of the file are not backed. We give
* them a backing by using MAP_FIXED to map in anonymous pages.
*/
if( (oc->image = mremap( oc->image, n, m, MREMAP_MAYMOVE )) == MAP_FAILED )
oc->image = mremap( oc->image, n, m, MREMAP_MAYMOVE );
if( oc->image == MAP_FAILED )
{
errorBelch( "Unable to mremap for Jump Islands\n" );
return 0;
......@@ -1464,6 +1478,7 @@ static int ocAllocateJumpIslands( ObjectCode* oc, int count, int first )
errorBelch( "Unable to mmap( MAP_FIXED ) for Jump Islands\n" );
return 0;
}
}
#else
oc->image -= misalignment;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment