762 ndx = sdp->sd_shndx;
763 } else
764 ndx = ofl->ofl_parexpnndx;
765 } else
766 ndx = sdp->sd_symndx;
767
768 /*
769 * Add the symbols 'value' to the addend field.
770 */
771 if (orsp->rel_flags & FLG_REL_ADVAL)
772 raddend += value;
773
774 /*
775 * The addend field for R_SPARC_TLS_DTPMOD32 and R_SPARC_TLS_DTPMOD64
776 * mean nothing. The addend is propagated in the corresponding
777 * R_SPARC_TLS_DTPOFF* relocations.
778 */
779 if (orsp->rel_rtype == M_R_DTPMOD)
780 raddend = 0;
781
782 relbits = (char *)relosp->os_outdata->d_buf;
783
784 rea.r_info = ELF_R_INFO(ndx,
785 ELF_R_TYPE_INFO(RELAUX_GET_TYPEDATA(orsp), orsp->rel_rtype));
786 rea.r_offset = roffset;
787 rea.r_addend = raddend;
788 DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_RELA, &rea, relosp->os_name,
789 ld_reloc_sym_name(orsp)));
790
791 /*
792 * Assert we haven't walked off the end of our relocation table.
793 */
794 assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
795
796 (void) memcpy((relbits + relosp->os_szoutrels),
797 (char *)&rea, sizeof (Rela));
798 relosp->os_szoutrels += (Xword)sizeof (Rela);
799
800 /*
801 * Determine if this relocation is against a non-writable, allocatable
802 * section. If so we may need to provide a text relocation diagnostic.
803 */
804 ld_reloc_remain_entry(orsp, osp, ofl, remain_seen);
805 return (1);
806 }
807
808
809 /*
810 * Sparc Instructions for TLS processing
811 */
812 #if defined(_ELF64)
813 #define TLS_GD_IE_LD 0xd0580000 /* ldx [%g0 + %g0], %o0 */
814 #else
815 #define TLS_GD_IE_LD 0xd0000000 /* ld [%g0 + %g0], %o0 */
1392 }
1393 }
1394 return (return_code);
1395 }
1396
1397 static uintptr_t
1398 ld_add_outrel(Word flags, Rel_desc *rsp, Ofl_desc *ofl)
1399 {
1400 Rel_desc *orsp;
1401 Sym_desc *sdp = rsp->rel_sym;
1402 Conv_inv_buf_t inv_buf;
1403
1404 /*
1405 * Static executables *do not* want any relocations against them.
1406 * Since our engine still creates relocations against a WEAK UNDEFINED
1407 * symbol in a static executable, it's best to disable them here
1408 * instead of through out the relocation code.
1409 */
1410 if (OFL_IS_STATIC_EXEC(ofl))
1411 return (1);
1412
1413 /*
1414 * Certain relocations do not make sense in a 64bit shared object,
1415 * if building a shared object do a sanity check on the output
1416 * relocations being created.
1417 */
1418 if (ofl->ofl_flags & FLG_OF_SHAROBJ) {
1419 Word rtype = rsp->rel_rtype;
1420 /*
1421 * Because the R_SPARC_HIPLT22 & R_SPARC_LOPLT10 relocations
1422 * are not relative they make no sense to create in a shared
1423 * object - so emit the proper error message if that occurs.
1424 */
1425 if ((rtype == R_SPARC_HIPLT22) || (rtype == R_SPARC_LOPLT10)) {
1426 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_REL_UNRELREL),
1427 conv_reloc_SPARC_type(rsp->rel_rtype, 0, &inv_buf),
1428 rsp->rel_isdesc->is_file->ifl_name,
1429 ld_reloc_sym_name(rsp));
1430 return (S_ERROR);
1431 }
|
762 ndx = sdp->sd_shndx;
763 } else
764 ndx = ofl->ofl_parexpnndx;
765 } else
766 ndx = sdp->sd_symndx;
767
768 /*
769 * Add the symbols 'value' to the addend field.
770 */
771 if (orsp->rel_flags & FLG_REL_ADVAL)
772 raddend += value;
773
774 /*
775 * The addend field for R_SPARC_TLS_DTPMOD32 and R_SPARC_TLS_DTPMOD64
776 * mean nothing. The addend is propagated in the corresponding
777 * R_SPARC_TLS_DTPOFF* relocations.
778 */
779 if (orsp->rel_rtype == M_R_DTPMOD)
780 raddend = 0;
781
782 /*
783 * Note that the other case which writes out the relocation, above, is
784 * M_R_REGISTER specific and so does not need this check.
785 */
786 if ((orsp->rel_rtype != M_R_NONE) &&
787 (orsp->rel_rtype != M_R_REGISTER) &&
788 (orsp->rel_rtype != M_R_RELATIVE)) {
789 if (ndx == 0) {
790 Conv_inv_buf_t inv_buf;
791 Is_desc *isp = orsp->rel_isdesc;
792
793 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_REL_NOSYMBOL),
794 conv_reloc_type(ofl->ofl_nehdr->e_machine,
795 orsp->rel_rtype, 0, &inv_buf),
796 isp->is_file->ifl_name, EC_WORD(isp->is_scnndx),
797 isp->is_name, EC_XWORD(roffset));
798 return (S_ERROR);
799 }
800 }
801
802 rea.r_info = ELF_R_INFO(ndx,
803 ELF_R_TYPE_INFO(RELAUX_GET_TYPEDATA(orsp), orsp->rel_rtype));
804 rea.r_offset = roffset;
805 rea.r_addend = raddend;
806 DBG_CALL(Dbg_reloc_out(ofl, ELF_DBG_LD, SHT_RELA, &rea, relosp->os_name,
807 ld_reloc_sym_name(orsp)));
808
809 /*
810 * Assert we haven't walked off the end of our relocation table.
811 */
812 assert(relosp->os_szoutrels <= relosp->os_shdr->sh_size);
813
814 relbits = (char *)relosp->os_outdata->d_buf;
815
816 (void) memcpy((relbits + relosp->os_szoutrels),
817 (char *)&rea, sizeof (Rela));
818 relosp->os_szoutrels += (Xword)sizeof (Rela);
819
820 /*
821 * Determine if this relocation is against a non-writable, allocatable
822 * section. If so we may need to provide a text relocation diagnostic.
823 */
824 ld_reloc_remain_entry(orsp, osp, ofl, remain_seen);
825 return (1);
826 }
827
828
829 /*
830 * Sparc Instructions for TLS processing
831 */
832 #if defined(_ELF64)
833 #define TLS_GD_IE_LD 0xd0580000 /* ldx [%g0 + %g0], %o0 */
834 #else
835 #define TLS_GD_IE_LD 0xd0000000 /* ld [%g0 + %g0], %o0 */
1412 }
1413 }
1414 return (return_code);
1415 }
1416
1417 static uintptr_t
1418 ld_add_outrel(Word flags, Rel_desc *rsp, Ofl_desc *ofl)
1419 {
1420 Rel_desc *orsp;
1421 Sym_desc *sdp = rsp->rel_sym;
1422 Conv_inv_buf_t inv_buf;
1423
1424 /*
1425 * Static executables *do not* want any relocations against them.
1426 * Since our engine still creates relocations against a WEAK UNDEFINED
1427 * symbol in a static executable, it's best to disable them here
1428 * instead of through out the relocation code.
1429 */
1430 if (OFL_IS_STATIC_EXEC(ofl))
1431 return (1);
1432
1433 /*
1434 * If the symbol will be reduced, we can't leave outstanding
1435 * relocations against it, as nothing will ever be able to satisfy them
1436 * (and the symbol won't be in .dynsym
1437 */
1438 if ((sdp != NULL) &&
1439 (sdp->sd_sym->st_shndx == SHN_UNDEF) &&
1440 (rsp->rel_rtype != M_R_NONE) &&
1441 (rsp->rel_rtype != M_R_REGISTER) &&
1442 (rsp->rel_rtype != M_R_RELATIVE)) {
1443 if (ld_sym_reducable(ofl, sdp))
1444 return (1);
1445 }
1446
1447 /*
1448 * Certain relocations do not make sense in a 64bit shared object,
1449 * if building a shared object do a sanity check on the output
1450 * relocations being created.
1451 */
1452 if (ofl->ofl_flags & FLG_OF_SHAROBJ) {
1453 Word rtype = rsp->rel_rtype;
1454 /*
1455 * Because the R_SPARC_HIPLT22 & R_SPARC_LOPLT10 relocations
1456 * are not relative they make no sense to create in a shared
1457 * object - so emit the proper error message if that occurs.
1458 */
1459 if ((rtype == R_SPARC_HIPLT22) || (rtype == R_SPARC_LOPLT10)) {
1460 ld_eprintf(ofl, ERR_FATAL, MSG_INTL(MSG_REL_UNRELREL),
1461 conv_reloc_SPARC_type(rsp->rel_rtype, 0, &inv_buf),
1462 rsp->rel_isdesc->is_file->ifl_name,
1463 ld_reloc_sym_name(rsp));
1464 return (S_ERROR);
1465 }
|