diff options
author | ab196087 <none@none> | 2007-04-19 08:12:50 -0700 |
---|---|---|
committer | ab196087 <none@none> | 2007-04-19 08:12:50 -0700 |
commit | 31fdd7ca2d295948f9f1bcc2a1178c66467bca63 (patch) | |
tree | 598d11bc35583a24ac3a5fd3cfaceeb9156668e7 /usr/src | |
parent | 022ba35cdbb5905f91897d5ebec60427a5bc8a16 (diff) | |
download | illumos-joyent-31fdd7ca2d295948f9f1bcc2a1178c66467bca63.tar.gz |
5108874 elfdump SEGVs on bad object file
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/sgs/elfdump/common/_elfdump.h | 1 | ||||
-rw-r--r-- | usr/src/cmd/sgs/elfdump/common/elfdump.c | 38 | ||||
-rw-r--r-- | usr/src/cmd/sgs/elfdump/common/elfdump.msg | 2 | ||||
-rw-r--r-- | usr/src/cmd/sgs/elfdump/common/main.c | 2 | ||||
-rw-r--r-- | usr/src/cmd/sgs/packages/common/SUNWonld-README | 4 | ||||
-rw-r--r-- | usr/src/cmd/sgs/packages/setup_pkg_ext | 9 | ||||
-rw-r--r-- | usr/src/cmd/sgs/rtld/common/_rtld.h | 2 | ||||
-rw-r--r-- | usr/src/cmd/sgs/rtld/common/analyze.c | 10 | ||||
-rw-r--r-- | usr/src/cmd/sgs/rtld/common/cap.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/sgs/tools/proto.sh | 13 |
10 files changed, 62 insertions, 23 deletions
diff --git a/usr/src/cmd/sgs/elfdump/common/_elfdump.h b/usr/src/cmd/sgs/elfdump/common/_elfdump.h index 1d80ec1c51..a2a363af58 100644 --- a/usr/src/cmd/sgs/elfdump/common/_elfdump.h +++ b/usr/src/cmd/sgs/elfdump/common/_elfdump.h @@ -68,6 +68,7 @@ typedef struct cache { Shdr *c_shdr; Elf_Data *c_data; char *c_name; + int c_ndx; /* Section index */ } Cache; typedef struct got_info { diff --git a/usr/src/cmd/sgs/elfdump/common/elfdump.c b/usr/src/cmd/sgs/elfdump/common/elfdump.c index 67bcffa5d0..ce03a0f556 100644 --- a/usr/src/cmd/sgs/elfdump/common/elfdump.c +++ b/usr/src/cmd/sgs/elfdump/common/elfdump.c @@ -90,8 +90,16 @@ typedef struct { 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 @@ string(Cache *refsec, Word ndx, Cache *strsec, const char *file, Word name) 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 @@ string(Cache *refsec, Word ndx, Cache *strsec, const char *file, Word name) * 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 @@ regular(const char *file, Elf *elf, uint_t flags, char *Nname, int wfd) cnt++, _cache++) { char scnndxnm[100]; + _cache->c_ndx = cnt; _cache->c_scn = scn; if ((_cache->c_shdr = elf_getshdr(scn)) == NULL) { diff --git a/usr/src/cmd/sgs/elfdump/common/elfdump.msg b/usr/src/cmd/sgs/elfdump/common/elfdump.msg index 783e00ee80..f8adc9cab2 100644 --- a/usr/src/cmd/sgs/elfdump/common/elfdump.msg +++ b/usr/src/cmd/sgs/elfdump/common/elfdump.msg @@ -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" diff --git a/usr/src/cmd/sgs/elfdump/common/main.c b/usr/src/cmd/sgs/elfdump/common/main.c index 220c20a9a2..4868608260 100644 --- a/usr/src/cmd/sgs/elfdump/common/main.c +++ b/usr/src/cmd/sgs/elfdump/common/main.c @@ -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) diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README index 4e73d64e23..0ebc25aa56 100644 --- a/usr/src/cmd/sgs/packages/common/SUNWonld-README +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README @@ -41,7 +41,8 @@ SUNWonld - link-editors development package. 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 @@ Bugid Risk Synopsis 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 diff --git a/usr/src/cmd/sgs/packages/setup_pkg_ext b/usr/src/cmd/sgs/packages/setup_pkg_ext index f21a6d8fc5..81ea7a2e60 100644 --- a/usr/src/cmd/sgs/packages/setup_pkg_ext +++ b/usr/src/cmd/sgs/packages/setup_pkg_ext @@ -44,7 +44,14 @@ if [ -h $SGSDIR/ext -o -d $SGSDIR/ext ]; then 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 $? diff --git a/usr/src/cmd/sgs/rtld/common/_rtld.h b/usr/src/cmd/sgs/rtld/common/_rtld.h index 403ed4af58..edab85db2f 100644 --- a/usr/src/cmd/sgs/rtld/common/_rtld.h +++ b/usr/src/cmd/sgs/rtld/common/_rtld.h @@ -596,7 +596,7 @@ extern int pr_open(Lm_list *); 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); diff --git a/usr/src/cmd/sgs/rtld/common/analyze.c b/usr/src/cmd/sgs/rtld/common/analyze.c index b79c67568a..1f81fb8cf5 100644 --- a/usr/src/cmd/sgs/rtld/common/analyze.c +++ b/usr/src/cmd/sgs/rtld/common/analyze.c @@ -574,7 +574,7 @@ relocate_lmc(Lm_list *lml, Aliste nlmco, Rt_map *clmp, Rt_map *nlmp) * 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 @@ load_so(Lm_list *lml, Aliste lmco, const char *oname, Rt_map *clmp, 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 @@ load_so(Lm_list *lml, Aliste lmco, const char *oname, Rt_map *clmp, */ 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 @@ _load_path(Lm_list *lml, Aliste lmco, const char *name, Rt_map *clmp, _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 @@ _load_path(Lm_list *lml, Aliste lmco, const char *name, Rt_map *clmp, _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); } } diff --git a/usr/src/cmd/sgs/rtld/common/cap.c b/usr/src/cmd/sgs/rtld/common/cap.c index 7e0fc39811..4962f780e7 100644 --- a/usr/src/cmd/sgs/rtld/common/cap.c +++ b/usr/src/cmd/sgs/rtld/common/cap.c @@ -164,7 +164,7 @@ hwcap_dir(Alist **fdalpp, Lm_list *lml, const char *name, Rt_map *clmp, _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 @@ hwcap_dir(Alist **fdalpp, Lm_list *lml, const char *name, Rt_map *clmp, * 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); diff --git a/usr/src/cmd/sgs/tools/proto.sh b/usr/src/cmd/sgs/tools/proto.sh index 4d1963a9d5..0857083ec2 100644 --- a/usr/src/cmd/sgs/tools/proto.sh +++ b/usr/src/cmd/sgs/tools/proto.sh @@ -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 @@ case $RELEASE in 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" |