[RFC][PATCH][X86_64] Eliminate PLT stubs for specified external functions via -fno-plt=
Pedro Alves
palves@redhat.com
Fri May 22 09:22:00 GMT 2015
On 05/21/2015 11:02 PM, Sriraman Tallam wrote:
> On Thu, May 21, 2015 at 2:51 PM, Pedro Alves <palves@redhat.com> wrote:
>> On 05/21/2015 10:12 PM, Sriraman Tallam wrote:
>>>
>>> My original proposal, for x86_64 only, was to add
>>> -fno-plt=<function-name>. This lets the user decide for which
>>> functions PLT must be avoided. Let the compiler always generate an
>>> indirect call using call *func@GOTPCREL(%rip). We could do this for
>>> non-PIC code too. No need for linker fixups since this relies on the
>>> user to know that func is from a shared object.
>>
>> Having to pass function names on the command line seems like an odd
>> interface. E.g, you'll need to pass the mangled name for
>> C++ functions. Any reason this isn't a function attribute?
>
> It is not clear to me where I would stick the attribute. Example
> usage in foo.cc:
>
> #include<string.h>
>
> int main() {
> int n = memcmp(....);
> }
>
> I want memcmp to not go through PLT, do you propose explicitly
> re-declaring it in foo.cc with the attribute?
I guess you'd do:
#include<string.h>
__attribute__((no_plt)) typeof (memcpy) memcpy;
int main() {
int n = memcmp(....);
}
or even:
#include<string.h>
int main() {
if (hotpath) {
__attribute__((no_plt)) typeof (memcpy) memcpy;
for (..) {
int n = memcmp(....);
}
} else {
int n = memcmp(....);
}
}
or globally:
$ cat no-plt/string.h:
#include_next <string.h>
__attribute__((no_plt)) typeof (memcpy) memcpy;
$ gcc -I no-plt/ ...
Thanks,
Pedro Alves
More information about the Gcc-patches
mailing list