18 votes 18 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 asked Sep 25, 2014 edited Dec 12, 2017 by kenzou Kathleen 5.8k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 27 votes 27 votes answer - B 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. ankitrokdeonsns answered Nov 23, 2014 edited Dec 12, 2017 by kenzou ankitrokdeonsns comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments jatin khachane 1 commented Nov 16, 2018 reply Follow Share @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 :( 0 votes 0 votes tusharp commented Nov 23, 2018 reply Follow Share 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 votes 0 votes tusharp commented Nov 23, 2018 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.
0 votes 0 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 See all 0 reply Please log in or register to add a comment.