tags:

views:

103

answers:

2

I have a RVDS project for a certain video decoder (its all C code), created for ARM926EJ-S target, executed using the RVDS 2.2 simulator. I am not using any scatterload / <configuration file> / <map file> to mention the various memory segments in the code like Stack segment, Heap, Data segment, Code Segment for RVDS Simulator environment.

  • When I add or comment some code (redundant/dead code), then compile the project and execute it, the decoder exits gracefully after mentioning that an error condition has occured , which should not have been the case, as the commented/added code is redundant and does not affect the functionality at all.
  • Now if i do the operation opposite to that done in 1.) i.e. uncomment code that was commented in step 1.) and compile and execute, the decoder works perfectly fine till its logically end.
  • Same C source/header files work in a MSVC workspace just fine.

I tried to debug a lot through this behaviour but i am not able to pinpoint the cause and the fix for it.

  • Is it a case of stack corruption as i add/remove code?
  • Is any segment getting overwritten, like Stack segment overflowing into the Data segment, or code segment overflowing into the Data segment?
A: 

I had something similar happen to a project I was working on. It ended up being a problem with referencing an un-initialized pointer on the stack. It would usually point to un-used program memory, and overwrite the code that wasn't being used.

When I removed unused code, suddenly it was pointing to memory that wasn't mine to modify, and it would exit ungracefully.

Double check your mallocs, and be sure about your function variable pointers!

Kieveli
A: 

Are you zero initializing the ZI section. I think that scatterload code in the runtime initialized the ZI section (my be not it's be awhile). We had a problem with the ZI section being initialized with some data left over from our program loader.

As a result changing any line in the code would cause it to crash at the same location. Even deleting code would cause a crash. I would verifythe ZI section is zero at the beginning of your program.

witkamp