------- Comment #3 from ro at gcc dot gnu dot org  2010-04-30 10:15 -------
This only happens when using GCC with Sun as, GNU as with either Sun ld or GNU
ld
is fine.  While gas follows the ELF gABI and sets SHT_INIT_ARRAY on an
.init_array
section, Sun as does not, and I see no easy workaround.

I've filed

6948724 as should recognize .init_array/.fini_array/.preinit_array sections
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6948724

for this issue.

In the meantime, there are two options:

* On Solaris 11, use elfedit to set SHT_INIT_ARRAY manually:

  elfedit -e 'shdr:sh_flags .init_array SHF_WRITE SHF_ALLOC' -e 'shdr:sh_type
.init_array SHT_INIT_ARRAY' <objectfile>

* With Sun ld, use -z initarray=<func>:

  gcc -z initarray=<func> <source> -o <executable>


-- 

ro at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ro at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
  GCC build triplet|sparc-sun-solaris2.*        |*-*-solaris2.*
   GCC host triplet|sparc-sun-solaris2.*        |*-*-solaris2.*
 GCC target triplet|sparc-sun-solaris2.*        |*-*-solaris2.*
   Last reconfirmed|0000-00-00 00:00:00         |2010-04-30 10:15:29
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28715

Reply via email to