22 22 votes 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? $0, 200, 500, 600$ $0, 200, 1000, 1600$ $200, 500, 600, 800$ $200, 700, 1300, 2100$ Compiler Design gate1998 compiler-design runtime-environment normal + – Kathleen 8.6k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 34 34 votes answer - Bfirst module loaded starting at address $0$. Size is $200$. hence it will occupy first $200$ address (last address being $199$). Second module will be present from $200$ and so on. ankitrokdeonsns answered Nov 23, 2014 • edited Aug 26, 2024 by shadymademe ankitrokdeonsns comment Share Follow See all 6 Comments 6 6 Comments reply ankitrokdeonsns commented Apr 24, 2015 reply Follow flag 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 0 replyShare pass_i0n commented Sep 18, 2018 reply Follow flag Can you explain it more clearly ?? 0 0 replyShare Ayush Upadhyaya commented Nov 2, 2018 reply Follow flag 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. So, answer is (B) 16 16 replyShare jatin khachane 1 commented Nov 16, 2018 reply Follow flag @Ayush+Upadhyaya 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 :( 1 1 replyShare tusharp commented Nov 23, 2018 reply Follow flag 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 0 replyShare tusharp commented Nov 23, 2018 reply Follow flag 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. 0 0 replyShare Please log in or register to add a comment.
3 3 votes Module 1 (Length: 200 words): Starting Address: 0 (No preceding modules) Module 2 (Length: 800 words): Starting Address: 200 (Length of Module 1) Module 3 (Length: 600 words): Starting Address: 1000 (Sum of lengths of Modules 1 and 2) Module 4 (Length: 500 words): Starting Address: 1600 (Sum of lengths of Modules 1, 2, and 3) Therefore, the relocation constants for each module are as follows: Module 1: 0 Module 2: 200 Module 3: 1000 Module 4: 1600 rajveer43 answered Dec 30, 2023 rajveer43 comment Share Follow 0 reply Please log in or register to add a comment.