Removing nested function from elfxx-aarch64.c
Richard Earnshaw (lists)
Richard.Earnshaw@arm.com
Wed Mar 19 13:08:16 GMT 2025
On 07/03/2025 20:09, Eric Botcazou wrote:
>> The short answer is "no". The longer answer is that I have in mind old
>> versions of gcc, probably when the support for nested functions had only
>> recently been added, where an executable stack was always used, even when
>> it was not strictly necessary. Now I may be mis-remembering here and
>> blaming gcc incorrectly, but I that is what I had in mind when I wrote that
>> sentence.
>
> I see, thanks. My experience is that GCC versions released over the last
> couple of decades behave as expected, in other words they do *not* require an
> executable stack unless a pointer to a nested function is taken (and a quick
> test with GCC 3.4.6 confirms it in a simple case).
It very much depends on the platform. From the gcc internals manual:
{Target Hook} int TARGET_CUSTOM_FUNCTION_DESCRIPTORS
If the target can use GCC's generic descriptor mechanism for nested
functions, define this hook to a power of 2 representing an unused bit
in function pointers which can be used to differentiate descriptors at
run time. This value gives the number of bytes by which descriptor
pointers are misaligned compared to function pointers. For example, on
targets that require functions to be aligned to a 4-byte boundary, a
value of either 1 or 2 is appropriate unless the architecture already
reserves the bit for another purpose, such as on ARM.
IIRC the function descriptor method requires some spare bits in a function pointer. If all bits are reserved by the architecture you can't use that approach, unless you manufacture some bits by over-aligning every addressable function; but that's essentially an ABI break.
R.
More information about the Binutils
mailing list