Permalink
Browse files

3436 relocatable objects also need sloppy relocation

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...
1 parent c866e23 commit 396f90f95f3331a5b0c3fa020d44414df08f2f9a @richlowe richlowe committed Jan 2, 2013
Showing with 23 additions and 12 deletions.
  1. +22 −12 usr/src/cmd/sgs/libld/common/place.c
  2. +1 −0 usr/src/cmd/sgs/packages/common/SUNWonld-README
@@ -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
@@ -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.