Re: questions in linux process memory management

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 05, 2003 at 06:10:22PM -0800, kernel rakshakudu wrote:
> I have following questions regrading linux process memory management. 
> 
> 1) Can a process modify its own text region(code). 

No, cause it is mapped read-only.

> 2)Can a process have two different pages (in linear address space)
> that are allocated same frame.

I think I don't understand your question. A process can have a single
physical page mapped at two different virtual locations in its address
space. Mapping a single virtual page to two different physical pages is
inpossible.

> 3) Process reads its text region for intructions to execute. But Is
> there an occasion when a process reads data from its text region ??

Sure:

int foo(int bar)
{
	return bar+1;
}

int main(void)
{
	unsigned int *gnu = (unsigned int *)foo;

	printf("foo() is at 0x%08x and has value 0x%08x\n",
		(unsigned int)gnu, *gnu);

	return 0;
}

Which on my system prints:

foo() is at 0x080483f0 and has value 0x8be58955

Put *gnu = 0 in it, and the program will die because of a segfault: you
can't write the text section.


Erik

-- 
J.A.K. (Erik) Mouw
Email: J.A.K.Mouw@its.tudelft.nl  mouw@nl.linux.org

Attachment: pgp00292.pgp
Description: PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux