summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/sgs/libld/common/_libld.h9
-rw-r--r--usr/src/cmd/sgs/libld/common/syms.c40
-rw-r--r--usr/src/cmd/sgs/libld/common/update.c18
-rw-r--r--usr/src/cmd/sgs/packages/common/SUNWonld-README2
4 files changed, 50 insertions, 19 deletions
diff --git a/usr/src/cmd/sgs/libld/common/_libld.h b/usr/src/cmd/sgs/libld/common/_libld.h
index 146dd54b8c..d34bda5fa4 100644
--- a/usr/src/cmd/sgs/libld/common/_libld.h
+++ b/usr/src/cmd/sgs/libld/common/_libld.h
@@ -199,7 +199,7 @@ typedef struct {
const Rel_entry *mr_reloc_table;
Word (* mr_init_rel)(Rel_desc *, Word *, void *);
- void (* mr_mach_eflags)(Ehdr *, Ofl_desc *);
+ void (* mr_mach_eflags)(Ehdr *, Ofl_desc *);
void (* mr_mach_make_dynamic)(Ofl_desc *, size_t *);
void (* mr_mach_update_odynamic)(Ofl_desc *, Dyn **);
Xword (* mr_calc_plt_addr)(Sym_desc *, Ofl_desc *);
@@ -754,6 +754,7 @@ extern Sdf_desc *sdf_find(const char *, APlist *);
#define ld_sym_nodirect ld64_sym_nodirect
#define ld_sym_process ld64_sym_process
#define ld_sym_resolve ld64_sym_resolve
+#define ld_sym_reducable ld64_sym_reducable
#define ld_sym_spec ld64_sym_spec
#define ld_targ ld64_targ
#define ld_targ_init_sparc ld64_targ_init_sparc
@@ -852,6 +853,7 @@ extern Sdf_desc *sdf_find(const char *, APlist *);
#define ld_sym_nodirect ld32_sym_nodirect
#define ld_sym_process ld32_sym_process
#define ld_sym_resolve ld32_sym_resolve
+#define ld_sym_reducable ld32_sym_reducable
#define ld_sym_spec ld32_sym_spec
#define ld_targ ld32_targ
#define ld_targ_init_sparc ld32_targ_init_sparc
@@ -878,8 +880,8 @@ extern int dbg_setup(Ofl_desc *, const char *, int);
extern uintptr_t ld_add_actrel(Word, Rel_desc *, Ofl_desc *);
extern uintptr_t ld_add_libdir(Ofl_desc *, const char *);
-extern void ld_adj_movereloc(Ofl_desc *, Rel_desc *);
-extern Sym_desc * ld_am_I_partial(Rel_desc *, Xword);
+extern void ld_adj_movereloc(Ofl_desc *, Rel_desc *);
+extern Sym_desc * ld_am_I_partial(Rel_desc *, Xword);
extern void ld_ar_member(Ar_desc *, Elf_Arsym *, Ar_aux *,
Ar_mem *);
extern Ar_desc *ld_ar_setup(const char *, Elf *, Ofl_desc *);
@@ -997,6 +999,7 @@ extern uintptr_t ld_sym_nodirect(Is_desc *, Ifl_desc *, Ofl_desc *);
extern uintptr_t ld_sym_process(Is_desc *, Ifl_desc *, Ofl_desc *);
extern uintptr_t ld_sym_resolve(Sym_desc *, Sym *, Ifl_desc *,
Ofl_desc *, int, Word, sd_flag_t);
+extern Boolean ld_sym_reducable(Ofl_desc *, Sym_desc *);
extern uintptr_t ld_sym_spec(Ofl_desc *);
extern Target ld_targ;
diff --git a/usr/src/cmd/sgs/libld/common/syms.c b/usr/src/cmd/sgs/libld/common/syms.c
index 3d2e361037..9b895a0724 100644
--- a/usr/src/cmd/sgs/libld/common/syms.c
+++ b/usr/src/cmd/sgs/libld/common/syms.c
@@ -636,7 +636,7 @@ sym_add_spec(const char *name, const char *uname, Word sdaux_id,
sd_flag_t sdflags_u, sd_flag_t sdflags, Ofl_desc *ofl)
{
Sym_desc *sdp;
- Sym_desc *usdp;
+ Sym_desc *usdp;
Sym *sym;
Word hash;
avl_index_t where;
@@ -795,7 +795,7 @@ sym_add_spec(const char *name, const char *uname, Word sdaux_id,
*
* - the symbol has been defined by an implicitly supplied library, ie. one
* which was encounted because it was NEEDED by another library, rather
- * than from a command line supplied library which would become the only
+ * than from a command line supplied library which would become the only
* dependency of the output file being produced.
*
* - the symbol has been defined by a version of a shared object that is
@@ -991,6 +991,9 @@ sym_cap_vis(const char *name, Word hash, Sym *sym, Ofl_desc *ofl)
case STV_SINGLETON:
sdflags |= FLG_SY_SINGLE;
break;
+ case STV_HIDDEN:
+ sdflags |= FLG_SY_HIDDEN;
+ break;
}
/*
@@ -1133,7 +1136,7 @@ ensure_array_local(Ofl_desc *ofl, APlist *apl, const char *str)
* or modified), validate and count the relevant entries:
*
* - check and print any undefined symbols remaining. Note that if a symbol
- * has been defined by virtue of the inclusion of an implicit shared
+ * has been defined by virtue of the inclusion of an implicit shared
* library, it is still classed as undefined.
*
* - count the number of global needed symbols together with the size of
@@ -1141,7 +1144,7 @@ ensure_array_local(Ofl_desc *ofl, APlist *apl, const char *str)
* symbols may be reduced to locals).
*
* - establish the size and alignment requirements for the global .bss
- * section (the alignment of this section is based on the first symbol
+ * section (the alignment of this section is based on the first symbol
* that it will contain).
*/
uintptr_t
@@ -1516,7 +1519,7 @@ ld_sym_validate(Ofl_desc *ofl)
*/
if ((sym->st_shndx == SHN_COMMON) &&
(((oflags & FLG_OF_RELOBJ) == 0) ||
- (SYM_IS_HIDDEN(sdp) && (oflags & FLG_OF_PROCRED)))) {
+ ld_sym_reducable(ofl, sdp))) {
if ((sdp->sd_move == NULL) ||
((sdp->sd_flags & FLG_SY_PAREXPN) == 0)) {
if (type != STT_TLS) {
@@ -1568,7 +1571,7 @@ ld_sym_validate(Ofl_desc *ofl)
* hidden requirement and ensures the symbol isn't made globally
* available at runtime.
*/
- if (SYM_IS_HIDDEN(sdp) && (oflags & FLG_OF_PROCRED)) {
+ if (ld_sym_reducable(ofl, sdp)) {
/*
* If any reductions are being processed, keep a count
* of eliminated symbols, and if the symbol is being
@@ -1890,7 +1893,7 @@ typedef struct {
* input sections from this input file have been assigned an input section
* descriptor which is saved in the `ifl_isdesc' array.
*
- * - local symbols are saved (as is) if the input file is a relocatable
+ * - local symbols are saved (as is) if the input file is a relocatable
* object
*
* - global symbols are added to the linkers internal symbol table if they
@@ -3133,3 +3136,26 @@ ld_stt_section_sym_name(Is_desc *isp)
return (isp->is_sym_name);
}
+
+/*
+ * If we're producing a relocatable object and the symbol is eligible for
+ * COMDAT section, it shouldn't be reduced in scope as that will break the
+ * COMDAT matching when the output object is later consumed. Leave it alone,
+ * and any reduction (and COMDAT) processing will occur then.
+ *
+ * Otherwise, any hidden symbol is reduced when reductions are being processed.
+ */
+Boolean
+ld_sym_reducable(Ofl_desc *ofl, Sym_desc *sdp)
+{
+ Is_desc *isc = sdp->sd_isc;
+
+ if (((ofl->ofl_flags & FLG_OF_RELOBJ) != 0) &&
+ (isc != NULL) &&
+ ((isc->is_flags & FLG_IS_COMDAT) != 0)) {
+ return (FALSE);
+ } else {
+ return (SYM_IS_HIDDEN(sdp) &&
+ (ofl->ofl_flags & FLG_OF_PROCRED));
+ }
+}
diff --git a/usr/src/cmd/sgs/libld/common/update.c b/usr/src/cmd/sgs/libld/common/update.c
index 19352782d0..242feeccf9 100644
--- a/usr/src/cmd/sgs/libld/common/update.c
+++ b/usr/src/cmd/sgs/libld/common/update.c
@@ -184,7 +184,7 @@ update_osym(Ofl_desc *ofl)
#endif
Addr bssaddr, etext = 0, edata = 0, end = 0, start = 0;
Addr tlsbssaddr = 0;
- Addr parexpnbase, parexpnaddr;
+ Addr parexpnbase, parexpnaddr;
int start_set = 0;
Sym _sym = {0}, *sym, *symtab = NULL;
Sym *dynsym = NULL, *ldynsym = NULL;
@@ -1013,7 +1013,7 @@ update_osym(Ofl_desc *ofl)
if (sdp->sd_ref == REF_DYN_SEEN)
continue;
- if (SYM_IS_HIDDEN(sdp) && (flags & FLG_OF_PROCRED))
+ if (ld_sym_reducable(ofl, sdp))
local = 1;
else
local = 0;
@@ -1224,7 +1224,7 @@ update_osym(Ofl_desc *ofl)
* of the .symtab. Retain the appropriate index for use in
* version symbol indexing and relocation.
*/
- if (SYM_IS_HIDDEN(sdp) && (flags & FLG_OF_PROCRED)) {
+ if (ld_sym_reducable(ofl, sdp)) {
local = 1;
if (!(sdp->sd_flags & FLG_SY_ELIM) && !dynsym)
sdp->sd_symndx = scopesym_ndx;
@@ -1333,7 +1333,7 @@ update_osym(Ofl_desc *ofl)
* keyword in a mapfile.
*
* - Symbol reference has been bound to a
- * dependency which was specified as
+ * dependency which was specified as
* requiring direct bindings with -zdirect.
*
* - All symbol references are required to
@@ -1889,7 +1889,7 @@ update_osym(Ofl_desc *ofl)
* to maintain the binding of the original reference.
*/
if (SYM_IS_HIDDEN(sdp)) {
- if (flags & FLG_OF_PROCRED)
+ if (ld_sym_reducable(ofl, sdp))
bind = STB_LOCAL;
else
bind = STB_WEAK;
@@ -3157,7 +3157,7 @@ update_move(Ofl_desc *ofl)
imvp->m_info);
}
} else {
- Boolean isredloc = FALSE;
+ Boolean isredloc = FALSE;
if ((ELF_ST_BIND(sym->st_info) == STB_LOCAL) &&
(ofl->ofl_flags & FLG_OF_REDLSYM))
@@ -3652,7 +3652,7 @@ ld_update_outfile(Ofl_desc *ofl)
DBG_CALL(Dbg_seg_title(ofl->ofl_lml));
for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
Phdr *phdr = &(sgp->sg_phdr);
- Xword p_align;
+ Xword p_align;
Aliste idx2;
Sym_desc *sdp;
@@ -3872,8 +3872,8 @@ ld_update_outfile(Ofl_desc *ofl)
* Check overlaps
*/
for (i = 0; i < phdrndx - 1; i++) {
- Addr p_s = (ofl->ofl_phdr[i]).p_vaddr;
- Addr p_e;
+ Addr p_s = (ofl->ofl_phdr[i]).p_vaddr;
+ Addr p_e;
if ((ofl->ofl_phdr[i]).p_type != PT_LOAD)
continue;
diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README
index 7e549775e0..7553ab68c7 100644
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README
@@ -1663,3 +1663,5 @@ Bugid Risk Synopsis
8616 ld has trouble parsing -z options specified with -Wl
10267 ld and GCC disagree about i386 local dynamic TLS
10471 ld(1) amd64 LD->LE TLS transition causes memory corruption
+10346 ld(1) should not reduce symbol visibility of COMDAT symbols when
+ producing relocatable objects