This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Segment names

In assembly code, it seems common to name segments using question marks. Such as, ?C_C51STARTUP, ?STACK, ?DT?MYFILE, etc. Is there a requirement to do this? If not, what is its purpose? I read TFM, and it says nothing.

Parents
  • "Is there a requirement to do this? If not, what is its purpose?"

    This is called 'name mangling', and one of its purposes is to avoid namespace conflict in the link stage.

    It also follows a naming convention that the C compiler adheres to, and is internally used by the compiler to describe the various memory allocation segments. If you need to write assembly functions to access C declared data objects, you can use the mangled segment names to map to C variables with proper memory type qualifiers.
    You can also declare data in ASM using the proper segment names and access those objects as C 'extern' variables, declared with the proper memory type qualifiers.

Reply
  • "Is there a requirement to do this? If not, what is its purpose?"

    This is called 'name mangling', and one of its purposes is to avoid namespace conflict in the link stage.

    It also follows a naming convention that the C compiler adheres to, and is internally used by the compiler to describe the various memory allocation segments. If you need to write assembly functions to access C declared data objects, you can use the mangled segment names to map to C variables with proper memory type qualifiers.
    You can also declare data in ASM using the proper segment names and access those objects as C 'extern' variables, declared with the proper memory type qualifiers.

Children
No data