This is the mail archive of the gcc@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]

i386 ELF PIC PLT optimization ?


Hi,

Did anybody try to improve the i386 ELF ABI for PIC code ? By looking at how the thinks are handled on PowerPC, I think that several improvements are possible, for both smaller and faster code :

1) On i386, the PLT is built by the static linker whereas on PPC it is built dynamically by the dynamic linker. The net result is that the executables are smaller and that indirect jumps can be avoided in the PLT, so the inter DLL/EXEs calls are faster. The PLT can be also smaller because only 5 (or 8) bytes per entry could be used (a call opcode can be used for lazy binding and a direct jmp after).

2) On i386, it is almost always needed to initialize %ebx properly to the GOT address when entering a DLL function (except for functions calling only static functions and referencing no global variables). On PPC, it is only needed to initialize %r30 when accessing global variables.

By using a dynamically generated PLT on i386, we could avoid the %ebx register usage when calling a function by the PLT and so we would need to initialize %ebx only in rare cases (only if the function accesses global variables).

The net result would be smaller code (because no function prologue in most cases) and faster DLL function calls (no indirect jmp and in most cases %ebx will be usable in the function).

I am thinking about implementing it in TinyCC (a tiny C compiler) to test it. Does anyone have implemented similar ideas in GCC ? Of course, a small patch in ld.so would be needed to support that while staying compatible with standard DLLs.

Fabrice.



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