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

C runtime environment setup by "#pragma asm"

I am checking some terrible C source code; I haven't got any idea about how to maintain it or cooperate with it. But I found a very fundamental problem. It does NOT have a startup.asm; it has a startup.c using the powerful C extension "#pragma". So, the C runtime environment is setup by "#pragma section", "#pragma intvect", "#pragma asm". I quite worry about such a startup.c; so I contacted the FAE of our local distributor. The FAE is an experienced good engineer, but he told me that, this is not their standard way to setup C runtime environment; they definitely provided the startup.s from Day 1.

What will be the side-effect, when the C runtime environment is setup by the C extension "#pragma"?

Parents
  • Don't you have access to an assembler startup file for the used compiler?

    If we ignore potential timing issues, a comparison of that startup file with the code you have should be able to tell if the current code does try to recreate all steps performed by the compiler-supplied startup file.

    Next step - if they do mix actual C code during their startup sequence - is to figure out if the calling conventions are correct, and stack etc are already correctly configured before first C function is used.

    Next step is to check when the C RTL gets initialized, and if any C RTL functions might have been called before this has happened. Lack of source code for the C RTL means that it will be impossible to know the full set of requirements that needs to be fulfilled for each individual C RTL function.

Reply
  • Don't you have access to an assembler startup file for the used compiler?

    If we ignore potential timing issues, a comparison of that startup file with the code you have should be able to tell if the current code does try to recreate all steps performed by the compiler-supplied startup file.

    Next step - if they do mix actual C code during their startup sequence - is to figure out if the calling conventions are correct, and stack etc are already correctly configured before first C function is used.

    Next step is to check when the C RTL gets initialized, and if any C RTL functions might have been called before this has happened. Lack of source code for the C RTL means that it will be impossible to know the full set of requirements that needs to be fulfilled for each individual C RTL function.

Children
No data