diff options
Diffstat (limited to 'cddl/contrib/opensolaris/tools/ctf/cvt/output.c')
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/output.c | 61 |
1 files changed, 13 insertions, 48 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c index ae8c594..f699fbf 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c @@ -79,7 +79,7 @@ burst_iitypes(void *data, void *arg) /*ARGSUSED1*/ static int -save_type_by_id(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private) +save_type_by_id(tdesc_t *tdp, tdesc_t **tdpp, void *private) { iiburst_t *iiburst = private; @@ -159,10 +159,8 @@ iiburst_free(iiburst_t *iiburst) * a global type description. */ static int -matching_iidesc(void *arg1, void *arg2) +matching_iidesc(iidesc_t *iidesc, iidesc_match_t *match) { - iidesc_t *iidesc = arg1; - iidesc_match_t *match = arg2; if (streq(iidesc->ii_name, match->iim_name) == 0) return (0); @@ -187,8 +185,6 @@ matching_iidesc(void *arg1, void *arg2) return (-1); } break; - default: - break; } return (0); } @@ -198,7 +194,7 @@ find_iidesc(tdata_t *td, iidesc_match_t *match) { match->iim_ret = NULL; iter_iidescs_by_name(td, match->iim_name, - matching_iidesc, match); + (int (*)())matching_iidesc, match); return (match->iim_ret); } @@ -243,12 +239,10 @@ check_for_weak(GElf_Sym *weak, char const *weakfile, GElf_Sym *retsym, char **curfilep) { char *curfile = NULL; - char *tmpfile1 = NULL; + char *tmpfile; GElf_Sym tmpsym; int candidate = 0; int i; - tmpsym.st_info = 0; - tmpsym.st_name = 0; if (GELF_ST_BIND(weak->st_info) != STB_WEAK) return (0); @@ -282,7 +276,7 @@ check_for_weak(GElf_Sym *weak, char const *weakfile, (curfile == NULL || weakfile == NULL || strcmp(curfile, weakfile) != 0)) { candidate = 1; - tmpfile1 = curfile; + tmpfile = curfile; tmpsym = sym; continue; } @@ -293,7 +287,7 @@ check_for_weak(GElf_Sym *weak, char const *weakfile, } if (candidate) { - *curfilep = tmpfile1; + *curfilep = tmpfile; *retsym = tmpsym; return (1); } @@ -502,14 +496,14 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, secxlate = xmalloc(sizeof (int) * sehdr.e_shnum); for (srcidx = dstidx = 0; srcidx < sehdr.e_shnum; srcidx++) { Elf_Scn *scn = elf_getscn(src, srcidx); - GElf_Shdr shdr1; + GElf_Shdr shdr; char *sname; - gelf_getshdr(scn, &shdr1); - sname = elf_strptr(src, sehdr.e_shstrndx, shdr1.sh_name); + gelf_getshdr(scn, &shdr); + sname = elf_strptr(src, sehdr.e_shstrndx, shdr.sh_name); if (sname == NULL) { elfterminate(srcname, "Can't find string at %u", - shdr1.sh_name); + shdr.sh_name); } if (strcmp(sname, CTF_ELF_SCN_NAME) == 0) { @@ -520,7 +514,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, strncmp(sname, ".rel.debug", 10) == 0 || strncmp(sname, ".rela.debug", 11) == 0)) { secxlate[srcidx] = -1; - } else if (dynsym && shdr1.sh_type == SHT_SYMTAB) { + } else if (dynsym && shdr.sh_type == SHT_SYMTAB) { /* * If we're building CTF against the dynsym, * we'll rip out the symtab so debuggers aren't @@ -573,31 +567,11 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, elfterminate(srcname, "Can't find string at %u", shdr.sh_name); } - -#if !defined(sun) - if (gelf_update_shdr(dscn, &shdr) == 0) - elfterminate(dstname, "Cannot update sect %s", sname); -#endif - if ((sdata = elf_getdata(sscn, NULL)) == NULL) elfterminate(srcname, "Cannot get sect %s data", sname); if ((ddata = elf_newdata(dscn)) == NULL) elfterminate(dstname, "Can't make sect %s data", sname); -#if defined(sun) bcopy(sdata, ddata, sizeof (Elf_Data)); -#else - /* - * FreeBSD's Elf_Data has private fields which the - * elf_* routines manage. Simply copying the - * entire structure corrupts the data. So we need - * to copy the public fields explictly. - */ - ddata->d_align = sdata->d_align; - ddata->d_off = sdata->d_off; - ddata->d_size = sdata->d_size; - ddata->d_type = sdata->d_type; - ddata->d_version = sdata->d_version; -#endif if (srcidx == sehdr.e_shstrndx) { char seclen = strlen(CTF_ELF_SCN_NAME); @@ -627,8 +601,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, GElf_Sym sym; short newscn; - if (gelf_getsym(ddata, i, &sym) == NULL) - printf("Could not get symbol %d\n",i); + (void) gelf_getsym(ddata, i, &sym); if (sym.st_shndx >= SHN_LORESERVE) continue; @@ -643,14 +616,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, } } -#if !defined(sun) - if (ddata->d_buf == NULL) { - ddata->d_buf = xmalloc(shdr.sh_size); - bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size); - } -#endif - - if (gelf_update_shdr(dscn, &shdr) == 0) + if (gelf_update_shdr(dscn, &shdr) == NULL) elfterminate(dstname, "Cannot update sect %s", sname); new_offset = (off_t)shdr.sh_offset; @@ -685,7 +651,6 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, ddata->d_buf = ctfdata; ddata->d_size = ctfsize; ddata->d_align = shdr.sh_addralign; - ddata->d_off = 0; gelf_update_shdr(dscn, &shdr); |