Additional post-processing of the returned value may be needed, see
__builtin_extract_return_addr
.The stored representation of the return address in memory may be different from the address returned by
__builtin_return_address
. For example, on AArch64 the stored address may be mangled with return address signing whereas the address returned by__builtin_return_address
is not.
What is the stored representation of the return address?
__builtin_extract_return_addr:
The address as returned by
__builtin_return_address
may have to be fed through this function to get the actual encoded address. For example, on the 31-bit S/390 platform the highest bit has to be masked out, or on SPARC platforms an offset has to be added for the true next instruction to be executed.If no fixup is needed, this function simply passes through addr.
What is the actual encoded address?
Does it mean that __builtin_return_address
returns address somehow encoded for CPU? And __builtin_extract_return_addr(__builtin_return_address(0))
returns the direct (without any encoding) actual (without any shifts) return address?
If it is so, why someone needs to use __builtin_return_address
without __builtin_extract_return_addr
?
I just want to find out which function calls my function. I have addresses of all functions that I got using the nm utility. Do the addresses returned by nm
and the addresses returned by __builtin_extract_return_addr(__builtin_return_address(0))
have the same encoding?