Skip to content

Commit

Permalink
3436 relocatable objects also need sloppy relocation
Browse files Browse the repository at this point in the history
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Garrett D'Amore <garrett@damore.org>
  • Loading branch information
richlowe committed Jan 10, 2013
1 parent c866e23 commit 396f90f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
34 changes: 22 additions & 12 deletions usr/src/cmd/sgs/libld/common/place.c
Expand Up @@ -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:
*
Expand All @@ -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));
}
}

/*
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions usr/src/cmd/sgs/packages/common/SUNWonld-README
Expand Up @@ -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

0 comments on commit 396f90f

Please sign in to comment.