Relocation in .obj -files
Originally replied by Salem to OS-indepedent stuff?
(Yes, with that inventive spelling by me)
You're right. I thought the reason it didn't work was just that I hadn't arranged for the "ORG 100h" that reserves the starting 256 bytes of the in-memory-image that DOS wants to use to contain the command line (and possibly other things) but examaning one with a disassembler proves that I was indeed wrong.
All the object file formats I know about contain a lot of relocation information as well. They're not simply "memory dumps" of the assembler code they represent.
But why does an .obj not passed through a linker contain relocation info? Musn't the OS add the current load point to each memory accessing instruction anyway?
Or does a relocatable program contain an initial where-am-I-loaded-at OS-call and then code that adds that variable/registry value to/before each memory accessing instruction (so this don't have to be arranged at load time)?