Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get a pointer to the .text section?

Tags:

c

embedded

How do you get a pointer to the .text section of memory for a program from within that program? I also need the length of the section to do a "Flash to Memory" compare as part of a continuous selftest that runs in the background.

The toolset automatically generates the linker .cmd file for the tools I'm using, and the Board Support Package for the board I'm using requires I use the generated .cmd file instead of making my own. (No make file either to add a script to muck with it afterwords.)

Edit: I'm working with a TI TMS 6713 DSP using the code composer 3.1 environment. The card I'm using was contracted by our customer and produced by another organization so I can't really point you to any info on it. However the BSP is dependant upon TI's "DSP BIOS" config tool, and I can't really fudge the settings too much without digging into an out of scope effort.

like image 575
NoMoreZealots Avatar asked Oct 14 '08 19:10

NoMoreZealots


1 Answers

You need to put "variables" in the linker script.

In one of my projects I have this in one of my sections:

  __FlashStart = .;

In the C program I have this:

extern unsigned long int _FlashStart;
unsigned long int address = (unsigned long int)&_FlashStart;
like image 104
Robert Avatar answered Oct 27 '22 08:10

Robert