From 396f90f95f3331a5b0c3fa020d44414df08f2f9a Mon Sep 17 00:00:00 2001 From: Richard Lowe Date: Tue, 1 Jan 2013 21:14:26 -0500 Subject: [PATCH] 3436 relocatable objects also need sloppy relocation Reviewed by: Gordon Ross Reviewed by: Robert Mustacchi Approved by: Garrett D'Amore --- usr/src/cmd/sgs/libld/common/place.c | 34 ++++++++++++------- .../cmd/sgs/packages/common/SUNWonld-README | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/usr/src/cmd/sgs/libld/common/place.c b/usr/src/cmd/sgs/libld/common/place.c index 1b32572968a7..d56e20571763 100644 --- a/usr/src/cmd/sgs/libld/common/place.c +++ b/usr/src/cmd/sgs/libld/common/place.c @@ -850,6 +850,13 @@ ld_place_section(Ofl_desc *ofl, Is_desc *isp, Place_path_info *path_info, } } + /* + * When building relocatable objects, we must not redirect COMDAT + * section names into their outputs, such that our output object may + * be successfully used as an input object also requiring COMDAT + * processing + */ + /* * GNU section names may follow the convention: * @@ -863,13 +870,15 @@ ld_place_section(Ofl_desc *ofl, Is_desc *isp, Place_path_info *path_info, * because we know the name is not NULL, and therefore must have * at least one character plus a NULL termination. */ - if (((ofl->ofl_flags & FLG_OF_RELOBJ) == 0) && - (isp->is_name == oname) && (isp->is_name[1] == 'g') && + if ((isp->is_name == oname) && (isp->is_name[1] == 'g') && (strncmp(MSG_ORIG(MSG_SCN_GNU_LINKONCE), isp->is_name, MSG_SCN_GNU_LINKONCE_SIZE) == 0)) { - if ((oname = - (char *)gnu_linkonce_sec(isp->is_name)) != isp->is_name) { - DBG_CALL(Dbg_sec_redirected(ofl->ofl_lml, isp, oname)); + if ((ofl->ofl_flags & FLG_OF_RELOBJ) == 0) { + if ((oname = (char *)gnu_linkonce_sec(isp->is_name)) != + isp->is_name) { + DBG_CALL(Dbg_sec_redirected(ofl->ofl_lml, isp, + oname)); + } } /* @@ -894,16 +903,17 @@ ld_place_section(Ofl_desc *ofl, Is_desc *isp, Place_path_info *path_info, * sections, and this identification can be triggered by a pattern * match section names. */ - if (((ofl->ofl_flags & FLG_OF_RELOBJ) == 0) && - (isp->is_name == oname) && (isp->is_flags & FLG_IS_COMDAT) && + if ((isp->is_name == oname) && (isp->is_flags & FLG_IS_COMDAT) && ((sname = gnu_comdat_sym(ifl, isp)) != NULL)) { size_t size = sname - isp->is_name; - if ((oname = libld_malloc(size + 1)) == NULL) - return ((Os_desc *)S_ERROR); - (void) strncpy(oname, isp->is_name, size); - oname[size] = '\0'; - DBG_CALL(Dbg_sec_redirected(ofl->ofl_lml, isp, oname)); + if ((ofl->ofl_flags & FLG_OF_RELOBJ) == 0) { + if ((oname = libld_malloc(size + 1)) == NULL) + return ((Os_desc *)S_ERROR); + (void) strncpy(oname, isp->is_name, size); + oname[size] = '\0'; + DBG_CALL(Dbg_sec_redirected(ofl->ofl_lml, isp, oname)); + } /* * Enable relaxed relocation processing, as this is diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README index 65f98b2b78a4..9c6135b8740b 100644 --- a/usr/src/cmd/sgs/packages/common/SUNWonld-README +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README @@ -1642,3 +1642,4 @@ Bugid Risk Synopsis 3265 link-editor builds bogus .eh_frame_hdr on ia32 3453 GNU comdat redirection does exactly the wrong thing 3439 discarded sections shouldn't end up on output lists +3436 relocatable objects also need sloppy relocation