This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Relocation avoidance for function pointers


On 10/07/2016 01:28 PM, Florian Weimer wrote:
On 10/07/2016 08:20 PM, Martin Sebor wrote:
On 10/07/2016 09:51 AM, Florian Weimer wrote:
It is possible to compute the difference between two labels and store
the result in a variable.  For PIC code, this can be used to avoid
relocations in jump tables.

I try to do something similar for function pointers.  (Function pointer
arithmetic is a GCC extension.)  However, GCC rejects that with “error:
initializer element is not constant”.  Is there any way around this? The
required relocation should be the same (for static functions anyway).

I can't think of a workaround.  There have been a number of bugs
and enhancement requests to have GCC treat more expressions as
integer or address constant.  Clang users especially expect some
of the basic cases accepted there to work in GCC as well.
A couple of the recent requests I remember are 69960 and 71713.
I don't think they cover your case so opening a new request for
it might be helpful.

Thanks.  I found <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38295>
and reopened it.

I forgot about this one.  Since labels are local to function they're
not subject to the same reordering that functions can be subject to.
Do you not see a potential problem with that or with the relaxation
Andrew mentions?

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]