Foundationপ্রথম নীতি থেকে
LEVEL 5 · Compilers

Relocation

রিলোকেশন

Compiler/assembler 'এই ঠিকানা এখনো অজানা' লিখে placeholder+relocation entry রাখে; linker চূড়ান্ত address জানলে fix করে দেয়।

main.o:  call foo          → relocation R_X86_64_PLT32, addend -4
linker :  foo @ 0x401120   → call টা patch: 0x401120 − (pc+4)
  • Symbol resolution (foo কোথায়?) আর relocation (call instruction-এ সেই address বসানো) আলাদা ধাপ
  • Section-এর alignment/padding-এর কারণে final layout link ছাড়া জানা যায় না — তাই placeholder অনিবার্য
  • readelf -r main.o দিয়ে relocation table নিজের চোখে দেখুন
  • Dynamic linking-এ runtime relocation: load-time fixup, PIC-এ GOT indirection