summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/sgs/libld/common/sections.c60
-rw-r--r--usr/src/cmd/sgs/packages/common/SUNWonld-README1
2 files changed, 38 insertions, 23 deletions
diff --git a/usr/src/cmd/sgs/libld/common/sections.c b/usr/src/cmd/sgs/libld/common/sections.c
index 01ee18aab3..95cc830f6c 100644
--- a/usr/src/cmd/sgs/libld/common/sections.c
+++ b/usr/src/cmd/sgs/libld/common/sections.c
@@ -160,6 +160,31 @@ ignore_sym(Ofl_desc *ofl, Ifl_desc *ifl, Sym_desc *sdp, int allow_ldynsym)
}
}
+static Boolean
+isdesc_discarded(Is_desc *isp)
+{
+ Ifl_desc *ifl = isp->is_file;
+ Os_desc *osp = isp->is_osdesc;
+ Word ptype = osp->os_sgdesc->sg_phdr.p_type;
+
+ if (isp->is_flags & FLG_IS_DISCARD)
+ return (TRUE);
+
+ /*
+ * If the file is discarded, it will take
+ * the section with it.
+ */
+ if (ifl &&
+ (((ifl->ifl_flags & FLG_IF_FILEREF) == 0) ||
+ ((ptype == PT_LOAD) &&
+ ((isp->is_flags & FLG_IS_SECTREF) == 0) &&
+ (isp->is_shdr->sh_size > 0))) &&
+ (ifl->ifl_flags & FLG_IF_IGNORE))
+ return (TRUE);
+
+ return (FALSE);
+}
+
/*
* There are situations where we may count output sections (ofl_shdrcnt)
* that are subsequently eliminated from the output object. Whether or
@@ -181,7 +206,6 @@ adjust_os_count(Ofl_desc *ofl)
Sg_desc *sgp;
Is_desc *isp;
Os_desc *osp;
- Ifl_desc *ifl;
Aliste idx1;
if ((ofl->ofl_flags & FLG_OF_ADJOSCNT) == 0)
@@ -194,37 +218,20 @@ adjust_os_count(Ofl_desc *ofl)
*/
for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
Aliste idx2;
- Word ptype = sgp->sg_phdr.p_type;
for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) {
Aliste idx3;
int keep = 0, os_isdescs_idx;
OS_ISDESCS_TRAVERSE(os_isdescs_idx, osp, idx3, isp) {
- ifl = isp->is_file;
-
- /* Input section is tagged for discard? */
- if (isp->is_flags & FLG_IS_DISCARD)
- continue;
-
- /*
- * If the file is discarded, it will take
- * the section with it.
- */
- if (ifl &&
- (((ifl->ifl_flags & FLG_IF_FILEREF) == 0) ||
- ((ptype == PT_LOAD) &&
- ((isp->is_flags & FLG_IS_SECTREF) == 0) &&
- (isp->is_shdr->sh_size > 0))) &&
- (ifl->ifl_flags & FLG_IF_IGNORE))
- continue;
-
/*
* We have found a kept input section,
* so the output section will be created.
*/
- keep = 1;
- break;
+ if (!isdesc_discarded(isp)) {
+ keep = 1;
+ break;
+ }
}
/*
* If no section of this name was kept, decrement
@@ -2849,7 +2856,14 @@ ld_make_strmerge(Ofl_desc *ofl, Os_desc *osp, APlist **rel_alpp,
*/
mstrtab = NULL;
for (APLIST_TRAVERSE(osp->os_mstrisdescs, idx, isp)) {
- if (isp->is_flags & FLG_IS_DISCARD)
+ if (isdesc_discarded(isp))
+ continue;
+
+ /*
+ * Input sections of 0 size are dubiously valid since they do
+ * not even contain the NUL string. Ignore them.
+ */
+ if (isp->is_shdr->sh_size == 0)
continue;
/*
diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README
index dedd0ea913..6688c34255 100644
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README
@@ -1653,3 +1653,4 @@ Bugid Risk Synopsis
4227 ld --library-path is translated to -l-path, not -L
4270 ld(1) argument error reporting is still pretty bad
4383 libelf can't write extended sections when ELF_F_LAYOUT
+4959 completely discarded merged string sections will corrupt output objects