kernelsec09
March 13th, 2009, 07:01 PM
When a program is loaded into memory (after running it from command line, say),
1. How does the Linux loader (ld) map the code segment to memory?
2. For example, the size of the code segment size is 6MB.
How many pages it creates?
3. Does the i'th page start at codeseg+(i-1)*pagesize; i.e., first page starts at 0 (contains data in 0 to pagesize-1), second page at pagesize and contains pagesize to 2*pagesize-1 and so on. If not, how does it work?
4. Does the first page starts with the first instruction to be executed? Is that the beginning of main()?
5. Consider an instruction in the binary: OPCODE OPND1 OPND2; If the memory mapping is such that OPCODE lies in page-i and "OPND1 OPND2" lies on page-(i+1), then is it a valid mapping? Or the loader maps the instruction into page-(i+1)?
1. How does the Linux loader (ld) map the code segment to memory?
2. For example, the size of the code segment size is 6MB.
How many pages it creates?
3. Does the i'th page start at codeseg+(i-1)*pagesize; i.e., first page starts at 0 (contains data in 0 to pagesize-1), second page at pagesize and contains pagesize to 2*pagesize-1 and so on. If not, how does it work?
4. Does the first page starts with the first instruction to be executed? Is that the beginning of main()?
5. Consider an instruction in the binary: OPCODE OPND1 OPND2; If the memory mapping is such that OPCODE lies in page-i and "OPND1 OPND2" lies on page-(i+1), then is it a valid mapping? Or the loader maps the instruction into page-(i+1)?