Hello,

I have added a builtin __function_size that is supposed to receive a pointer to a function and return the size, in words, that the function takes.

We got it working until GCC4.5. In GCC4.5 became tricky for 2 reasons.

First, GCC 4.5 removes the function if the only reference to the function is through the builtin.

The way it currently works is that the builtin is converted into a label, through target_fold_builtin, and then after each function we output some code so that this label is has a value equal to the function size by subtracting two labels (current position and function label). This actually only works without assembler-linker (2 in 1).

However, since GCC4.5 if __function_size(swap) is the only reference to function swap, swap is removed and then there is no function in the assembler, and the calculation of the size fails.

How can I tell GCC to keep functions referenced by __function_size?

The second problem is the adoption of the GNU Binutils for assembling and linking. There is a backend for our target. However, the problem is that the function size, due to relaxation, is only available at link time. I know elf has a size attribute for symbols so I was thinking about using that, however, I am unsure on how to use GCC to get it working. Any suggestions?

My thought was to fold __function_size still to a special label (unique for each function) that would be then generates by as and set to the unrelaxed size of the function. Once the linker performs the required relaxation it also modifies the label value accordingly.

Cheers,

--
PMatos

Reply via email to