# HG changeset patch # User Bryan Cantrill # Date 1365531214 0 # Node ID b7147f4e608b85c16b2e499bab24a035d49a14e6 # Parent 7b07c85f383139f2ef97902d48bbf16bc9560e50 3926 multiple extern map file definitions corrupt symbol table entry Reviewed by: Robert Mustacchi Reviewed by: Richard Lowe Approved by: Albert Lee diff -r 7b07c85f3831 -r b7147f4e608b usr/src/cmd/sgs/libld/common/map_support.c --- a/usr/src/cmd/sgs/libld/common/map_support.c Sat Jul 27 11:12:12 2013 -0700 +++ b/usr/src/cmd/sgs/libld/common/map_support.c Tue Apr 09 18:13:34 2013 +0000 @@ -28,6 +28,10 @@ */ /* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +/* * Map file parsing (Shared Support Code). */ #include @@ -1075,34 +1079,33 @@ hash = (Word)elf_hash(ms->ms_name); DBG_CALL(Dbg_map_version(ofl->ofl_lml, mv->mv_name, ms->ms_name, mv->mv_scope)); + + /* + * Make sure that any parent or external declarations fall back to + * references. + */ + if (ms->ms_sdflags & (FLG_SY_PARENT | FLG_SY_EXTERN)) { + /* + * Turn it into a reference by setting the section index + * to UNDEF. + */ + ms->ms_shndx = SHN_UNDEF; + + /* + * It is wrong to specify size or value for an external symbol. + */ + if (ms->ms_value_set || (ms->ms_size != 0)) { + mf_fatal0(mf, MSG_INTL(MSG_MAP_NOEXVLSZ)); + mv->mv_errcnt++; + return (TRUE); + } + } + if ((sdp = ld_sym_find(ms->ms_name, hash, &where, ofl)) == NULL) { if ((sym = libld_calloc(sizeof (Sym), 1)) == NULL) return (FALSE); - /* - * Make sure any parent or external declarations - * fall back to references. - */ - if (ms->ms_sdflags & (FLG_SY_PARENT | FLG_SY_EXTERN)) { - /* - * Turn it into a reference by setting - * the section index to UNDEF. - */ - sym->st_shndx = ms->ms_shndx = SHN_UNDEF; - - /* - * It is wrong to specify size or value for an - * external symbol. - */ - if (ms->ms_value_set || (ms->ms_size != 0)) { - mf_fatal0(mf, MSG_INTL(MSG_MAP_NOEXVLSZ)); - mv->mv_errcnt++; - return (TRUE); - } - } else { - sym->st_shndx = (Half)ms->ms_shndx; - } - + sym->st_shndx = (Half)ms->ms_shndx; sym->st_value = ms->ms_value; sym->st_size = ms->ms_size; sym->st_info = ELF_ST_INFO(STB_GLOBAL, ms->ms_type); @@ -1135,7 +1138,6 @@ * from different mapfiles can augment each * other. */ - /* BEGIN CSTYLED */ if (sym->st_value) { if (ms->ms_value && (sym->st_value != ms->ms_value)) conflict = MSG_INTL(MSG_MAP_DIFF_SYMVAL); @@ -1162,7 +1164,6 @@ } else { sym->st_shndx = sdp->sd_shndx = ms->ms_shndx; } - /* END CSTYLED */ if ((sdp->sd_flags & MSK_SY_GLOBAL) && (sdp->sd_aux->sa_overndx != VER_NDX_GLOBAL) && diff -r 7b07c85f3831 -r b7147f4e608b usr/src/cmd/sgs/packages/common/SUNWonld-README --- a/usr/src/cmd/sgs/packages/common/SUNWonld-README Sat Jul 27 11:12:12 2013 -0700 +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README Tue Apr 09 18:13:34 2013 +0000 @@ -1647,3 +1647,4 @@ 3616 SHF_GROUP sections should not be discarded via other COMDAT mechanisms 3709 need sloppy relocation for GNU .debug_macro 3722 link-editor is over restrictive of R_AMD64_32 addends +3926 multiple extern map file definitions corrupt symbol table entry