Hello cinap,

My experiment here.

void
main(int argc, char *argv[])
{       char *ap;
        char buf[1];
        ARGBEGIN{
        default: usage();
        }ARGEND
        
        ap = segattach(0,"share",0,1024);
        print("%p\n",ap);       // ffffffff  error

        /* compare */
        ap = sbrk(0);
        print("sbrk %p\n",ap);  // 6cb0
        ap += 2*1024*1024;
        print("%p\n",ap);       // 206cb0
        ap = segattach(0, "shared", ap, 1024);
        print("%p\n",ap);       // 206000

        read(0,buf,1);
}

we can find the allocated share memory:

term% cat /proc/612768/segment
Stack     defff000 dffff000    1
Text   R      1000     6000    1
Data          6000     7000    1
Bss           7000     7000    1
Shared      206000   207000    1
term% 

note that 0x206cb0 + 0x400 > 0x20700.
if we believe that we have a memory
of range [mp,mp+1024) by executing
mp = share(1024)
then we will fail.

Kenji Arisawa

2014/09/14 12:17、[email protected] のメール:

> it should round va down and va+len up as neccesary
> to make them page aligned. but the initial passed
> range should be covered by the created segment
> in any case.


Reply via email to