From: John Speth on 11 May 2010 13:40 Hi folks- I'm building a NIOS2 project which uses GCC tools and I'd like to write a C function that needs to know the stack top and stack bottom pointers at runtime. What is the GCC method for getting the stack top and bottom pointers at runtime? Thanks, John Speth. --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Tim Wescott on 11 May 2010 13:46 John Speth wrote: > Hi folks- > > I'm building a NIOS2 project which uses GCC tools and I'd like to write a C > function that needs to know the stack top and stack bottom pointers at > runtime. > > What is the GCC method for getting the stack top and bottom pointers at > runtime? > > Thanks, John Speth. Different, depending on version and startup code. The first place that I'd look would be the linker command file (something_or_other.ld) -- if you're lucky they'll be called something like __stack_top and __stack_bottom. Failing that, look in the map file from your link for things called "stack". Failing that, grep. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
From: John Speth on 11 May 2010 13:56 >> What is the GCC method for getting the stack top and bottom pointers at >> runtime? > The first place that I'd look would be the linker command file > (something_or_other.ld) -- if you're lucky they'll be called something > like __stack_top and __stack_bottom. Failing that, look in the map file > from your link for things called "stack". Failing that, grep. You're right but it needs to be a run time operation. John Speth. --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Andrew Jackson on 11 May 2010 14:15 > I'm building a NIOS2 project which uses GCC tools and I'd like to write a C > function that needs to know the stack top and stack bottom pointers at > runtime. > > What is the GCC method for getting the stack top and bottom pointers at > runtime? It's probably going to depend on what the crt0.s file you are linking against does. (You could disassemble that with objdump to see what symbols get used then write the appropriate code.) Andrew
From: Grant Edwards on 11 May 2010 14:22 On 2010-05-11, John Speth <johnspeth(a)yahoo.com> wrote: >>> What is the GCC method for getting the stack top and bottom pointers at >>> runtime? > >> The first place that I'd look would be the linker command file >> (something_or_other.ld) -- if you're lucky they'll be called something >> like __stack_top and __stack_bottom. Failing that, look in the map file >> from your link for things called "stack". Failing that, grep. > > You're right but it needs to be a run time operation. Oh for pete's sake: extern char __stack_top, __stack_bottom; [...] printf("Stack top = %p, bottom = %p\n",&__stack_top,&__stack_bottom); -- Grant Edwards grant.b.edwards Yow! I appoint you at ambassador to Fantasy gmail.com Island!!!
|
Next
|
Last
Pages: 1 2 3 4 Prev: Seeking TAS151 Manual desperately Next: How to find memory data width (x16 or x32?) |