Generating PIC or nonabsolute OMF51

Hello,

I have two separate questions:
1) I was wondering whether the Keil C51 compiler can generate Position Independent Code. Perhaps, if I build a program as a library, would the generated object code be position independent? By PIC, I mean that all jumps would be Program Counter-relative rather than absolute.

2) Can the C51 generate OMF51 Object code rather than Absolute OMF51 object code? If I write a program with unresolved external references, would the linker abort as soon as it realizes that these references cannot be linked or would it resolve as much as it can and generate object code with 'dangling' unresolved symbols? If so, would the OMF51 file list these unresolved symbols such that a dynamic loader can patch them at runtime?

Thanks,
Umar

Parents
  • The Keil C51 compiler and A51 assembler generate OMF-51 object modules which are relocatable object modules (in other words, they are non-absolute). The linker relocates them to reside (and execute) from any address in CODE memory and this is what makes the final output from the linker an absolute object module.

    With regards to position independent code, this implies to me that the code can be changed after linkage. And, that's not the case with our tools. In fact, I don't know of any 8051 tools that can do that or that offer that as a feature. I guess it's possible to search and replace targets of jumps and calls. However, many 8051 applications don't rely exclusively on these instructions to branch to a new address.

    With regards to Program Counter-relative addressing, there is no such addressing mode on the 8051. So, this would have to be done through some kind of function call.

    Can the C51 generate OMF51 Object code rather than Absolute OMF51 object code?

    It already does that.

    If I write a program with unresolved external references, would the linker abort as soon as it realizes that these references cannot be linked or would it resolve as much as it can and generate object code with 'dangling' unresolved symbols?

    The linker would link the entire program and would output all errors/warnings it encountered.

    If so, would the OMF51 file list these unresolved symbols such that a dynamic loader can patch them at runtime?

    The absolute OMF51 object module format is just that - it's absolute. It does not include any fixup information about external symbols. However, this information is available in the listing file generated by the linker.

    Just what kind of dynamic loader did you have in mind? Is this something you are writing yourself or have you found an existing commercial product? If you have found a product that claims to be able to do this, why don't you ask them how it all works?

    Jon

Reply
  • The Keil C51 compiler and A51 assembler generate OMF-51 object modules which are relocatable object modules (in other words, they are non-absolute). The linker relocates them to reside (and execute) from any address in CODE memory and this is what makes the final output from the linker an absolute object module.

    With regards to position independent code, this implies to me that the code can be changed after linkage. And, that's not the case with our tools. In fact, I don't know of any 8051 tools that can do that or that offer that as a feature. I guess it's possible to search and replace targets of jumps and calls. However, many 8051 applications don't rely exclusively on these instructions to branch to a new address.

    With regards to Program Counter-relative addressing, there is no such addressing mode on the 8051. So, this would have to be done through some kind of function call.

    Can the C51 generate OMF51 Object code rather than Absolute OMF51 object code?

    It already does that.

    If I write a program with unresolved external references, would the linker abort as soon as it realizes that these references cannot be linked or would it resolve as much as it can and generate object code with 'dangling' unresolved symbols?

    The linker would link the entire program and would output all errors/warnings it encountered.

    If so, would the OMF51 file list these unresolved symbols such that a dynamic loader can patch them at runtime?

    The absolute OMF51 object module format is just that - it's absolute. It does not include any fixup information about external symbols. However, this information is available in the listing file generated by the linker.

    Just what kind of dynamic loader did you have in mind? Is this something you are writing yourself or have you found an existing commercial product? If you have found a product that claims to be able to do this, why don't you ask them how it all works?

    Jon

Children
More questions in this forum