• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Return Address - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="C-Extensions.html#C-Extensions" title="C Extensions">
9<link rel="prev" href="Function-Names.html#Function-Names" title="Function Names">
10<link rel="next" href="Vector-Extensions.html#Vector-Extensions" title="Vector Extensions">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010 Free Software Foundation, Inc.
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with the
20Invariant Sections being ``Funding Free Software'', the Front-Cover
21Texts being (a) (see below), and with the Back-Cover Texts being (b)
22(see below).  A copy of the license is included in the section entitled
23``GNU Free Documentation License''.
24
25(a) The FSF's Front-Cover Text is:
26
27     A GNU Manual
28
29(b) The FSF's Back-Cover Text is:
30
31     You have freedom to copy and modify this GNU Manual, like GNU
32     software.  Copies published by the Free Software Foundation raise
33     funds for GNU development.-->
34<meta http-equiv="Content-Style-Type" content="text/css">
35<style type="text/css"><!--
36  pre.display { font-family:inherit }
37  pre.format  { font-family:inherit }
38  pre.smalldisplay { font-family:inherit; font-size:smaller }
39  pre.smallformat  { font-family:inherit; font-size:smaller }
40  pre.smallexample { font-size:smaller }
41  pre.smalllisp    { font-size:smaller }
42  span.sc    { font-variant:small-caps }
43  span.roman { font-family:serif; font-weight:normal; } 
44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
45--></style>
46<link rel="stylesheet" type="text/css" href="../cs.css">
47</head>
48<body>
49<div class="node">
50<a name="Return-Address"></a>
51<p>
52Next:&nbsp;<a rel="next" accesskey="n" href="Vector-Extensions.html#Vector-Extensions">Vector Extensions</a>,
53Previous:&nbsp;<a rel="previous" accesskey="p" href="Function-Names.html#Function-Names">Function Names</a>,
54Up:&nbsp;<a rel="up" accesskey="u" href="C-Extensions.html#C-Extensions">C Extensions</a>
55<hr>
56</div>
57
58<h3 class="section">6.48 Getting the Return or Frame Address of a Function</h3>
59
60<p>These functions may be used to get information about the callers of a
61function.
62
63<div class="defun">
64&mdash; Built-in Function: void * <b>__builtin_return_address</b> (<var>unsigned int level</var>)<var><a name="index-g_t_005f_005fbuiltin_005freturn_005faddress-2702"></a></var><br>
65<blockquote><p>This function returns the return address of the current function, or of
66one of its callers.  The <var>level</var> argument is number of frames to
67scan up the call stack.  A value of <code>0</code> yields the return address
68of the current function, a value of <code>1</code> yields the return address
69of the caller of the current function, and so forth.  When inlining
70the expected behavior is that the function will return the address of
71the function that will be returned to.  To work around this behavior use
72the <code>noinline</code> function attribute.
73
74      <p>The <var>level</var> argument must be a constant integer.
75
76      <p>On some machines it may be impossible to determine the return address of
77any function other than the current one; in such cases, or when the top
78of the stack has been reached, this function will return <code>0</code> or a
79random value.  In addition, <code>__builtin_frame_address</code> may be used
80to determine if the top of the stack has been reached.
81
82      <p>Additional post-processing of the returned value may be needed, see
83<code>__builtin_extract_return_address</code>.
84
85      <p>This function should only be used with a nonzero argument for debugging
86purposes. 
87</p></blockquote></div>
88
89<div class="defun">
90&mdash; Built-in Function: void * <b>__builtin_extract_return_address</b> (<var>void *addr</var>)<var><a name="index-g_t_005f_005fbuiltin_005fextract_005freturn_005faddress-2703"></a></var><br>
91<blockquote><p>The address as returned by <code>__builtin_return_address</code> may have to be fed
92through this function to get the actual encoded address.  For example, on the
9331-bit S/390 platform the highest bit has to be masked out, or on SPARC
94platforms an offset has to be added for the true next instruction to be
95executed.
96
97      <p>If no fixup is needed, this function simply passes through <var>addr</var>. 
98</p></blockquote></div>
99
100<div class="defun">
101&mdash; Built-in Function: void * <b>__builtin_frob_return_address</b> (<var>void *addr</var>)<var><a name="index-g_t_005f_005fbuiltin_005ffrob_005freturn_005faddress-2704"></a></var><br>
102<blockquote><p>This function does the reverse of <code>__builtin_extract_return_address</code>. 
103</p></blockquote></div>
104
105<div class="defun">
106&mdash; Built-in Function: void * <b>__builtin_frame_address</b> (<var>unsigned int level</var>)<var><a name="index-g_t_005f_005fbuiltin_005fframe_005faddress-2705"></a></var><br>
107<blockquote><p>This function is similar to <code>__builtin_return_address</code>, but it
108returns the address of the function frame rather than the return address
109of the function.  Calling <code>__builtin_frame_address</code> with a value of
110<code>0</code> yields the frame address of the current function, a value of
111<code>1</code> yields the frame address of the caller of the current function,
112and so forth.
113
114      <p>The frame is the area on the stack which holds local variables and saved
115registers.  The frame address is normally the address of the first word
116pushed on to the stack by the function.  However, the exact definition
117depends upon the processor and the calling convention.  If the processor
118has a dedicated frame pointer register, and the function has a frame,
119then <code>__builtin_frame_address</code> will return the value of the frame
120pointer register.
121
122      <p>On some machines it may be impossible to determine the frame address of
123any function other than the current one; in such cases, or when the top
124of the stack has been reached, this function will return <code>0</code> if
125the first frame pointer is properly initialized by the startup code.
126
127      <p>This function should only be used with a nonzero argument for debugging
128purposes. 
129</p></blockquote></div>
130
131 </body></html>
132
133