Mercurial > illumos > illumos-gate
changeset 4063:ca21bf366165
5108874 elfdump SEGVs on bad object file
author | ab196087 |
---|---|
date | Thu, 19 Apr 2007 08:12:50 -0700 |
parents | c84209043eff |
children | 66e3f3aebd89 |
files | usr/src/cmd/sgs/elfdump/common/_elfdump.h usr/src/cmd/sgs/elfdump/common/elfdump.c usr/src/cmd/sgs/elfdump/common/elfdump.msg usr/src/cmd/sgs/elfdump/common/main.c usr/src/cmd/sgs/packages/common/SUNWonld-README usr/src/cmd/sgs/packages/setup_pkg_ext usr/src/cmd/sgs/rtld/common/_rtld.h usr/src/cmd/sgs/rtld/common/analyze.c usr/src/cmd/sgs/rtld/common/cap.c usr/src/cmd/sgs/tools/proto.sh |
diffstat | 10 files changed, 62 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/sgs/elfdump/common/_elfdump.h Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/elfdump/common/_elfdump.h Thu Apr 19 08:12:50 2007 -0700 @@ -68,6 +68,7 @@ Shdr *c_shdr; Elf_Data *c_data; char *c_name; + int c_ndx; /* Section index */ } Cache; typedef struct got_info {
--- a/usr/src/cmd/sgs/elfdump/common/elfdump.c Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/elfdump/common/elfdump.c Thu Apr 19 08:12:50 2007 -0700 @@ -90,8 +90,16 @@ static const char * string(Cache *refsec, Word ndx, Cache *strsec, const char *file, Word name) { - static Cache *osec = 0; - static int nostr; + /* + * If an error in this routine is due to a property of the string + * section, as opposed to a bad offset into the section (a property of + * the referencing section), then we will detect the same error on + * every call involving those sections. We use these static variables + * to retain the information needed to only issue each such error once. + */ + static Cache *last_refsec; /* Last referencing section seen */ + static int strsec_err; /* True if error issued */ + const char *strs; Word strn; @@ -102,12 +110,23 @@ strn = strsec->c_data->d_size; /* - * Only print a diagnostic regarding an empty string table once per - * input section being processed. + * We only print a diagnostic regarding a bad string table once per + * input section being processed. If the refsec has changed, reset + * our retained error state. */ - if (osec != refsec) { - osec = refsec; - nostr = 0; + if (last_refsec != refsec) { + last_refsec = refsec; + strsec_err = 0; + } + + /* Verify that strsec really is a string table */ + if (strsec->c_shdr->sh_type != SHT_STRTAB) { + if (!strsec_err) { + (void) fprintf(stderr, MSG_INTL(MSG_ERR_NOTSTRTAB), + file, strsec->c_ndx, refsec->c_ndx); + strsec_err = 1; + } + return (MSG_INTL(MSG_STR_UNKNOWN)); } /* @@ -118,10 +137,10 @@ * Do we have a empty string table? */ if (strs == 0) { - if (nostr == 0) { + if (!strsec_err) { (void) fprintf(stderr, MSG_INTL(MSG_ERR_BADSZ), file, strsec->c_name); - nostr++; + strsec_err = 1; } } else { (void) fprintf(stderr, MSG_INTL(MSG_ERR_BADSTOFF), @@ -2770,6 +2789,7 @@ cnt++, _cache++) { char scnndxnm[100]; + _cache->c_ndx = cnt; _cache->c_scn = scn; if ((_cache->c_shdr = elf_getshdr(scn)) == NULL) {
--- a/usr/src/cmd/sgs/elfdump/common/elfdump.msg Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/elfdump/common/elfdump.msg Thu Apr 19 08:12:50 2007 -0700 @@ -111,6 +111,8 @@ @ MSG_ERR_BADSORTNDX "%s: %s: sort section has bad symbol index: %d\n" @ MSG_ERR_BADVER "%s: %s: index[%d]: version %d is out of range: \ version definitions available: 0-%d\n" +@ MSG_ERR_NOTSTRTAB "%s: section[%d] is not a string table as expected \ + by section[%d]\n"; @ MSG_ERR_LDYNNOTADJ "%s: bad dynamic symbol table layout: %s and %s \ sections are not adjacent\n"
--- a/usr/src/cmd/sgs/elfdump/common/main.c Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/elfdump/common/main.c Thu Apr 19 08:12:50 2007 -0700 @@ -45,7 +45,7 @@ #include <msg.h> #include <_elfdump.h> -const Cache cache_init = {NULL, NULL, NULL}; +const Cache cache_init = {NULL, NULL, NULL, NULL, 0}; const char * _elfdump_msg(Msg mid)
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README Thu Apr 19 08:12:50 2007 -0700 @@ -41,7 +41,8 @@ General link-editor information can be found: - http://linkers.eng/ + http://linkers.central/ + http://linkers.sfbay/ (also known as linkers.eng) Comments and Questions: @@ -1226,3 +1227,4 @@ 6516665 The link-editors should be more resilient against gcc's symbol versioning 6541004 hwcap filter processing can leak memory +5108874 elfdump SEGVs on bad object file
--- a/usr/src/cmd/sgs/packages/setup_pkg_ext Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/packages/setup_pkg_ext Thu Apr 19 08:12:50 2007 -0700 @@ -44,7 +44,14 @@ exit 0; fi -TEST_EXT=/net/linkers.eng/linkers/ws/ld_tests/bin/setup_ext +# There are two linkers servers (central and sfbay). If we are in +# one of those domains, use the local server. Otherwise .central. +TEST_EXT=/net/linkers/export/ws/ld_tests/bin/setup_ext +if [ -f $TEST_EXT ]; then + /bin/sh $TEST_EXT $SGSDIR + exit $? +fi +TEST_EXT=/net/linkers.central/export/ws/ld_tests/bin/setup_ext if [ -f $TEST_EXT ]; then /bin/sh $TEST_EXT $SGSDIR exit $?
--- a/usr/src/cmd/sgs/rtld/common/_rtld.h Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/rtld/common/_rtld.h Thu Apr 19 08:12:50 2007 -0700 @@ -596,7 +596,7 @@ extern void rd_event(Lm_list *, rd_event_e, r_state_e); extern int readenv_user(const char **, Word *, Word *, int); extern int readenv_config(Rtc_env *, Addr, int); -extern void rejection_inherit(Rej_desc *, Rej_desc *, Fdesc *); +extern void rejection_inherit(Rej_desc *, Rej_desc *); extern int relocate_lmc(Lm_list *, Aliste, Rt_map *, Rt_map *); extern int relocate_finish(Rt_map *, Alist *, int, int); extern void remove_cntl(Lm_list *, Aliste);
--- a/usr/src/cmd/sgs/rtld/common/analyze.c Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/rtld/common/analyze.c Thu Apr 19 08:12:50 2007 -0700 @@ -574,7 +574,7 @@ * additional processing or rejection messages. */ void -rejection_inherit(Rej_desc *rej1, Rej_desc *rej2, Fdesc *fdp) +rejection_inherit(Rej_desc *rej1, Rej_desc *rej2) { if (rej2->rej_type && (rej1->rej_type == 0)) { rej1->rej_type = rej2->rej_type; @@ -1766,7 +1766,7 @@ nfdp->fd_flags = FLG_FD_SLASH; if (find_path(lml, oname, clmp, flags, nfdp, &_rej) == 0) { - rejection_inherit(rej, &_rej, nfdp); + rejection_inherit(rej, &_rej); return (0); } @@ -1811,7 +1811,7 @@ */ if (find_file(lml, oname, clmp, flags, nfdp, &_rej, dir, &strhash, olen) == 0) { - rejection_inherit(rej, &_rej, nfdp); + rejection_inherit(rej, &_rej); continue; } @@ -2171,7 +2171,7 @@ _rej.rej_type = SGS_REJ_STR; _rej.rej_str = MSG_INTL(MSG_GEN_NOOPEN); DBG_CALL(Dbg_file_rejected(lml, &_rej)); - rejection_inherit(rej, &_rej, nfdp); + rejection_inherit(rej, &_rej); remove_so(lml, nlmp); return (0); } @@ -2203,7 +2203,7 @@ _rej.rej_type = SGS_REJ_STR; _rej.rej_str = strerror(ENOENT); DBG_CALL(Dbg_file_rejected(lml, &_rej)); - rejection_inherit(rej, &_rej, nfdp); + rejection_inherit(rej, &_rej); return (0); } }
--- a/usr/src/cmd/sgs/rtld/common/cap.c Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/rtld/common/cap.c Thu Apr 19 08:12:50 2007 -0700 @@ -164,7 +164,7 @@ _rej.rej_name = name; _rej.rej_str = strerror(errno); DBG_CALL(Dbg_file_rejected(lml, &_rej)); - rejection_inherit(rej, &_rej, 0); + rejection_inherit(rej, &_rej); return (0); } @@ -213,7 +213,7 @@ * provides a single point for error diagnostics. */ if (find_path(lml, name, clmp, flags, &fdesc, &_rej) == 0) { - rejection_inherit(rej, &_rej, &fdesc); + rejection_inherit(rej, &_rej); if ((rej->rej_name != _rej.rej_name) && (_rej.rej_name == name)) free((void *)name);
--- a/usr/src/cmd/sgs/tools/proto.sh Wed Apr 18 21:01:55 2007 -0700 +++ b/usr/src/cmd/sgs/tools/proto.sh Thu Apr 19 08:12:50 2007 -0700 @@ -21,7 +21,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -124,11 +124,18 @@ exit 1;; esac + # We need a local copy of libc_pic.a (we should get this from the parent # workspace, but as we can't be sure how the proto area is constructed there -# simply take it from a stashed copy on linkers.eng) +# simply take it from a stashed copy on linkers.central or linkers.eng.) +# +# We try for the linkers server in the current domain. Failing that, +# we fall over to linkers.central. +LIBC_PICDIR=/net/linkers/export/big/libc_pic/$RELEASE +if [ ! -d $LIBC_PICDIR ]; then + LIBC_PICDIR=/net/linkers.central/export/big/libc_pic/$RELEASE +fi -LIBC_PICDIR=/net/linkers.eng/linkers/ftp/pub/linkers/libc_pic/$RELEASE if [ $MACH = "sparc" ]; then PLATS="sparc sparcv9"