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

C51, Linker, list of variables as pile up in memory

Hi

I found a bug in my code, a for was out of range and overwriting the variables after the wanted one.

i.e.
uint8_t xdata globalMyVar[4];

for ( ii = 0; ii < 20; ii++ )
{ globalMyVar[ii] = 0;
}

So I wanted to look which were these overwritten variables.
For that I checked the file generated by the linker (.M51) with the symbols information
My application has several modules.
The symbol(s) table(s) produced is not well adapted for a quick look on how variables are piled up in memory.

What I did was to cut and paste all the modules symbols information in excel, with fixed columns for the address value, type and name then sort by address value.

I couldn't find a switch for the linker to obtain this kind of sorted list.
Btw I noted that the memory pile-up is not as declared in the source code, nor alphabetic (some internal hash used for optimization?).

Is there a better way to get the sorted list of variables as they are defined in memory? (than sorting via excel)

Regards
Daniel

Parents
  • To make a long explanation short, I wrote my first program 36 years ago (yes, 1982) and along all of these years I found myself bugs even in compilers, in the hardware (processors, coprocessors, logic, fpga, cplds, etc..) also after doing several reviews I'm never 100% sure there is something like bug free.
    Your statement sounds strong for me, may be with time you'll learn that the only thing we can do is to reduce the risk the better we can but not to eliminate it ...

    I think that there are other things that give software/firmware/hardware a bad name but this is to discuss with another cup of coffee...

    Regards
    Daniel

Reply
  • To make a long explanation short, I wrote my first program 36 years ago (yes, 1982) and along all of these years I found myself bugs even in compilers, in the hardware (processors, coprocessors, logic, fpga, cplds, etc..) also after doing several reviews I'm never 100% sure there is something like bug free.
    Your statement sounds strong for me, may be with time you'll learn that the only thing we can do is to reduce the risk the better we can but not to eliminate it ...

    I think that there are other things that give software/firmware/hardware a bad name but this is to discuss with another cup of coffee...

    Regards
    Daniel

Children
No data