diff options
Diffstat (limited to 'usr/src/tools')
| -rw-r--r-- | usr/src/tools/ctf/cvt/dwarf.c | 118 | ||||
| -rw-r--r-- | usr/src/tools/cw/Makefile | 6 | ||||
| -rw-r--r-- | usr/src/tools/cw/cw.c | 5 | ||||
| -rw-r--r-- | usr/src/tools/env/illumos.sh | 3 | ||||
| -rw-r--r-- | usr/src/tools/scripts/git-pbchk.py | 18 |
5 files changed, 136 insertions, 14 deletions
diff --git a/usr/src/tools/ctf/cvt/dwarf.c b/usr/src/tools/ctf/cvt/dwarf.c index ce8f6f9601..e261818d3a 100644 --- a/usr/src/tools/ctf/cvt/dwarf.c +++ b/usr/src/tools/ctf/cvt/dwarf.c @@ -22,6 +22,10 @@ * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Jason King. All rights reserved. + * Use is subject to license terms. + */ /* * DWARF to tdata conversion @@ -360,6 +364,37 @@ die_attr_form(dwarf_t *dw, Dwarf_Attribute attr) return (0); } +/* + * the following functions lookup the value of an attribute in a DIE: + * + * die_signed + * die_unsigned + * die_bool + * die_string + * + * They all take the same parameters (with the exception of valp which is + * a pointer to the type of the attribute we are looking up): + * + * dw - the dwarf object to look in + * die - the DIE we're interested in + * name - the name of the attribute to lookup + * valp - pointer to where the value of the attribute is placed + * req - if the value is required (0 / non-zero) + * + * If the attribute is not found, one of the following happens: + * - program terminates (req is non-zero) + * - function returns 0 + * + * If the value is found, and in a form (class) we can handle, the function + * returns 1. + * + * Currently, we can only handle attribute values that are stored as + * constants (immediate value). If an attribute has a form we cannot + * handle (for example VLAs may store the dimensions of the array + * as a DWARF expression that can compute it at runtime by reading + * values off the stack or other locations in memory), it is treated + * the same as if the attribute does not exist. + */ static int die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp, int req) @@ -371,6 +406,9 @@ die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp, return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formsdata(attr, &val, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get signed (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -392,6 +430,9 @@ die_unsigned(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Unsigned *valp, return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formudata(attr, &val, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get unsigned (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -412,6 +453,9 @@ die_bool(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Bool *valp, int req) return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formflag(attr, &val, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get bool (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -432,6 +476,9 @@ die_string(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, char **strp, int req) return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formstring(attr, &str, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get string (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -1791,6 +1838,59 @@ die_resolve(dwarf_t *dw) } while (dw->dw_nunres != 0); } +/* + * Any object containing a function or object symbol at any scope should also + * contain DWARF data. + */ +static boolean_t +should_have_dwarf(Elf *elf) +{ + Elf_Scn *scn = NULL; + Elf_Data *data = NULL; + GElf_Shdr shdr; + GElf_Sym sym; + uint32_t symdx = 0; + size_t nsyms = 0; + boolean_t found = B_FALSE; + + while ((scn = elf_nextscn(elf, scn)) != NULL) { + gelf_getshdr(scn, &shdr); + + if (shdr.sh_type == SHT_SYMTAB) { + found = B_TRUE; + break; + } + } + + if (!found) + terminate("cannot convert stripped objects\n"); + + data = elf_getdata(scn, NULL); + nsyms = shdr.sh_size / shdr.sh_entsize; + + for (symdx = 0; symdx < nsyms; symdx++) { + gelf_getsym(data, symdx, &sym); + + if ((GELF_ST_TYPE(sym.st_info) == STT_FUNC) || + (GELF_ST_TYPE(sym.st_info) == STT_TLS) || + (GELF_ST_TYPE(sym.st_info) == STT_OBJECT)) { + char *name; + + name = elf_strptr(elf, shdr.sh_link, sym.st_name); + + /* Studio emits these local symbols regardless */ + if ((strcmp(name, "Bbss.bss") != 0) && + (strcmp(name, "Ttbss.bss") != 0) && + (strcmp(name, "Ddata.data") != 0) && + (strcmp(name, "Ttdata.data") != 0) && + (strcmp(name, "Drodata.rodata") != 0)) + return (B_TRUE); + } + } + + return (B_FALSE); +} + /*ARGSUSED*/ int dw_read(tdata_t *td, Elf *elf, const char *filename) @@ -1814,8 +1914,12 @@ dw_read(tdata_t *td, Elf *elf, const char *filename) if ((rc = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dw.dw_dw, &dw.dw_err)) == DW_DLV_NO_ENTRY) { - errno = ENOENT; - return (-1); + if (should_have_dwarf(elf)) { + errno = ENOENT; + return (-1); + } else { + return (0); + } } else if (rc != DW_DLV_OK) { if (dwarf_errno(dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) { /* @@ -1834,10 +1938,18 @@ dw_read(tdata_t *td, Elf *elf, const char *filename) terminate("file does not contain valid DWARF data: %s\n", dwarf_errmsg(dw.dw_err)); + /* + * Some compilers emit no DWARF for empty files, others emit an empty + * compilation unit. + */ if ((cu = die_sibling(&dw, NULL)) == NULL || - (child = die_child(&dw, cu)) == NULL) + ((child = die_child(&dw, cu)) == NULL) && + should_have_dwarf(elf)) { terminate("file does not contain dwarf type data " "(try compiling with -g)\n"); + } else if (child == NULL) { + return (0); + } dw.dw_maxoff = nxthdr - 1; diff --git a/usr/src/tools/cw/Makefile b/usr/src/tools/cw/Makefile index 70f9a20c2a..73a3c3ca57 100644 --- a/usr/src/tools/cw/Makefile +++ b/usr/src/tools/cw/Makefile @@ -37,10 +37,12 @@ $(__GNUC)sparc_CC= $(GCC_ROOT)/bin/gcc CFLAGS += $(CCVERBOSE) -# Override CFLAGS when building with gcc. This is needed only for bootstrap -# of cw. +# Override CFLAGS. This is needed only for bootstrap of cw. $(__GNUC)CFLAGS= -O -D__sun -Wall -Wno-unknown-pragmas -Werror \ -std=gnu89 -nodefaultlibs +$(__SUNC)CFLAGS= -xspace -Xa -xildoff -errtags=yes -errwarn=%all \ + -xc99=%none -W0,-xglobalstatic -v + $(__GNUC)LDLIBS += -lc $(__GNUC)LDFLAGS= $(MAPFILE.NES:%=-Wl,-M%) diff --git a/usr/src/tools/cw/cw.c b/usr/src/tools/cw/cw.c index 135a7b363b..7e27294770 100644 --- a/usr/src/tools/cw/cw.c +++ b/usr/src/tools/cw/cw.c @@ -1140,11 +1140,6 @@ do_gcc(cw_ictx_t *ctx) break; } #if defined(__x86) - if (strcmp(arg, "-Wu,-no_got_reloc") == 0) { - newae(ctx->i_ae, "-fno-jump-tables"); - newae(ctx->i_ae, "-fno-constant-pools"); - break; - } if (strcmp(arg, "-Wu,-xmodel=kernel") == 0) { newae(ctx->i_ae, "-ffreestanding"); newae(ctx->i_ae, "-mno-red-zone"); diff --git a/usr/src/tools/env/illumos.sh b/usr/src/tools/env/illumos.sh index 9276217c03..23d7a35565 100644 --- a/usr/src/tools/env/illumos.sh +++ b/usr/src/tools/env/illumos.sh @@ -226,3 +226,6 @@ export SPRO_VROOT="$SPRO_ROOT" # POST_NIGHTLY can be any command to be run at the end of nightly. See # nightly(1) for interactions between environment variables and this command. #POST_NIGHTLY= + +# Uncomment this to disable support for SMB printing. +# export ENABLE_SMB_PRINTING='#' diff --git a/usr/src/tools/scripts/git-pbchk.py b/usr/src/tools/scripts/git-pbchk.py index 59af2f3832..74be6a4818 100644 --- a/usr/src/tools/scripts/git-pbchk.py +++ b/usr/src/tools/scripts/git-pbchk.py @@ -24,6 +24,7 @@ import os import re import subprocess import sys +import tempfile from cStringIO import StringIO @@ -62,15 +63,24 @@ def git(command): command = ["git"] + command - p = subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + try: + tmpfile = tempfile.TemporaryFile(prefix="git-nits") + except EnvironmentError, e: + raise GitError("Could not create temporary file: %s\n" % e) + + try: + p = subprocess.Popen(command, + stdout=tmpfile, + stderr=subprocess.STDOUT) + except OSError, e: + raise GitError("could not execute %s: %s\n" (command, e)) err = p.wait() if err != 0: raise GitError(p.stdout.read()) - return p.stdout + tmpfile.seek(0) + return tmpfile def git_root(): |
