Agnius Vasiliauskas
Agnius Vasiliauskas

Reputation: 11277

GCC return address of calling function in ARM architecture

I'm curious why __builtin_return_address() doesn't supports other arguments than 0 in ARM ? It's a problem that somehow you can't deduce calling function address from the stack of ARM ? Or something else ?

Thanks

Upvotes: 17

Views: 7213

Answers (2)

ams
ams

Reputation: 25599

Backtrace on ARM is hard. The Glibc backtrace function does work these days, but you need an up to date compiler/glibc, and you need to have built everything with -funwind-tables. GDB also has trouble without debug info.

Upvotes: 4

J. C. Salomon
J. C. Salomon

Reputation: 4313

According to this post <http://codingrelic.geekhold.com/2009/05/pre-mortem-backtracing.html>,

Also on some architectures, including my beloved MIPS, only __builtin_return_address(0) works. MIPS has no frame pointer, making it difficult to walk back up the stack. Frame 0 can use the return address register directly. If ARM also does not have a frame pointer, this would explain the limitation.

See also http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html.

Upvotes: 12

Related Questions