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]

PATCH: use non-readonly data section for objc references


When compiling Objective-C code -fPIC, readonly data references are created
that produce absolute relocs--something frowned upon by the linker (and
resulting in Many warnings by the linker, not to mention runtime overhead
with the dynamic linker).  This was found on NetBSD when attempting to make
libobjc a shared library.

The following patch (against 2.95.2) will use a writable data section when
compiling PIC code.  And the answer to the original comment:  "This is why
not."  8^)

==========
*** gcc/objc/objc-act.c	2000/07/26 00:19:06
--- gcc/objc/objc-act.c	2000/08/10 21:06:50
***************
*** 8399,8406 ****
        pushdecl (decl);
        rest_of_decl_compilation (decl, 0, 0, 0);
  
!       /* Make following constant read-only (why not)?  */
!       readonly_data_section ();
  
        exp = build1 (ADDR_EXPR, string_type_node, decl);
  
--- 8399,8409 ----
        pushdecl (decl);
        rest_of_decl_compilation (decl, 0, 0, 0);
  
!       /* Make following constant read-only, if not compiling PIC. */
!       if (flag_pic)
!         data_section();
!       else
!         readonly_data_section ();
  
        exp = build1 (ADDR_EXPR, string_type_node, decl);
  
==========

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  http://www.wasabisystems.com/
-- Speed, stability, security, and support.  Wasabi NetBSD:  Run with it.


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