1.9k views

A linker reads four modules whose lengths are $200, 800, 600$ and $500$ words, respectively. If they are loaded in that order, what are the relocation constants?

1. $0, 200, 500, 600$
2. $0, 200, 1000, 1600$
3. $200, 500, 600, 800$
4. $200, 700, 1300, 2100$

edited | 1.9k views

first module loaded starting at address $0$. Size is $200$. hence it will occup first $200$ address last address being $199$. Second module will be present from $200$ and so on.

by Loyal (8.6k points)
edited by
0
first module loaded starting at address 0. Size is 200. hence it will occup first 200 address last address being 199. Second module will be present from 200 and so on
0
Can you explain it more clearly ??
+3

 Module Number Base Limit 1 0 200 2 200 800 3 1000 600 4 1600 500

So, if my program wants to access byte 'x' in module 3, so address that needs to be accessed will be computed as Base(1000)+(x-1)=999+x Byte number.

And, if suppose I try to access Byte 600 in module 3,

$600 \not \lt600(limit)$, a trap to the O.S. will be generated.

0

Is it always the case that ..linker will place module 2 after module 1 ..then module 3 after module 2

(Here I mean module -> Object code(.o) )

What if it place module 2 before 1...?? m confused now :(

0

If they are loaded in that order

@jatin khachane 1  it is mentioned. Otherwise linker will ask OS for free slot in memory and suppose OS provides address x then in base register of that module x will be stored and relative addresses will be converted to absolute accordingly.

0

What if it place module 2 before 1...??

Yes it is possible. But during program execution MMU will take care of it using page tables.