0

In a C application, I want to place a big buffer at an address after the variables, stack and dma address ranges. Of course I can define a section in the wanted location in the linker script and declare a big array in C and give a section attribute to the array. But I want to do it without actually declaring the big array because it makes the executable too big. I want to use the array address to do the same.
I'm using gcc and try to use an address I define in the linker script inside the C source file.
Here is how I tried it.
in the linker script file (which is ldabtsm.lds.S in my case),

...
    . = ALIGN(16777216);
    .vimbuffs : {
        *(.vimbuffs)
    }
    vimbuffs = .;
...

I tried using vimbuffs in the C source file.
So I did (if I can print, I can use it anyway..)

extern unsigned int vimbuffs; // from linker script
printf("vimbuffs = %x\n", vimbuffs); 

From the map file, I can see the vimbufs is assigned to 0x3b3f6000 which is just right, I want it to be aligned. But when run the program and print the value, I see

vimbuffs = a07f233d

What is wrong?

Chan Kim
  • 5,177
  • 12
  • 57
  • 112

0 Answers0