[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] Compiler/linker problem (?)




Another piece of information:
If I use mb-objcopy to create a binary from the elf file, the array is not corrupted. So I think the problem is in the conversion from elf to binflat format.

Rod Campbell

Rod Campbell wrote:


Hi,

I've been using uClinux 2.4 on microblaze successfully for a few years. Just recently I ran into a problem that I wonder if anyone else has seen (and if anyone has any insights).

My uClinux program runs fine except for one problem. The symptom is that a pointer to a string (stored in an array of string pointers) is corrupted. Naturally I thought that I was just doing something goofy somewhere in my code. After checking it out, I found to my surprise that the corruption exists in the bflt executable itself.
The module code basically looks like this:

// many string arrays

char *strVals[14] =
 {"1+1 ", "1/0 ", "2/0 ", "3/0 ",
  "3/0L", "2/1 ", "2/1L", "3/1 ",
  "3/1L", "2/2 ", "2/2L", "3/2 ",
  "3/2L", "Pass"};

// more string arrays and other variables

const unsigned char PcmBypass = 8;
// start of functions

When I look at dump of the bflt exe, I see that in the array of pointers that is created for strVals[], the 5th pointer points to the storage area for PcmBypass instead of where "3/0L" is stored. I looked at the executable file while it was still in flash (not after being loaded into RAM for execution).

If I change the definition of PcmBypass to "unsigned char PcmBypass = 8; ", meaning I just remove the "const", it compiles and runs fine.

If I use mb-objdump to explore the elf file created by mb-gcc, I don't see any problems - I see the array of strVals[] pointers and they look correct.

I compiled and ran an earlier version of the program and saw the same type of problem; the only difference was that the PcmBypass pointer clobbered a pointer in a different array.

I reference the variable PcmBypass in code only once, and that is in the same file that it is defined in. There are no "extern unsigned char PcmBypass" statements.

The exe I create is made up of several files and the exe itself is large but by no means the largest I've built - about 180K bytes. I am using the stock microblaze-elf-tools-20060213 tools supplied with 2.4.32-uc0 uClinux.

Any insights would be appreciated.

Rod Campbell


___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/



___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/