Print this page
7323 ld(1) -zignore can erroneously discard init and fini arrays as unreferenced


 742         Ifl_desc        *ifl = isp->is_file;
 743         char            *oname, *sname;
 744         uint_t          onamehash;
 745         Boolean         is_ehframe = (isp->is_flags & FLG_IS_EHFRAME) != 0;
 746 
 747         /*
 748          * Define any sections that must be thought of as referenced.  These
 749          * sections may not be referenced externally in a manner ld(1) can
 750          * discover, but they must be retained (ie. not removed by -zignore).
 751          */
 752         static const Msg RefSecs[] = {
 753                 MSG_SCN_INIT,           /* MSG_ORIG(MSG_SCN_INIT) */
 754                 MSG_SCN_FINI,           /* MSG_ORIG(MSG_SCN_FINI) */
 755                 MSG_SCN_EX_RANGES,      /* MSG_ORIG(MSG_SCN_EX_RANGES) */
 756                 MSG_SCN_EX_SHARED,      /* MSG_ORIG(MSG_SCN_EX_SHARED) */
 757                 MSG_SCN_CTORS,          /* MSG_ORIG(MSG_SCN_CTORS) */
 758                 MSG_SCN_DTORS,          /* MSG_ORIG(MSG_SCN_DTORS) */
 759                 MSG_SCN_EHFRAME,        /* MSG_ORIG(MSG_SCN_EHFRAME) */
 760                 MSG_SCN_EHFRAME_HDR,    /* MSG_ORIG(MSG_SCN_EHFRAME_HDR) */
 761                 MSG_SCN_JCR,            /* MSG_ORIG(MSG_SCN_JCR) */



 762                 0
 763         };
 764 
 765         DBG_CALL(Dbg_sec_in(ofl->ofl_lml, isp));
 766 
 767         /*
 768          * If this section identifies group members, or this section indicates
 769          * that it is a member of a group, determine whether the section is
 770          * still required.
 771          */
 772         if ((shflags & SHF_GROUP) || (shdr->sh_type == SHT_GROUP)) {
 773                 Group_desc      *gdesc;
 774 
 775                 if ((gdesc = ld_get_group(ofl, isp)) != NULL) {
 776                         DBG_CALL(Dbg_sec_group(ofl->ofl_lml, isp, gdesc));
 777 
 778                         /*
 779                          * If this group has been replaced by another group,
 780                          * then this section needs to be discarded.
 781                          */




 742         Ifl_desc        *ifl = isp->is_file;
 743         char            *oname, *sname;
 744         uint_t          onamehash;
 745         Boolean         is_ehframe = (isp->is_flags & FLG_IS_EHFRAME) != 0;
 746 
 747         /*
 748          * Define any sections that must be thought of as referenced.  These
 749          * sections may not be referenced externally in a manner ld(1) can
 750          * discover, but they must be retained (ie. not removed by -zignore).
 751          */
 752         static const Msg RefSecs[] = {
 753                 MSG_SCN_INIT,           /* MSG_ORIG(MSG_SCN_INIT) */
 754                 MSG_SCN_FINI,           /* MSG_ORIG(MSG_SCN_FINI) */
 755                 MSG_SCN_EX_RANGES,      /* MSG_ORIG(MSG_SCN_EX_RANGES) */
 756                 MSG_SCN_EX_SHARED,      /* MSG_ORIG(MSG_SCN_EX_SHARED) */
 757                 MSG_SCN_CTORS,          /* MSG_ORIG(MSG_SCN_CTORS) */
 758                 MSG_SCN_DTORS,          /* MSG_ORIG(MSG_SCN_DTORS) */
 759                 MSG_SCN_EHFRAME,        /* MSG_ORIG(MSG_SCN_EHFRAME) */
 760                 MSG_SCN_EHFRAME_HDR,    /* MSG_ORIG(MSG_SCN_EHFRAME_HDR) */
 761                 MSG_SCN_JCR,            /* MSG_ORIG(MSG_SCN_JCR) */
 762                 MSG_SCN_INITARRAY,      /* MSG_ORIG(MSG_SCN_INITARRAY) */
 763                 MSG_SCN_FINIARRAY,      /* MSG_ORIG(MSG_SCN_FINIARRAY) */
 764                 MSG_SCN_PREINITARRAY,   /* MSG_ORIG(MSG_SCN_PREINITARRAY) */
 765                 0
 766         };
 767 
 768         DBG_CALL(Dbg_sec_in(ofl->ofl_lml, isp));
 769 
 770         /*
 771          * If this section identifies group members, or this section indicates
 772          * that it is a member of a group, determine whether the section is
 773          * still required.
 774          */
 775         if ((shflags & SHF_GROUP) || (shdr->sh_type == SHT_GROUP)) {
 776                 Group_desc      *gdesc;
 777 
 778                 if ((gdesc = ld_get_group(ofl, isp)) != NULL) {
 779                         DBG_CALL(Dbg_sec_group(ofl->ofl_lml, isp, gdesc));
 780 
 781                         /*
 782                          * If this group has been replaced by another group,
 783                          * then this section needs to be discarded.
 784                          */