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

[PATCH] Avoid one unnecessary PLT slot in every GCC created shared library


Hi!

Each shared library created by GCC has an unnecessary PLT slot:
00dfcd28  00006506 R_386_GLOB_DAT         00000000   _Jv_RegisterClasses
00dfcd14  00006507 R_386_JUMP_SLOT        00000000   _Jv_RegisterClasses
   101: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
The code needs to load _Jv_RegisterClasses function pointer anyway
(from GOT), so there is no reason why this pointer cannot be reused
for the (unlikely) call.  At least on IA32/AMD64 I've checked
that GCC doesn't de-optimize this back to a PLT call.
Ok to commit?

2004-01-15  Jakub Jelinek  <jakub@redhat.com>

	* crtstuff.c (frame_dummy, __do_global_ctors_1): Call
	_Jv_RegisterClasses through a function pointer.

--- gcc/crtstuff.c.jj	2003-12-02 17:23:26.000000000 +0100
+++ gcc/crtstuff.c	2004-01-15 22:13:54.000000000 +0100
@@ -312,8 +312,12 @@ frame_dummy (void)
 #endif /* CRT_GET_RFIB_DATA */
 #endif /* USE_EH_FRAME_REGISTRY */
 #ifdef JCR_SECTION_NAME
-  if (__JCR_LIST__[0] && _Jv_RegisterClasses)
-    _Jv_RegisterClasses (__JCR_LIST__);
+  if (__JCR_LIST__[0])
+    {
+      void (*register_classes) (void *) = _Jv_RegisterClasses;
+      if (register_classes)
+	register_classes (__JCR_LIST__);
+    }
 #endif /* JCR_SECTION_NAME */
 }
 
@@ -395,8 +399,12 @@ __do_global_ctors_1(void)
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
 #endif
 #ifdef JCR_SECTION_NAME
-  if (__JCR_LIST__[0] && _Jv_RegisterClasses)
-    _Jv_RegisterClasses (__JCR_LIST__);
+  if (__JCR_LIST__[0])
+    {
+      void (*register_classes) (void *) = _Jv_RegisterClasses;
+      if (register_classes)
+	register_classes (__JCR_LIST__);
+    }
 #endif
 }
 #endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME */

	Jakub


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