diff options
Diffstat (limited to 'usr/src')
53 files changed, 991 insertions, 636 deletions
diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master index ac3b6f4702..fa24c6a55f 100644 --- a/usr/src/Makefile.master +++ b/usr/src/Makefile.master @@ -987,7 +987,7 @@ AS_BIGPICFLAGS= -K PIC # # Default label for CTF sections # -CTFCVTFLAGS= -i -L VERSION +CTFCVTFLAGS= -L VERSION # # Override to pass module-specific flags to ctfmerge. Currently used only by @@ -1010,11 +1010,14 @@ CTFCONVERT_O = $(CTFCONVERT) $(CTFCVTFLAGS) $@ # Rules (normally from make.rules) and macros which are used for post # processing files. Normally, these do stripping of the comment section # automatically. -# RELEASE_CM: Should be editted to reflect the release. -# POST_PROCESS_O: Post-processing for `.o' files. -# POST_PROCESS_A: Post-processing for `.a' files (currently null). +# RELEASE_CM: Should be edited to reflect the release. +# POST_PROCESS_O: Post-processing for `.o' files (typically C source) +# POST_PROCESS_S_O: Post-processing for `.o' files built from asssembly +# POST_PROCESS_CC_O: Post-processing for `.o' files built from C++ +# POST_PROCESS_A: Post-processing for `.a' files (currently null). # POST_PROCESS_SO: Post-processing for `.so' files. # POST_PROCESS: Post-processing for executable files (no suffix). +# # Note that these macros are not completely generalized as they are to be # used with the file name to be processed following. # @@ -1066,6 +1069,8 @@ STRIP_STABS= $(STRIP) -x $@ $(SRCDBGBLD)STRIP_STABS= : POST_PROCESS_O= +POST_PROCESS_S_O= +POST_PROCESS_CC_O= POST_PROCESS_A= POST_PROCESS_SO= $(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \ $(ELFSIGN_OBJECT) @@ -1111,7 +1116,7 @@ PKGPUBLISHER_NONREDIST= on-extra $(RM) $% .s.o: $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) .s.a: $(COMPILE.s) -o $% $< $(PROCESS_COMMENT) $% @@ -1122,7 +1127,7 @@ PKGPUBLISHER_NONREDIST= on-extra $(POST_PROCESS) .cc.o: $(COMPILE.cc) $(OUTPUT_OPTION) $< - $(POST_PROCESS_O) + $(POST_PROCESS_CC_O) .cc.a: $(COMPILE.cc) -o $% $< $(AR) $(ARFLAGS) $@ $% diff --git a/usr/src/cmd/ctfconvert/ctfconvert.c b/usr/src/cmd/ctfconvert/ctfconvert.c index 3ff96c5089..9c93da38f4 100644 --- a/usr/src/cmd/ctfconvert/ctfconvert.c +++ b/usr/src/cmd/ctfconvert/ctfconvert.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015, Joyent, Inc. + * Copyright (c) 2019, Joyent, Inc. */ /* @@ -69,12 +69,13 @@ ctfconvert_usage(const char *fmt, ...) va_end(ap); } - (void) fprintf(stderr, "Usage: %s [-is] [-j nthrs] [-l label | " + (void) fprintf(stderr, "Usage: %s [-ims] [-j nthrs] [-l label | " "-L labelenv] [-o outfile] input\n" "\n" "\t-i ignore files not built partially from C sources\n" "\t-j use nthrs threads to perform the merge\n" "\t-k keep around original input file on failure\n" + "\t-m allow input to have missing debug info\n" "\t-o copy input to outfile and add CTF\n" "\t-l set output container's label to specified value\n" "\t-L set output container's label to value from environment\n", @@ -259,21 +260,16 @@ main(int argc, char *argv[]) char *eptr; char buf[4096]; boolean_t optx = B_FALSE; + boolean_t ignore_non_c = B_FALSE; ctfconvert_progname = basename(argv[0]); ctfconvert_altexec(argv); - while ((c = getopt(argc, argv, ":j:kl:L:o:iX")) != -1) { + while ((c = getopt(argc, argv, ":ij:kl:L:mo:X")) != -1) { switch (c) { - case 'k': - keep = B_TRUE; - break; - case 'l': - label = optarg; - break; - case 'L': - label = getenv(optarg); + case 'i': + ignore_non_c = B_TRUE; break; case 'j': errno = 0; @@ -285,12 +281,21 @@ main(int argc, char *argv[]) } nthreads = (uint_t)argj; break; + case 'k': + keep = B_TRUE; + break; + case 'l': + label = optarg; + break; + case 'L': + label = getenv(optarg); + break; + case 'm': + flags |= CTF_ALLOW_MISSING_DEBUG; + break; case 'o': outfile = optarg; break; - case 'i': - flags |= CTF_CONVERT_F_IGNNONC; - break; case 'X': optx = B_TRUE; break; @@ -307,8 +312,8 @@ main(int argc, char *argv[]) argv += optind; argc -= optind; - if (argc < 1) { - ctfconvert_usage("Missing required input file\n"); + if (argc != 1) { + ctfconvert_usage("Exactly one input file is required\n"); return (CTFCONVERT_USAGE); } infile = argv[0]; @@ -334,19 +339,32 @@ main(int argc, char *argv[]) sizeof (buf)); if (ofp == NULL) { /* - * -i says that we shouldn't concern ourselves with source files - * that weren't built from C source code in part. Because this - * has been traditionally used across all of illumos, we still - * honor it. + * Normally, ctfconvert requires that its input file has at + * least one C-source compilation unit, and that every C-source + * compilation unit has DWARF. This is to avoid accidentally + * leaving out useful CTF. + * + * However, for the benefit of intransigent build environments, + * the -i and -m options can be used to relax this. */ - if ((flags & CTF_CONVERT_F_IGNNONC) != 0 && - err == ECTF_CONVNOCSRC) { + if (err == ECTF_CONVNOCSRC && ignore_non_c) { exit(CTFCONVERT_OK); } + + if (err == ECTF_CONVNODEBUG && + (flags & CTF_ALLOW_MISSING_DEBUG) != 0) { + exit(CTFCONVERT_OK); + } + if (keep == B_FALSE) (void) unlink(infile); - ctfconvert_fatal("CTF conversion failed: %s\n", - err == ECTF_CONVBKERR ? buf : ctf_errmsg(err)); + + if (err == ECTF_CONVBKERR || err == ECTF_CONVNODEBUG) { + ctfconvert_fatal("%s", buf); + } else { + ctfconvert_fatal("CTF conversion failed: %s\n", + ctf_errmsg(err)); + } } if (optx == B_TRUE) diff --git a/usr/src/cmd/ctfmerge/ctfmerge.c b/usr/src/cmd/ctfmerge/ctfmerge.c index 1257fd16c9..2da162a99b 100644 --- a/usr/src/cmd/ctfmerge/ctfmerge.c +++ b/usr/src/cmd/ctfmerge/ctfmerge.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2017, Joyent, Inc. + * Copyright (c) 2019, Joyent, Inc. */ /* @@ -38,7 +38,6 @@ static char *g_progname; static char *g_unique; static char *g_outfile; -static boolean_t g_req; static uint_t g_nctf; #define CTFMERGE_OK 0 @@ -64,73 +63,39 @@ ctfmerge_fatal(const char *fmt, ...) exit(CTFMERGE_FATAL); } -static boolean_t -ctfmerge_expect_ctf(const char *name, Elf *elf) +/* + * We failed to find CTF for this file, check if it's OK. If we're not derived + * from C, or we have the -m option, we let missing CTF pass. + */ +static void +ctfmerge_check_for_c(const char *name, Elf *elf, uint_t flags) { - Elf_Scn *scn, *strscn; - Elf_Data *data, *strdata; - GElf_Shdr shdr; - ulong_t i; - - if (g_req == B_FALSE) - return (B_FALSE); - - scn = NULL; - while ((scn = elf_nextscn(elf, scn)) != NULL) { - if (gelf_getshdr(scn, &shdr) == NULL) { - ctfmerge_fatal("failed to get section header for file " - "%s: %s\n", name, elf_errmsg(elf_errno())); - } - - if (shdr.sh_type == SHT_SYMTAB) - break; - } - - if (scn == NULL) - return (B_FALSE); - - if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL) - ctfmerge_fatal("failed to get section header for file %s: %s\n", - name, elf_errmsg(elf_errno())); - - if ((data = elf_getdata(scn, NULL)) == NULL) - ctfmerge_fatal("failed to read symbol table for %s: %s\n", - name, elf_errmsg(elf_errno())); - - if ((strdata = elf_getdata(strscn, NULL)) == NULL) - ctfmerge_fatal("failed to read string table for %s: %s\n", - name, elf_errmsg(elf_errno())); - - for (i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) { - GElf_Sym sym; - const char *file; - size_t len; + char errmsg[1024]; - if (gelf_getsym(data, i, &sym) == NULL) - ctfmerge_fatal("failed to read symbol table entry %lu " - "for %s: %s\n", i, name, elf_errmsg(elf_errno())); + if (flags & CTF_ALLOW_MISSING_DEBUG) + return; - if (GELF_ST_TYPE(sym.st_info) != STT_FILE) - continue; + switch (ctf_has_c_source(elf, errmsg, sizeof (errmsg))) { + case CHR_ERROR: + ctfmerge_fatal("failed to open %s: %s\n", name, errmsg); + break; - file = (const char *)((uintptr_t)strdata->d_buf + sym.st_name); - len = strlen(file); - if (len < 2 || name[len - 2] != '.') - continue; + case CHR_NO_C_SOURCE: + return; - if (name[len - 1] == 'c') - return (B_TRUE); + default: + ctfmerge_fatal("failed to open %s: %s\n", name, + ctf_errmsg(ECTF_NOCTFDATA)); + break; } - - return (B_FALSE); } /* * Go through and construct enough information for this Elf Object to try and do * a ctf_bufopen(). */ -static void -ctfmerge_elfopen(const char *name, Elf *elf, ctf_merge_t *cmh) +static int +ctfmerge_elfopen(const char *name, Elf *elf, ctf_merge_t *cmh, uint_t flags) { GElf_Ehdr ehdr; GElf_Shdr shdr; @@ -214,10 +179,8 @@ ctfmerge_elfopen(const char *name, Elf *elf, ctf_merge_t *cmh) } if (ctfsect.cts_type == SHT_NULL) { - if (ctfmerge_expect_ctf(name, elf) == B_FALSE) - return; - ctfmerge_fatal("failed to open %s: %s\n", name, - ctf_errmsg(ECTF_NOCTFDATA)); + ctfmerge_check_for_c(name, elf, flags); + return (ENOENT); } if (symsect.cts_type != SHT_NULL && strsect.cts_type != SHT_NULL) { @@ -227,36 +190,37 @@ ctfmerge_elfopen(const char *name, Elf *elf, ctf_merge_t *cmh) } if (fp == NULL) { - if (ctfmerge_expect_ctf(name, elf) == B_TRUE) { - ctfmerge_fatal("failed to open file %s: %s\n", - name, ctf_errmsg(err)); - } - } else { - if ((err = ctf_merge_add(cmh, fp)) != 0) { - ctfmerge_fatal("failed to add input %s: %s\n", - name, ctf_errmsg(err)); - } - g_nctf++; + ctfmerge_fatal("failed to open file %s: %s\n", + name, ctf_errmsg(err)); + } + + if ((err = ctf_merge_add(cmh, fp)) != 0) { + ctfmerge_fatal("failed to add input %s: %s\n", + name, ctf_errmsg(err)); } + + g_nctf++; + return (0); } static void ctfmerge_read_archive(const char *name, int fd, Elf *elf, - ctf_merge_t *cmh) + ctf_merge_t *cmh, uint_t flags) { - Elf *aelf; Elf_Cmd cmd = ELF_C_READ; int cursec = 1; - char *nname; + Elf *aelf; while ((aelf = elf_begin(fd, cmd, elf)) != NULL) { + char *nname = NULL; Elf_Arhdr *arhdr; - boolean_t leakelf = B_FALSE; if ((arhdr = elf_getarhdr(aelf)) == NULL) ctfmerge_fatal("failed to get archive header %d for " "%s: %s\n", cursec, name, elf_errmsg(elf_errno())); + cmd = elf_next(aelf); + if (*(arhdr->ar_name) == '/') goto next; @@ -267,28 +231,64 @@ ctfmerge_read_archive(const char *name, int fd, Elf *elf, switch (elf_kind(aelf)) { case ELF_K_AR: - ctfmerge_read_archive(nname, fd, aelf, cmh); - free(nname); + ctfmerge_read_archive(nname, fd, aelf, cmh, flags); break; case ELF_K_ELF: - ctfmerge_elfopen(nname, aelf, cmh); - free(nname); - leakelf = B_TRUE; + /* ctfmerge_elfopen() takes ownership of aelf. */ + if (ctfmerge_elfopen(nname, aelf, cmh, flags) == 0) + aelf = NULL; break; default: ctfmerge_fatal("unknown elf kind (%d) in archive %d " "for %s\n", elf_kind(aelf), cursec, name); + break; } next: - cmd = elf_next(aelf); - if (leakelf == B_FALSE) - (void) elf_end(aelf); + (void) elf_end(aelf); + free(nname); cursec++; } } static void +ctfmerge_file_add(ctf_merge_t *cmh, const char *file, uint_t flags) +{ + Elf *e; + int fd; + + if ((fd = open(file, O_RDONLY)) < 0) { + ctfmerge_fatal("failed to open file %s: %s\n", + file, strerror(errno)); + } + + if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { + (void) close(fd); + ctfmerge_fatal("failed to open %s: %s\n", + file, elf_errmsg(elf_errno())); + } + + switch (elf_kind(e)) { + case ELF_K_AR: + ctfmerge_read_archive(file, fd, e, cmh, flags); + break; + + case ELF_K_ELF: + /* ctfmerge_elfopen() takes ownership of e. */ + if (ctfmerge_elfopen(file, e, cmh, flags) == 0) + e = NULL; + break; + + default: + ctfmerge_fatal("unknown elf kind (%d) for %s\n", + elf_kind(e), file); + } + + (void) elf_end(e); + (void) close(fd); +} + +static void ctfmerge_usage(const char *fmt, ...) { if (fmt != NULL) { @@ -300,15 +300,15 @@ ctfmerge_usage(const char *fmt, ...) va_end(ap); } - (void) fprintf(stderr, "Usage: %s [-t] [-d uniqfile] [-l label] " + (void) fprintf(stderr, "Usage: %s [-m] [-d uniqfile] [-l label] " "[-L labelenv] [-j nthrs] -o outfile file ...\n" "\n" "\t-d uniquify merged output against uniqfile\n" "\t-j use nthrs threads to perform the merge\n" "\t-l set output container's label to specified value\n" "\t-L set output container's label to value from environment\n" - "\t-o file to add CTF data to\n" - "\t-t require CTF data from all inputs built from C sources\n", + "\t-m allow C-based input files to not have CTF\n" + "\t-o file to add CTF data to\n", g_progname); } @@ -341,8 +341,9 @@ main(int argc, char *argv[]) uint_t nthreads = CTFMERGE_DEFAULT_NTHREADS; char *tmpfile = NULL, *label = NULL; int wflags = CTF_ELFWRITE_F_COMPRESS; - ctf_file_t *ofp; + uint_t flags = 0; ctf_merge_t *cmh; + ctf_file_t *ofp; long argj; char *eptr; @@ -352,9 +353,9 @@ main(int argc, char *argv[]) /* * We support a subset of the old CTF merge flags, mostly for - * compatability. + * compatibility. */ - while ((c = getopt(argc, argv, ":d:fgj:l:L:o:t")) != -1) { + while ((c = getopt(argc, argv, ":d:fgj:l:L:mo:t")) != -1) { switch (c) { case 'd': g_unique = optarg; @@ -381,11 +382,14 @@ main(int argc, char *argv[]) case 'L': label = getenv(optarg); break; + case 'm': + flags |= CTF_ALLOW_MISSING_DEBUG; + break; case 'o': g_outfile = optarg; break; case 't': - g_req = B_TRUE; + /* Silently ignored for compatibility */ break; case ':': ctfmerge_usage("Option -%c requires an operand\n", @@ -430,58 +434,7 @@ main(int argc, char *argv[]) nthreads, ctf_errmsg(err)); for (i = 0; i < argc; i++) { - ctf_file_t *ifp; - int fd; - - if ((fd = open(argv[i], O_RDONLY)) < 0) - ctfmerge_fatal("failed to open file %s: %s\n", - argv[i], strerror(errno)); - ifp = ctf_fdopen(fd, &err); - if (ifp == NULL) { - Elf *e; - - if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { - (void) close(fd); - ctfmerge_fatal("failed to open %s: %s\n", - argv[i], ctf_errmsg(err)); - } - - /* - * It's an ELF file, check if we have an archive or if - * we're expecting CTF here. - */ - switch (elf_kind(e)) { - case ELF_K_AR: - break; - case ELF_K_ELF: - if (ctfmerge_expect_ctf(argv[i], e) == B_TRUE) { - (void) elf_end(e); - (void) close(fd); - ctfmerge_fatal("failed to " - "open %s: file was built from C " - "sources, but missing CTF\n", - argv[i]); - } - (void) elf_end(e); - (void) close(fd); - continue; - default: - (void) elf_end(e); - (void) close(fd); - ctfmerge_fatal("failed to open %s: " - "unsupported ELF file type", argv[i]); - } - - ctfmerge_read_archive(argv[i], fd, e, cmh); - (void) elf_end(e); - (void) close(fd); - continue; - } - (void) close(fd); - if ((err = ctf_merge_add(cmh, ifp)) != 0) - ctfmerge_fatal("failed to add input %s: %s\n", - argv[i], ctf_errmsg(err)); - g_nctf++; + ctfmerge_file_add(cmh, argv[i], flags); } if (g_nctf == 0) { diff --git a/usr/src/cmd/mdb/Makefile.module b/usr/src/cmd/mdb/Makefile.module index 7da9b0c586..6c2c6af170 100644 --- a/usr/src/cmd/mdb/Makefile.module +++ b/usr/src/cmd/mdb/Makefile.module @@ -23,9 +23,9 @@ # Use is subject to license terms. # # Copyright (c) 2013 by Delphix. All rights reserved. -# Copyright (c) 2018, Joyent, Inc. # Copyright (c) 2019 Carlos Neira <cneirabustos@gmail.com> # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. +# Copyright (c) 2019, Joyent, Inc. # .KEEP_STATE: @@ -240,7 +240,6 @@ dmod/%.o kmod/%.o: %.c dmod/%.o kmod%.o: %.s $(COMPILE.s) -o $@ $< - $(CTFCONVERT_O) dmod/%.o kmod/%.o: ../%.c $(COMPILE.c) -o $@ $< @@ -248,7 +247,6 @@ dmod/%.o kmod/%.o: ../%.c dmod/%.o kmod%.o: ../%.s $(COMPILE.s) -o $@ $< - $(CTFCONVERT_O) dmod/%.o kmod/%.o: ../../../common/modules/$(MODNAME)/%.c $(COMPILE.c) -o $@ $< @@ -256,7 +254,6 @@ dmod/%.o kmod/%.o: ../../../common/modules/$(MODNAME)/%.c dmod/%.o kmod%.o: ../../../common/modules/$(MODNAME)/%.s $(COMPILE.s) -o $@ $< - $(CTFCONVERT_O) dmod/%.o kmod/%.o: $$(MODSRCS_DIR)/%.c $(COMPILE.c) -o $@ $< @@ -264,7 +261,6 @@ dmod/%.o kmod/%.o: $$(MODSRCS_DIR)/%.c dmod/%.o kmod%.o: $$(MODSRCS_DIR)/%.s $(COMPILE.s) -o $@ $< - $(CTFCONVERT_O) # # Lint diff --git a/usr/src/cmd/mdb/common/modules/genunix/Makefile.files b/usr/src/cmd/mdb/common/modules/genunix/Makefile.files index 07e5c2fa14..87d0c589a8 100644 --- a/usr/src/cmd/mdb/common/modules/genunix/Makefile.files +++ b/usr/src/cmd/mdb/common/modules/genunix/Makefile.files @@ -21,7 +21,7 @@ # # Copyright 2011 Nexenta Systems, Inc. All rights reserved. # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2018 Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # Copyright (c) 2013 by Delphix. All rights reserved. # @@ -48,7 +48,6 @@ GENUNIX_SRCS = \ findstack.c \ findstack_subr.c \ fm.c \ - gcore.c \ gcore_isadep.c \ genunix.c \ group.c \ diff --git a/usr/src/cmd/mdb/intel/amd64/genunix/Makefile b/usr/src/cmd/mdb/intel/amd64/genunix/Makefile index 07f1069a84..8d73bebcb1 100644 --- a/usr/src/cmd/mdb/intel/amd64/genunix/Makefile +++ b/usr/src/cmd/mdb/intel/amd64/genunix/Makefile @@ -26,6 +26,8 @@ # # Copyright (c) 2013 by Delphix. All rights reserved. # +# Copyright (c) 2019, Joyent, Inc. +# MODULE = genunix.so MDBTGT = kvm @@ -40,6 +42,7 @@ KMODSRCS = \ MODSRCS = \ $(COMMONSRCS) \ + gcore.c \ typegraph.c # diff --git a/usr/src/cmd/sgs/rtld/Makefile.targ b/usr/src/cmd/sgs/rtld/Makefile.targ index b028b33add..6ea1a29e6d 100644 --- a/usr/src/cmd/sgs/rtld/Makefile.targ +++ b/usr/src/cmd/sgs/rtld/Makefile.targ @@ -25,6 +25,8 @@ # # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. # +# Copyright (c) 2019, Joyent, Inc. +# # Don't generate separate sections for this module pics/debugdata.o := XFFLAG= @@ -34,11 +36,11 @@ $(RTLD) := CTFMERGE_POST = $(CTFMERGE_LIB) pics/%.o: %.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(CRTSRCS)/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: %.c $(COMPILE.c) -o $@ $< diff --git a/usr/src/common/ctf/ctf_error.c b/usr/src/common/ctf/ctf_error.c index 1765b77b54..9ac40ce811 100644 --- a/usr/src/common/ctf/ctf_error.c +++ b/usr/src/common/ctf/ctf_error.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2015, Joyent, Inc. + * Copyright (c) 2019, Joyent, Inc. */ #include <ctf_impl.h> @@ -83,7 +83,7 @@ static const char *const _ctf_errlist[] = { "Zlib library failure", /* ECTF_ZLIB */ "CTF conversion backend error", /* ECTF_CONVBKERR */ "No C source to convert from", /* ECTF_CONVNOCSRC */ - "No applicable conversion backend" /* ECTF_NOCONVBKEND */ + "No debug info found to convert from" /* ECTF_CONVNODEBUG */ }; static const int _ctf_nerr = sizeof (_ctf_errlist) / sizeof (_ctf_errlist[0]); diff --git a/usr/src/lib/Makefile.lib b/usr/src/lib/Makefile.lib index 686298e4e8..a18e77553e 100644 --- a/usr/src/lib/Makefile.lib +++ b/usr/src/lib/Makefile.lib @@ -22,7 +22,7 @@ # Copyright 2015 Gary Mills # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2015, Joyent, Inc. +# Copyright 2019, Joyent, Inc. # # # Definitions common to libraries. @@ -229,7 +229,7 @@ objs/%.o pics/%.o: %.c objs/%.o pics/%.o: %.cc $(COMPILE.cc) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_CC_O) .PRECIOUS: $(LIBS) diff --git a/usr/src/lib/Makefile.targ b/usr/src/lib/Makefile.targ index a1cc95bb4c..36f91189b4 100644 --- a/usr/src/lib/Makefile.targ +++ b/usr/src/lib/Makefile.targ @@ -20,7 +20,7 @@ # # # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2014, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # # @@ -48,11 +48,11 @@ $(ROOTHDRDIR)/%: $(HDRDIR)/% $(ROOTLIBDIR)/%: % $(INS.file) $(ROOTLIBDIR64)/%: % - $(INS.file) + $(INS.file) $(ROOTFS_LIBDIR)/%: % $(INS.file) $(ROOTFS_LIBDIR64)/%: % - $(INS.file) + $(INS.file) $(ROOTLIBDIR)/$(LIBLINKS): $(ROOTLIBDIR)/$(LIBLINKS)$(VERS) $(INS.liblink) @@ -80,7 +80,7 @@ objs/%.o pics/%.o: $(SRCDIR)/%.c objs/%.o pics/%.o: $(SRCDIR)/%.cc $(COMPILE.cc) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_CC_O) objs pics: -@mkdir -p $@ @@ -99,7 +99,7 @@ $(DYNLIBCCC): pics .WAIT $$(PICS) $$(ALTPICS) $$(EXTPICS) $(BUILDCCC.SO) $(POST_PROCESS_SO) -$(LINTLIB): $$(SRCS) +$(LINTLIB): $$(SRCS) $(LINT.c) -o $(LIBNAME) $(SRCS) > $(LINTOUT) 2>&1 lintcheck: $$(SRCS) diff --git a/usr/src/lib/brand/lx/lx_brand/Makefile.com b/usr/src/lib/brand/lx/lx_brand/Makefile.com index e57436e127..bb9ce6ed93 100644 --- a/usr/src/lib/brand/lx/lx_brand/Makefile.com +++ b/usr/src/lib/brand/lx/lx_brand/Makefile.com @@ -21,7 +21,7 @@ # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. -# Copyright 2018 Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # LX_CMN = $(SRC)/common/brand/lx @@ -91,7 +91,7 @@ include ../../../../Makefile.usdt pics/%.o: $(ISASRCDIR)/%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LX_CMN)/%.c $(COMPILE.c) -o $@ $< diff --git a/usr/src/lib/brand/lx/lx_vdso/Makefile.com b/usr/src/lib/brand/lx/lx_vdso/Makefile.com index b6d46d38cd..9a1836112c 100644 --- a/usr/src/lib/brand/lx/lx_vdso/Makefile.com +++ b/usr/src/lib/brand/lx/lx_vdso/Makefile.com @@ -10,7 +10,7 @@ # # -# Copyright 2016 Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # LIBRARY = lx_vdso.a @@ -79,7 +79,7 @@ include $(SRC)/lib/commpage/Makefile.shared.targ pics/%.o: $(ISASRCDIR)/%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/vdso_main.o := CPPFLAGS += $(COMMPAGE_CPPFLAGS) -I$(SRCDIR) pics/vdso_subr.o := ASFLAGS += -I$(SRC)/uts/common/brand/lx -I$(SRCDIR) diff --git a/usr/src/lib/brand/shared/brand/Makefile.com b/usr/src/lib/brand/shared/brand/Makefile.com index 7d9a4ee554..8d58c993d8 100644 --- a/usr/src/lib/brand/shared/brand/Makefile.com +++ b/usr/src/lib/brand/shared/brand/Makefile.com @@ -23,6 +23,8 @@ # # Copyright 2013 Nexenta Systems, Inc. All rights reserved. # +# Copyright (c) 2019, Joyent, Inc. +# COBJS = brand_util.o ASOBJS = crt.o handler.o runexe.o @@ -74,6 +76,6 @@ $(OFFSETS_H): $(OFFSETS_SRC) pics/%.o: $(ISASRCDIR)/%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/commpage/Makefile.shared.targ b/usr/src/lib/commpage/Makefile.shared.targ index 85260e3c9e..31dd17ba13 100644 --- a/usr/src/lib/commpage/Makefile.shared.targ +++ b/usr/src/lib/commpage/Makefile.shared.targ @@ -10,7 +10,7 @@ # # -# Copyright 2016 Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # # @@ -23,7 +23,7 @@ pics/%.o: $(SRC)/lib/commpage/common/%.c pics/%.o: $(SRC)/lib/commpage/$(TARGET_ARCH)/%.s $(COMMPAGE_OFFSETS_H) $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) $(COMMPAGE_OFFSETS_H): $(COMMPAGE_OFFSETS_SRC) $(OFFSETS_CREATE) <$(COMMPAGE_OFFSETS_SRC) >$@ diff --git a/usr/src/lib/libc/Makefile.targ b/usr/src/lib/libc/Makefile.targ index 8721e8ec21..c69897fb79 100644 --- a/usr/src/lib/libc/Makefile.targ +++ b/usr/src/lib/libc/Makefile.targ @@ -21,8 +21,8 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. -# Copyright 2018 Joyent, Inc. # +# Copyright (c) 2019, Joyent, Inc. # # libc build rules @@ -32,7 +32,7 @@ # pics/%.o: $(OPTIMIZED_LIBCBASE)/gen/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/crt/%.c $(COMPILE.c) -o $@ $< @@ -40,7 +40,7 @@ pics/%.o: $(LIBCBASE)/crt/%.c pics/%.o: $(LIBCBASE)/crt/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/gen/%.c $(COMPILE.c) -o $@ $< @@ -48,15 +48,15 @@ pics/%.o: $(LIBCBASE)/gen/%.c pics/%.o: $(LIBCBASE)/gen/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/gen/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/_stack_grow.o: $(LIBCBASE)/../$(TARGET_ARCH)/gen/_stack_grow.s $(BUILD.s) $(LIBCBASE)/../$(TARGET_ARCH)/gen/_stack_grow.s - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/fp/%.c $(COMPILE.c) -o $@ $< @@ -68,7 +68,7 @@ pics/%.o: $(LIBCBASE)/../$(MACH)/fp/%.c pics/%.o: $(LIBCBASE)/fp/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/fp/%.c $(COMPILE.c) -o $@ $< @@ -76,7 +76,7 @@ pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/fp/%.c pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/fp/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/sys/%.c $(COMPILE.c) -o $@ $< @@ -84,15 +84,15 @@ pics/%.o: $(LIBCBASE)/sys/%.c pics/%.o: $(LIBCBASE)/../common/sys/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/sys/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../$(MACH)/sys/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../$(MACH)/sys/%.c $(COMPILE.c) -o $@ $< @@ -104,17 +104,17 @@ pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/sys/%.c pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/sys/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) # rules to build large file aware objects (xxx64.o from xxx.s or xxx.c) pics/%64.o: $(LIBCBASE)/../common/sys/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%64.o: $(LIBCBASE)/sys/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%64.o: $(LIBCBASE)/gen/%.c $(COMPILE.c) -o $@ $< @@ -245,7 +245,7 @@ pics/%.o: $(LIBCBASE)/threads/%.c pics/%.o: $(LIBCBASE)/threads/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/threads/%.c $(COMPILE.c) -o $@ $< @@ -253,7 +253,7 @@ pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/threads/%.c pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/threads/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/unwind/%.c $(COMPILE.c) -o $@ $< @@ -261,7 +261,7 @@ pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/unwind/%.c pics/%.o: $(LIBCBASE)/../$(TARGET_ARCH)/unwind/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../port/unwind/%.c $(COMPILE.c) -o $@ $< @@ -269,7 +269,7 @@ pics/%.o: $(LIBCBASE)/../port/unwind/%.c pics/%.o: $(LIBCBASE)/../$(MACH)/unwind/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(LIBCBASE)/../port/sys/%.c $(COMPILE.c) -o $@ $< @@ -281,12 +281,12 @@ pics/%.o: $(LIBCBASE)/../../crt/common/%.c pics/%.o: $(LIBCBASE)/$(CRTSRCS)/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) # $(SRC)/common rules pics/%.o: $(SRC)/common/atomic/$(TARGETMACH)/%.s $(BUILD.s) - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) $(COMOBJS:%=pics/%): $(SRC)/common/util/$$(@F:.o=.c) $(COMPILE.c) -o $@ $(SRC)/common/util/$(@F:.o=.c) diff --git a/usr/src/lib/libc/capabilities/Makefile.targ b/usr/src/lib/libc/capabilities/Makefile.targ index c2c6951f0d..d9f7891f22 100644 --- a/usr/src/lib/libc/capabilities/Makefile.targ +++ b/usr/src/lib/libc/capabilities/Makefile.targ @@ -22,6 +22,8 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # +# Copyright (c) 2019, Joyent, Inc. +# $(SYMCAP): $(OBJCAP) $(OBJCAP): $(PICS) @@ -31,11 +33,11 @@ $(PICS): pics pics/%.o: ../../$(TRG_PLATFORM)/common/%.s $(COMPILE.s) $< -o $@ - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: ../../$(ALT_PLATFORM)/common/%.s $(COMPILE.s) $< -o $@ - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) # Combine all pic objects into one relocatable object. Assign any capabilities # to this object, and define the interface. diff --git a/usr/src/lib/libc_db/Makefile.com b/usr/src/lib/libc_db/Makefile.com index 36c954e36c..9fb18a576c 100644 --- a/usr/src/lib/libc_db/Makefile.com +++ b/usr/src/lib/libc_db/Makefile.com @@ -22,7 +22,7 @@ # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. LIBRARY = libc_db.a VERS = .1 @@ -63,4 +63,4 @@ include ../../Makefile.targ pics/%.o: $(CRTSRCS)/%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) diff --git a/usr/src/lib/libcpc/Makefile.com b/usr/src/lib/libcpc/Makefile.com index 8e95766942..78ed2818ad 100644 --- a/usr/src/lib/libcpc/Makefile.com +++ b/usr/src/lib/libcpc/Makefile.com @@ -21,7 +21,7 @@ # # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. LIBRARY = libcpc.a VERS = .1 @@ -31,7 +31,7 @@ OBJECTS = $(ASOBJS) $(MACHCOBJS) $(COBJS) $(V1_OBJS) include ../../Makefile.lib -SRCS = $(ASOBJS:%.o=../$(MACH)/%.s) \ +SRCS = $(ASOBJS:%.o=../$(MACH)/%.s) \ $(MACHCOBJS:%.o=../$(MACH)/%.c) \ $(V1_OBJS:%.o=../common/%.c) \ $(COBJS:%.o=../common/%.c) @@ -66,4 +66,4 @@ pics/%.o: ../$(MACH)/%.c pics/%.o: ../$(MACH)/%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) diff --git a/usr/src/lib/libctf/common/ctf_convert.c b/usr/src/lib/libctf/common/ctf_convert.c index 7190e66718..9441aa6ed7 100644 --- a/usr/src/lib/libctf/common/ctf_convert.c +++ b/usr/src/lib/libctf/common/ctf_convert.c @@ -21,6 +21,7 @@ */ #include <libctf_impl.h> +#include <assert.h> #include <gelf.h> ctf_convert_f ctf_converters[] = { @@ -29,76 +30,73 @@ ctf_convert_f ctf_converters[] = { #define NCONVERTS (sizeof (ctf_converters) / sizeof (ctf_convert_f)) -typedef enum ctf_convert_source { - CTFCONV_SOURCE_NONE = 0x0, - CTFCONV_SOURCE_UNKNOWN = 0x01, - CTFCONV_SOURCE_C = 0x02, - CTFCONV_SOURCE_S = 0x04 -} ctf_convert_source_t; - -static void -ctf_convert_ftypes(Elf *elf, ctf_convert_source_t *types) +ctf_hsc_ret_t +ctf_has_c_source(Elf *elf, char *errmsg, size_t errlen) { - int i; - Elf_Scn *scn = NULL, *strscn; - *types = CTFCONV_SOURCE_NONE; - GElf_Shdr shdr; + ctf_hsc_ret_t ret = CHR_NO_C_SOURCE; + Elf_Scn *scn, *strscn; Elf_Data *data, *strdata; + GElf_Shdr shdr; + ulong_t i; + scn = NULL; while ((scn = elf_nextscn(elf, scn)) != NULL) { - - if (gelf_getshdr(scn, &shdr) == NULL) - return; + if (gelf_getshdr(scn, &shdr) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to get section header: %s", + elf_errmsg(elf_errno())); + return (CHR_ERROR); + } if (shdr.sh_type == SHT_SYMTAB) break; } if (scn == NULL) - return; + return (CHR_NO_C_SOURCE); - if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL) - return; + if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL) { + (void) snprintf(errmsg, errlen, "failed to get str section: %s", + elf_errmsg(elf_errno())); + return (CHR_ERROR); + } - if ((data = elf_getdata(scn, NULL)) == NULL) - return; + if ((data = elf_getdata(scn, NULL)) == NULL) { + (void) snprintf(errmsg, errlen, "failed to read section: %s", + elf_errmsg(elf_errno())); + return (CHR_ERROR); + } - if ((strdata = elf_getdata(strscn, NULL)) == NULL) - return; + if ((strdata = elf_getdata(strscn, NULL)) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to read string table: %s", elf_errmsg(elf_errno())); + return (CHR_ERROR); + } for (i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) { GElf_Sym sym; const char *file; size_t len; - if (gelf_getsym(data, i, &sym) == NULL) - return; + if (gelf_getsym(data, i, &sym) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to read sym %lu: %s", + i, elf_errmsg(elf_errno())); + return (CHR_ERROR); + } if (GELF_ST_TYPE(sym.st_info) != STT_FILE) continue; file = (const char *)((uintptr_t)strdata->d_buf + sym.st_name); len = strlen(file); - if (len < 2 || file[len - 2] != '.') { - *types |= CTFCONV_SOURCE_UNKNOWN; - continue; - } - - switch (file[len - 1]) { - case 'c': - *types |= CTFCONV_SOURCE_C; - break; - case 'h': - /* We traditionally ignore header files... */ - break; - case 's': - *types |= CTFCONV_SOURCE_S; - break; - default: - *types |= CTFCONV_SOURCE_UNKNOWN; + if (len >= 2 && strncmp(".c", &file[len - 2], 2) == 0) { + ret = CHR_HAS_C_SOURCE; break; } } + + return (ret); } ctf_file_t * @@ -107,8 +105,6 @@ ctf_elfconvert(int fd, Elf *elf, const char *label, uint_t nthrs, uint_t flags, { int err, i; ctf_file_t *fp = NULL; - boolean_t notsup = B_TRUE; - ctf_convert_source_t type; if (errp == NULL) errp = &err; @@ -118,7 +114,7 @@ ctf_elfconvert(int fd, Elf *elf, const char *label, uint_t nthrs, uint_t flags, return (NULL); } - if (flags & ~CTF_CONVERT_F_IGNNONC) { + if (flags & ~CTF_ALLOW_MISSING_DEBUG) { *errp = EINVAL; return (NULL); } @@ -128,47 +124,35 @@ ctf_elfconvert(int fd, Elf *elf, const char *label, uint_t nthrs, uint_t flags, return (NULL); } - ctf_convert_ftypes(elf, &type); - ctf_dprintf("got types: %d\n", type); - if (flags & CTF_CONVERT_F_IGNNONC) { - if (type == CTFCONV_SOURCE_NONE || - (type & CTFCONV_SOURCE_UNKNOWN)) { - *errp = ECTF_CONVNOCSRC; - return (NULL); - } + switch (ctf_has_c_source(elf, errbuf, errlen)) { + case CHR_ERROR: + *errp = ECTF_ELF; + return (NULL); + + case CHR_NO_C_SOURCE: + *errp = ECTF_CONVNOCSRC; + return (NULL); + + default: + break; } for (i = 0; i < NCONVERTS; i++) { - ctf_conv_status_t cs; - fp = NULL; - cs = ctf_converters[i](fd, elf, nthrs, errp, &fp, errbuf, - errlen); - if (cs == CTF_CONV_SUCCESS) { - notsup = B_FALSE; - break; - } - if (cs == CTF_CONV_ERROR) { - fp = NULL; - notsup = B_FALSE; + err = ctf_converters[i](fd, elf, nthrs, flags, + &fp, errbuf, errlen); + + if (err != ECTF_CONVNODEBUG) break; - } } - if (notsup == B_TRUE) { - if ((flags & CTF_CONVERT_F_IGNNONC) != 0 && - (type & CTFCONV_SOURCE_C) == 0) { - *errp = ECTF_CONVNOCSRC; - return (NULL); - } - *errp = ECTF_NOCONVBKEND; + if (err != 0) { + assert(fp == NULL); + *errp = err; return (NULL); } - /* - * Succsesful conversion. - */ - if (fp != NULL && label != NULL) { + if (label != NULL) { if (ctf_add_label(fp, label, fp->ctf_typemax, 0) == CTF_ERR) { *errp = ctf_errno(fp); ctf_close(fp); diff --git a/usr/src/lib/libctf/common/ctf_dwarf.c b/usr/src/lib/libctf/common/ctf_dwarf.c index 7cd02db43c..aa55127d26 100644 --- a/usr/src/lib/libctf/common/ctf_dwarf.c +++ b/usr/src/lib/libctf/common/ctf_dwarf.c @@ -883,7 +883,7 @@ ctf_dwarf_dwarf_base(ctf_cu_t *cup, Dwarf_Die die, int *kindp, break; default: (void) snprintf(cup->cu_errbuf, cup->cu_errlen, - "encountered unkown DWARF encoding: %d", type); + "encountered unknown DWARF encoding: %d", type); return (ECTF_CONVBKERR); } @@ -1778,6 +1778,7 @@ ctf_dwarf_convert_type(ctf_cu_t *cup, Dwarf_Die die, ctf_id_t *idp, break; default: ctf_dprintf("ignoring tag type %x\n", tag); + *idp = CTF_ERR; ret = 0; break; } @@ -2677,7 +2678,8 @@ ctf_dwarf_free_die(ctf_cu_t *cup) } ctf_dprintf("Trying to clean up dwarf_t: %p\n", cup->cu_dwarf); - (void) dwarf_finish(cup->cu_dwarf, &derr); + if (cup->cu_dwarf != NULL) + (void) dwarf_finish(cup->cu_dwarf, &derr); cup->cu_dwarf = NULL; ctf_close(cup->cu_ctfp); @@ -2727,13 +2729,6 @@ ctf_dwarf_count_dies(Dwarf_Debug dw, Dwarf_Error *derr, int *ndies, *ndies = *ndies + 1; } - if (*ndies == 0) { - (void) snprintf(errbuf, errlen, - "file does not contain valid DWARF data: %s\n", - dwarf_errmsg(*derr)); - return (ECTF_CONVBKERR); - } - return (0); } @@ -2769,10 +2764,9 @@ ctf_dwarf_init_die(int fd, Elf *elf, ctf_cu_t *cup, int ndie, char *errbuf, cup->cu_elf = elf; cup->cu_maxoff = nexthdr - 1; cup->cu_ctfp = ctf_fdcreate(fd, &ret); - if (cup->cu_ctfp == NULL) { - ctf_free(cup, sizeof (ctf_cu_t)); + if (cup->cu_ctfp == NULL) return (ret); - } + avl_create(&cup->cu_map, ctf_dwmap_comp, sizeof (ctf_dwmap_t), offsetof(ctf_dwmap_t, cdm_avl)); cup->cu_errbuf = errbuf; @@ -2782,46 +2776,32 @@ ctf_dwarf_init_die(int fd, Elf *elf, ctf_cu_t *cup, int ndie, char *errbuf, bzero(&cup->cu_bitfields, sizeof (ctf_list_t)); if ((ret = ctf_dwarf_die_elfenc(elf, cup, errbuf, - errlen)) != 0) { - avl_destroy(&cup->cu_map); - ctf_free(cup, sizeof (ctf_cu_t)); + errlen)) != 0) return (ret); - } - if ((ret = ctf_dwarf_sib(cup, NULL, &cu)) != 0) { - avl_destroy(&cup->cu_map); - ctf_free(cup, sizeof (ctf_cu_t)); + if ((ret = ctf_dwarf_sib(cup, NULL, &cu)) != 0) return (ret); - } + if (cu == NULL) { (void) snprintf(errbuf, errlen, - "file does not contain DWARF data\n"); - avl_destroy(&cup->cu_map); - ctf_free(cup, sizeof (ctf_cu_t)); - return (ECTF_CONVBKERR); + "file does not contain DWARF data"); + return (ECTF_CONVNODEBUG); } - if ((ret = ctf_dwarf_child(cup, cu, &child)) != 0) { - avl_destroy(&cup->cu_map); - ctf_free(cup, sizeof (ctf_cu_t)); + if ((ret = ctf_dwarf_child(cup, cu, &child)) != 0) return (ret); - } + if (child == NULL) { (void) snprintf(errbuf, errlen, - "file does not contain DWARF data\n"); - avl_destroy(&cup->cu_map); - ctf_free(cup, sizeof (ctf_cu_t)); - return (ECTF_CONVBKERR); + "file does not contain DWARF data"); + return (ECTF_CONVNODEBUG); } cup->cu_cuoff = offset; cup->cu_cu = child; - if ((cup->cu_cmh = ctf_merge_init(fd, &ret)) == NULL) { - avl_destroy(&cup->cu_map); - ctf_free(cup, sizeof (ctf_cu_t)); + if ((cup->cu_cmh = ctf_merge_init(fd, &ret)) == NULL) return (ret); - } if (ctf_dwarf_string(cup, cu, DW_AT_name, &name) == 0) { size_t len = strlen(name) + 1; @@ -2835,41 +2815,143 @@ ctf_dwarf_init_die(int fd, Elf *elf, ctf_cu_t *cup, int ndie, char *errbuf, return (0); } +/* + * This is our only recourse to identify a C source file that is missing debug + * info: it will be mentioned as an STT_FILE, but not have a compile unit entry. + * (A traditional ctfmerge works on individual files, so can identify missing + * DWARF more directly, via ctf_has_c_source() on the .o file.) + * + * As we operate on basenames, this can of course miss some cases, but it's + * better than not checking at all. + * + * We explicitly whitelist some CRT components. Failing that, there's always + * the -m option. + */ +static boolean_t +c_source_has_debug(const char *file, ctf_cu_t *cus, size_t nr_cus) +{ + const char *basename = strrchr(file, '/'); + + if (basename == NULL) + basename = file; + else + basename++; + + if (strcmp(basename, "common-crt.c") == 0 || + strcmp(basename, "gmon.c") == 0 || + strcmp(basename, "dlink_init.c") == 0 || + strcmp(basename, "dlink_common.c") == 0 || + strncmp(basename, "crt", strlen("crt")) == 0 || + strncmp(basename, "values-", strlen("values-")) == 0) + return (B_TRUE); -ctf_conv_status_t -ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp, + for (size_t i = 0; i < nr_cus; i++) { + if (strcmp(basename, cus[i].cu_name) == 0) + return (B_TRUE); + } + + return (B_FALSE); +} + +static int +ctf_dwarf_check_missing(ctf_cu_t *cus, size_t nr_cus, Elf *elf, char *errmsg, size_t errlen) { + Elf_Scn *scn, *strscn; + Elf_Data *data, *strdata; + GElf_Shdr shdr; + ulong_t i; + + scn = NULL; + while ((scn = elf_nextscn(elf, scn)) != NULL) { + if (gelf_getshdr(scn, &shdr) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to get section header: %s\n", + elf_errmsg(elf_errno())); + return (EINVAL); + } + + if (shdr.sh_type == SHT_SYMTAB) + break; + } + + if (scn == NULL) + return (0); + + if ((strscn = elf_getscn(elf, shdr.sh_link)) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to get str section: %s\n", + elf_errmsg(elf_errno())); + return (EINVAL); + } + + if ((data = elf_getdata(scn, NULL)) == NULL) { + (void) snprintf(errmsg, errlen, "failed to read section: %s\n", + elf_errmsg(elf_errno())); + return (EINVAL); + } + + if ((strdata = elf_getdata(strscn, NULL)) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to read string table: %s\n", + elf_errmsg(elf_errno())); + return (EINVAL); + } + + for (i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) { + GElf_Sym sym; + const char *file; + size_t len; + + if (gelf_getsym(data, i, &sym) == NULL) { + (void) snprintf(errmsg, errlen, + "failed to read sym %lu: %s\n", + i, elf_errmsg(elf_errno())); + return (EINVAL); + } + + if (GELF_ST_TYPE(sym.st_info) != STT_FILE) + continue; + + file = (const char *)((uintptr_t)strdata->d_buf + sym.st_name); + len = strlen(file); + if (len < 2 || strncmp(".c", &file[len - 2], 2) != 0) + continue; + + if (!c_source_has_debug(file, cus, nr_cus)) { + (void) snprintf(errmsg, errlen, + "file %s is missing debug info\n", file); + return (ECTF_CONVNODEBUG); + } + } + + return (0); +} + +int +ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, uint_t flags, + ctf_file_t **fpp, char *errbuf, size_t errlen) +{ int err, ret, ndies, i; Dwarf_Debug dw; Dwarf_Error derr; ctf_cu_t *cdies = NULL, *cup; workq_t *wqp = NULL; - if (errp == NULL) - errp = &err; - *errp = 0; *fpp = NULL; ret = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dw, &derr); if (ret != DW_DLV_OK) { - /* - * We may want to expect DWARF data here and fail conversion if - * it's missing. In this case, if we actually have some amount - * of DWARF, but no section, for now, just go ahead and create - * an empty CTF file. - */ if (ret == DW_DLV_NO_ENTRY || dwarf_errno(derr) == DW_DLE_DEBUG_INFO_NULL) { - *fpp = ctf_create(errp); - return (*fpp != NULL ? CTF_CONV_SUCCESS : - CTF_CONV_ERROR); + (void) snprintf(errbuf, errlen, + "file does not contain DWARF data\n"); + return (ECTF_CONVNODEBUG); } - (void) snprintf(errmsg, errlen, - "failed to initialize DWARF: %s\n", - dwarf_errmsg(derr)); - *errp = ECTF_CONVBKERR; - return (CTF_CONV_ERROR); + + (void) snprintf(errbuf, errlen, + "dwarf_elf_init() failed: %s\n", dwarf_errmsg(derr)); + return (ECTF_CONVBKERR); } /* @@ -2880,42 +2962,47 @@ ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp, * only a single Dwarf_Debug as well. */ ndies = 0; - ret = ctf_dwarf_count_dies(dw, &derr, &ndies, errmsg, errlen); - if (ret != 0) { - *errp = ret; - goto out; + err = ctf_dwarf_count_dies(dw, &derr, &ndies, errbuf, errlen); + + ctf_dprintf("found %d DWARF CUs\n", ndies); + + if (ndies == 0) { + (void) snprintf(errbuf, errlen, + "file does not contain DWARF data\n"); + return (ECTF_CONVNODEBUG); } (void) dwarf_finish(dw, &derr); cdies = ctf_alloc(sizeof (ctf_cu_t) * ndies); if (cdies == NULL) { - *errp = ENOMEM; - return (CTF_CONV_ERROR); + return (ENOMEM); } + bzero(cdies, sizeof (ctf_cu_t) * ndies); + for (i = 0; i < ndies; i++) { cup = &cdies[i]; ret = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &cup->cu_dwarf, &derr); if (ret != 0) { ctf_free(cdies, sizeof (ctf_cu_t) * ndies); - (void) snprintf(errmsg, errlen, + (void) snprintf(errbuf, errlen, "failed to initialize DWARF: %s\n", dwarf_errmsg(derr)); - *errp = ECTF_CONVBKERR; - return (CTF_CONV_ERROR); + return (ECTF_CONVBKERR); } - ret = ctf_dwarf_init_die(fd, elf, &cdies[i], i, errmsg, errlen); - if (ret != 0) { - *errp = ret; + err = ctf_dwarf_init_die(fd, elf, cup, i, errbuf, errlen); + if (err != 0) goto out; - } cup->cu_doweaks = ndies > 1 ? B_FALSE : B_TRUE; } - ctf_dprintf("found %d DWARF CUs\n", ndies); + if (!(flags & CTF_ALLOW_MISSING_DEBUG) && + (err = ctf_dwarf_check_missing(cdies, ndies, + elf, errbuf, errlen)) != 0) + goto out; /* * If we only have one compilation unit, there's no reason to use @@ -2926,7 +3013,7 @@ ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp, nthrs = 1; if (workq_init(&wqp, nthrs) == -1) { - *errp = errno; + err = errno; goto out; } @@ -2935,18 +3022,18 @@ ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp, ctf_dprintf("adding cu %s: %p, %x %x\n", cup->cu_name, cup->cu_cu, cup->cu_cuoff, cup->cu_maxoff); if (workq_add(wqp, cup) == -1) { - *errp = errno; + err = errno; goto out; } } - ret = workq_work(wqp, ctf_dwarf_convert_one, NULL, errp); + ret = workq_work(wqp, ctf_dwarf_convert_one, NULL, &err); if (ret == WORKQ_ERROR) { - *errp = errno; + err = errno; goto out; } else if (ret == WORKQ_UERROR) { ctf_dprintf("internal convert failed: %s\n", - ctf_errmsg(*errp)); + ctf_errmsg(err)); goto out; } @@ -2954,44 +3041,37 @@ ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp, if (ndies != 1) { ctf_merge_t *cmp; - cmp = ctf_merge_init(fd, &ret); - if (cmp == NULL) { - *errp = ret; + cmp = ctf_merge_init(fd, &err); + if (cmp == NULL) goto out; - } ctf_dprintf("setting threads\n"); - if ((ret = ctf_merge_set_nthreads(cmp, nthrs)) != 0) { + if ((err = ctf_merge_set_nthreads(cmp, nthrs)) != 0) { ctf_merge_fini(cmp); - *errp = ret; goto out; } for (i = 0; i < ndies; i++) { cup = &cdies[i]; - ctf_dprintf("adding cu %s (%p)\n", cup->cu_name, - cup->cu_ctfp); - if ((ret = ctf_merge_add(cmp, cup->cu_ctfp)) != 0) { + if ((err = ctf_merge_add(cmp, cup->cu_ctfp)) != 0) { ctf_merge_fini(cmp); - *errp = ret; goto out; } } ctf_dprintf("performing merge\n"); - ret = ctf_merge_merge(cmp, fpp); - if (ret != 0) { + err = ctf_merge_merge(cmp, fpp); + if (err != 0) { ctf_dprintf("failed merge!\n"); *fpp = NULL; ctf_merge_fini(cmp); - *errp = ret; goto out; } ctf_merge_fini(cmp); - *errp = 0; + err = 0; ctf_dprintf("successfully converted!\n"); } else { - *errp = 0; + err = 0; *fpp = cdies->cu_ctfp; cdies->cu_ctfp = NULL; ctf_dprintf("successfully converted!\n"); @@ -3000,5 +3080,5 @@ ctf_dwarf_convert(int fd, Elf *elf, uint_t nthrs, int *errp, ctf_file_t **fpp, out: workq_fini(wqp); ctf_dwarf_free_dies(cdies, ndies); - return (*fpp != NULL ? CTF_CONV_SUCCESS : CTF_CONV_ERROR); + return (err); } diff --git a/usr/src/lib/libctf/common/libctf.h b/usr/src/lib/libctf/common/libctf.h index a5c5027048..78b0a7a786 100644 --- a/usr/src/lib/libctf/common/libctf.h +++ b/usr/src/lib/libctf/common/libctf.h @@ -24,7 +24,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2015, Joyent, Inc. + * Copyright (c) 2019, Joyent, Inc. */ /* @@ -75,12 +75,25 @@ extern int ctf_diff_functions(ctf_diff_t *, ctf_diff_func_f, void *); extern int ctf_diff_objects(ctf_diff_t *, ctf_diff_obj_f, void *); extern void ctf_diff_fini(ctf_diff_t *); -#define CTF_CONVERT_F_IGNNONC 0x01 +/* + * Normally, we return a failure if we find a C-derived compilation unit that + * lacks DWARF or CTF (as required). This flag over-rides this check. + */ +#define CTF_ALLOW_MISSING_DEBUG 0x01 + extern ctf_file_t *ctf_elfconvert(int, Elf *, const char *, uint_t, uint_t, int *, char *, size_t); extern ctf_file_t *ctf_fdconvert(int, const char *, uint_t, uint_t, int *, char *, size_t); +typedef enum ctf_hsc_ret { + CHR_ERROR = -1, + CHR_NO_C_SOURCE = 0, + CHR_HAS_C_SOURCE = 1 +} ctf_hsc_ret_t; + +extern ctf_hsc_ret_t ctf_has_c_source(Elf *, char *, size_t); + typedef struct ctf_merge_handle ctf_merge_t; extern ctf_merge_t *ctf_merge_init(int, int *); extern int ctf_merge_add(ctf_merge_t *, ctf_file_t *); diff --git a/usr/src/lib/libctf/common/libctf_impl.h b/usr/src/lib/libctf/common/libctf_impl.h index be091ef199..5c88b9454d 100644 --- a/usr/src/lib/libctf/common/libctf_impl.h +++ b/usr/src/lib/libctf/common/libctf_impl.h @@ -29,15 +29,9 @@ extern "C" { #endif -typedef enum ctf_conv_status { - CTF_CONV_SUCCESS = 0, - CTF_CONV_ERROR = 1, - CTF_CONV_NOTSUP = 2 -} ctf_conv_status_t; - -typedef ctf_conv_status_t (*ctf_convert_f)(int, Elf *, uint_t, int *, +typedef int (*ctf_convert_f)(int, Elf *, uint_t, uint_t, ctf_file_t **, char *, size_t); -extern ctf_conv_status_t ctf_dwarf_convert(int, Elf *, uint_t, int *, +extern int ctf_dwarf_convert(int, Elf *, uint_t, uint_t, ctf_file_t **, char *, size_t); /* diff --git a/usr/src/lib/libctf/common/mapfile-vers b/usr/src/lib/libctf/common/mapfile-vers index 243f072a3d..9281bbfff5 100644 --- a/usr/src/lib/libctf/common/mapfile-vers +++ b/usr/src/lib/libctf/common/mapfile-vers @@ -23,7 +23,7 @@ # # -# Copyright 2018 Joyent, Inc. +# Copyright 2019 Joyent, Inc. # # @@ -87,6 +87,7 @@ SYMBOL_VERSION SUNWprivate_1.2 { ctf_func_args_by_id; ctf_func_info_by_id; ctf_function_iter; + ctf_has_c_source; ctf_kind_name; ctf_label_info; ctf_label_iter; diff --git a/usr/src/lib/libfru/Makefile.targ b/usr/src/lib/libfru/Makefile.targ index 709e1a8159..cec17959b0 100644 --- a/usr/src/lib/libfru/Makefile.targ +++ b/usr/src/lib/libfru/Makefile.targ @@ -23,9 +23,7 @@ # Copyright (c) 2000 by Sun Microsystems, Inc. # All rights reserved. # -#pragma ident "%Z%%M% %I% %E% SMI" -# -# lib/libfru/Makefile.targ +# Copyright (c) 2019, Joyent, Inc. # include ../../Makefile.targ @@ -33,15 +31,15 @@ include ../../Makefile.targ # build rules for pics. (access sub directories) pics/%.o objs/%.o: ../libfru/%.cc $(COMPILE.cc) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_CC_O) pics/%.o objs/%.o: ../libfrureg/%.cc $(COMPILE.cc) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_CC_O) pics/%.o objs/%.o: ../libgenutil/%.cc $(COMPILE.cc) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_CC_O) # some special rules for the yacc and lex parser. (with sub directories) pics/y.tab.cc pics/y.tab.h: ../libfru/nameSyntaxYacc.y diff --git a/usr/src/lib/libm/Makefile.targ b/usr/src/lib/libm/Makefile.targ index 8d8588ad1b..e2d96834f8 100644 --- a/usr/src/lib/libm/Makefile.targ +++ b/usr/src/lib/libm/Makefile.targ @@ -12,10 +12,12 @@ # # Copyright 2011 Nexenta Systems, Inc. All rights reserved. # +# Copyright (c) 2019, Joyent, Inc. +# pics/%.o: $(LIBMDIR)/$(TARGETMACH)/src/%.$(ASSUFFIX) $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(SRCDIR)/C/%.c $(LM_IL) $(COMPILE.c) -o $@ $< diff --git a/usr/src/lib/libmvec/Makefile.com b/usr/src/lib/libmvec/Makefile.com index e574b0df22..6498f511e4 100644 --- a/usr/src/lib/libmvec/Makefile.com +++ b/usr/src/lib/libmvec/Makefile.com @@ -12,6 +12,8 @@ # # Copyright 2011 Nexenta Systems, Inc. All rights reserved. # +# Copyright (c) 2019, Joyent, Inc. +# LIBMDIR = $(SRC)/lib/libm @@ -159,7 +161,7 @@ LIBS = $(DYNLIB) SRCDIR = ../common/ DYNFLAGS += $(ZIGNORE) -LINTERROFF = -erroff=E_FP_DIVISION_BY_ZERO +LINTERROFF = -erroff=E_FP_DIVISION_BY_ZERO LINTERROFF += -erroff=E_FP_INVALID LINTERROFF += -erroff=E_BAD_PTR_CAST_ALIGN LINTERROFF += -erroff=E_ASSIGMENT_CAUSE_LOSS_PREC @@ -274,8 +276,8 @@ lint: lintcheck pics/%.o: ../$(TARGET_ARCH)/src/%.S $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: ../common/$$(CHIP)/%.S $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) diff --git a/usr/src/lib/libnisdb/Makefile b/usr/src/lib/libnisdb/Makefile index 762f725643..66fbf91865 100644 --- a/usr/src/lib/libnisdb/Makefile +++ b/usr/src/lib/libnisdb/Makefile @@ -23,7 +23,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. LIBRARY= libnisdb.a VERS= .2 @@ -204,14 +204,6 @@ install: all $(ROOTLIBS) $(ROOTLINKS) lint: $(DERIVED_FILES) .WAIT lintcheck -pics/%.o: %.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -pics/%.o: %.cc - $(COMPILE.cc) -o $@ $< - $(POST_PROCESS_O) - objs/%.o pics/%.o profs/%.o: $(YPTOL_DIR)/%.c $(COMPILE.c) -o $@ $< $(POST_PROCESS_O) diff --git a/usr/src/lib/libsqlite/Makefile.com b/usr/src/lib/libsqlite/Makefile.com index 6ab092d4d1..5e1f3d8072 100644 --- a/usr/src/lib/libsqlite/Makefile.com +++ b/usr/src/lib/libsqlite/Makefile.com @@ -3,7 +3,7 @@ # Use is subject to license terms. # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> # Copyright 2016 Nexenta Systems, Inc. All rights reserved. -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. # @@ -158,6 +158,8 @@ $(NATIVETARGETS) := LDLIBS = -lc $(OBJS) := CFLAGS += $(CTF_FLAGS) $(OBJS) := CTFCONVERT_POST = $(CTFCONVERT_O) +$(NATIVEOBJS) := CFLAGS += $(CTF_FLAGS) +$(NATIVEOBJS) := CTFCONVERT_POST = $(CTFCONVERT_O) TCLBASE = /usr/sfw TCLVERS = tcl8.3 diff --git a/usr/src/lib/libtnfctl/Makefile.com b/usr/src/lib/libtnfctl/Makefile.com index bbc56e5257..b9392268ce 100644 --- a/usr/src/lib/libtnfctl/Makefile.com +++ b/usr/src/lib/libtnfctl/Makefile.com @@ -22,7 +22,7 @@ # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. LIBRARY= libtnfctl.a VERS= .1 @@ -107,7 +107,7 @@ BUILD.s= $(AS) $< -o $@ objs/%.o pics/%.o: ../%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) objs/%.o pics/%.o: ../%.c $(COMPILE.c) -o $@ $< diff --git a/usr/src/lib/libtnfprobe/Makefile.com b/usr/src/lib/libtnfprobe/Makefile.com index f4df1679f3..bfdceac994 100644 --- a/usr/src/lib/libtnfprobe/Makefile.com +++ b/usr/src/lib/libtnfprobe/Makefile.com @@ -21,7 +21,7 @@ # # Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. LIBRARY= libtnfprobe.a VERS= .1 @@ -97,7 +97,7 @@ BUILD.s= $(AS) $(ASFLAGS) $< -o $@ objs/%.o pics/%.o: ../%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o objs/%.o: ../%.c $(COMPILE.c) -o $@ $< diff --git a/usr/src/lib/libumem/Makefile.targ b/usr/src/lib/libumem/Makefile.targ index c56b5fd9f5..621b935002 100644 --- a/usr/src/lib/libumem/Makefile.targ +++ b/usr/src/lib/libumem/Makefile.targ @@ -22,6 +22,7 @@ # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # Copyright (c) 2016, Chris Fraire <cfraire@me.com>. +# Copyright (c) 2019, Joyent, Inc. # # @@ -74,7 +75,7 @@ objs/%.o pics/%.o: $(ISASRCDIR)/%.c objs/%.o pics/%.o: $(ISASRCDIR)/%.s $(COMPILE.s) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) objs/%.o pics/%.o: ../common/%.c $(COMPILE.c) -o $@ $< diff --git a/usr/src/lib/pkcs11/libsoftcrypto/amd64/Makefile b/usr/src/lib/pkcs11/libsoftcrypto/amd64/Makefile index 1d184f528a..5fdac2dd0c 100644 --- a/usr/src/lib/pkcs11/libsoftcrypto/amd64/Makefile +++ b/usr/src/lib/pkcs11/libsoftcrypto/amd64/Makefile @@ -22,9 +22,8 @@ # # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2017 Jason King -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # -# Copyright (c) 2018, Joyent, Inc. LIBRARY = libsoftcrypto.a VERS = .1 @@ -87,7 +86,7 @@ pics/%.o: $(AES_DIR)/$(MACH64)/%.c pics/%.o: $(AES_DIR)/$(MACH64)/%.s $(COMPILE.s) $(AES_FLAGS) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(BIGNUM_DIR)/$(MACH64)/%.c $(COMPILE.c) $(BIGNUM_FLAGS) -o $@ $< @@ -95,11 +94,11 @@ pics/%.o: $(BIGNUM_DIR)/$(MACH64)/%.c pics/%.o: $(BIGNUM_DIR)/$(MACH64)/%.s $(COMPILE64.s) $(BIGNUM_FLAGS) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) pics/%.o: $(MODES_DIR)/$(MACH64)/%.s $(COMPILE64.s) $(MODES_FLAGS) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) include ../Makefile.targ @@ -108,4 +107,4 @@ arcfour-x86_64.s: $(ARCFOUR_DIR)/amd64/arcfour-x86_64.pl pics/%.o: arcfour-x86_64.s $(COMPILE64.s) $(ARCFOUR_FLAGS) -o $@ $< - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) diff --git a/usr/src/lib/pkcs11/libsoftcrypto/capabilities/intel/i386/Makefile b/usr/src/lib/pkcs11/libsoftcrypto/capabilities/intel/i386/Makefile index 87f618b38a..dda85c9669 100644 --- a/usr/src/lib/pkcs11/libsoftcrypto/capabilities/intel/i386/Makefile +++ b/usr/src/lib/pkcs11/libsoftcrypto/capabilities/intel/i386/Makefile @@ -22,6 +22,8 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # +# Copyright (c) 2019, Joyent, Inc. +# BIGNUM_PSM_OBJS = bignum_i386.o bignum_i386_asm.o @@ -53,4 +55,4 @@ pics/bignum_i386.o: $(BIGNUM_DIR)/i386/bignum_i386.c pics/bignum_i386_asm.o: $(BIGNUM_DIR)/i386/bignum_i386_asm.s $(COMPILE.s) -o $@ $(BIGNUM_DIR)/i386/bignum_i386_asm.s - $(POST_PROCESS_O) + $(POST_PROCESS_S_O) diff --git a/usr/src/test/crypto-tests/tests/common/Makefile b/usr/src/test/crypto-tests/tests/common/Makefile index 0779484f5f..8f818223d0 100644 --- a/usr/src/test/crypto-tests/tests/common/Makefile +++ b/usr/src/test/crypto-tests/tests/common/Makefile @@ -12,10 +12,11 @@ # # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright 2015 Nexenta Systems, Inc. All rights reserved. -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # include $(SRC)/cmd/Makefile.cmd +include $(SRC)/cmd/Makefile.ctf include $(SRC)/test/Makefile.com BASEOBJS = testfuncs.o cryptotest_pkcs.o cryptotest_kcf.o @@ -28,9 +29,11 @@ all install: $(OBJS) %.32.o: %.c $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) %.64.o: %.c $(COMPILE64.c) -o $@ $< + $(POST_PROCESS_O) lint: diff --git a/usr/src/test/util-tests/runfiles/default.run b/usr/src/test/util-tests/runfiles/default.run index 3cccf62ac9..f8569b1423 100644 --- a/usr/src/test/util-tests/runfiles/default.run +++ b/usr/src/test/util-tests/runfiles/default.run @@ -13,7 +13,7 @@ # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright 2014 Garrett D'Amore <garrett@damore.org> # Copyright 2014 Nexenta Systems, Inc. All rights reserved. -# Copyright 2018 Joyent, Inc. +# Copyright 2019, Joyent, Inc. # [DEFAULT] @@ -56,3 +56,7 @@ tests = [ 'runtests.sh' ] [/opt/util-tests/tests/demangle] tests = ['afl-fast', 'gcc-libstdc++', 'llvm-stdcxxabi'] + +[/opt/util-tests/tests/ctf] +pre = precheck +tests = [ 'ctftest' ] diff --git a/usr/src/test/util-tests/tests/ctf/Makefile b/usr/src/test/util-tests/tests/ctf/Makefile index 007d6c1c2f..9a65e51e90 100644 --- a/usr/src/test/util-tests/tests/ctf/Makefile +++ b/usr/src/test/util-tests/tests/ctf/Makefile @@ -18,7 +18,11 @@ include $(SRC)/Makefile.master ROOTOPTPKG = $(ROOT)/opt/util-tests TESTDIR = $(ROOTOPTPKG)/tests/ctf -SCRIPTS = ctftest.ksh +SCRIPTS = precheck.ksh \ + ctftest.ksh \ + ctftest-convert-non-c.ksh \ + ctftest-convert-no-dwarf.ksh \ + ctftest-merge-no-ctf.ksh \ TESTS = test-float.c \ test-reference.c \ diff --git a/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh b/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh new file mode 100644 index 0000000000..2183696aba --- /dev/null +++ b/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh @@ -0,0 +1,141 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# Copyright (c) 2019, Joyent, Inc. +# + +set -e + +result=0 + +progname=$(basename $0) + +fail() +{ + echo "Failed: $*" 2>&1 + result=1 +} + +fail_no_debug() +{ + cmd="$@" + set +e + out=$($ctf_convert $cmd 2>&1) + + if [[ $? -eq 0 ]]; then + fail "$cmd succeeded but should have failed" + set -e + return; + fi + + set -e + + if echo "$out" | grep "is missing debug info" >/dev/null; then + return; + fi + + if echo "$out" | grep "does not contain DWARF data" >/dev/null; then + return; + fi + fail "$cmd: incorrect output $out" +} + +has_ctf() +{ + for f in "$@"; do + if ! elfdump -c -N .SUNW_ctf "$f" | + grep '.SUNW_ctf' >/dev/null; then + fail "$f lacks CTF section" + return + fi + done +} + +cat <<EOF >file1.c +#include <stdio.h> +struct foo { int a; }; +int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); } +EOF + +cat <<EOF >file2.c +#include <stdio.h> +char myfunc(int a) { printf("%d\n", a); } +EOF + +cat <<EOF >file3.cc +struct bar { char *tar; }; +void mycxxfunc(char *c) { c[0] = '9'; }; +EOF + +cat <<EOF >file4.s +.globl caller +.type caller,@function +caller: + movl 4(%ebp), %eax + ret +EOF + +echo "$progname: An empty file should fail conversion due to no DWARF" +echo >emptyfile.c + +$ctf_cc -c -o emptyfile.o emptyfile.c +fail_no_debug emptyfile.o +$ctf_cc -c -o emptyfile.o emptyfile.c +$ctf_convert -m emptyfile.o + +$ctf_cc $ctf_debugflags -c -o emptyfile.o emptyfile.c +fail_no_debug emptyfile.o +$ctf_cc $ctf_debugflags -c -o emptyfile.o emptyfile.c +$ctf_convert -m emptyfile.o + +echo "$progname: A file missing DWARF should fail conversion" + +$ctf_cc -c -o file1.o file1.c +fail_no_debug file1.o +$ctf_cc -c -o file1.o file1.c +$ctf_convert -m file1.o + +echo "$progname: A binary with DWARF but 0 debug dies should fail conversion" + +$ctf_cc -o mybin file1.c +fail_no_debug mybin +$ctf_cc -o mybin file1.c +$ctf_convert -m mybin + +echo "$progname: One C file missing DWARF should fail ctfconvert" + +$ctf_cc -c -o file1.o file1.c +$ctf_cc $ctf_debugflags -c -o file2.o file2.c +ld -r -o files.o file2.o file1.o +fail_no_debug files.o +ld -r -o files.o file2.o file1.o +$ctf_convert -m files.o +has_ctf files.o + +echo "$progname: One .cc file missing DWARF should pass" + +$ctf_cc $ctf_debugflags -c -o file1.o file1.c +$ctf_cc $ctf_debugflags -c -o file2.o file2.c +$ctf_cxx -c -o file3.o file3.cc +ld -r -o files.o file1.o file2.o file3.o +$ctf_convert files.o +has_ctf files.o + +echo "$progname: One .s file missing DWARF should pass" +$ctf_cc $ctf_debugflags -c -o file1.o file1.c +$ctf_cc $ctf_debugflags -c -o file2.o file2.c +$ctf_as -o file4.o file4.s +$ctf_cc -o mybin file1.o file2.o file4.o +$ctf_convert mybin +has_ctf mybin + +echo "result is $result" +exit $result diff --git a/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh b/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh new file mode 100755 index 0000000000..cfbdf3d724 --- /dev/null +++ b/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh @@ -0,0 +1,97 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# Copyright (c) 2019, Joyent, Inc. +# + +set -e + +result=0 + +progname=$(basename $0) + +fail() +{ + echo "Failed: $*" 2>&1 + result=1 +} + +fail_non_c() +{ + cmd="$@" + set +e + out=$($ctf_convert $cmd 2>&1) + + if [[ $? -eq 0 ]]; then + fail "$cmd succeeded but should have failed" + set -e + return; + fi + + set -e + + if ! echo "$out" | \ + grep "No C source to convert from" >/dev/null; then + fail "$cmd: incorrect output $out" + return; + fi +} + +no_ctf() +{ + for f in "$@"; do + if elfdump -c -N .SUNW_ctf "$f" | + grep '.SUNW_ctf' >/dev/null; then + fail "$f has CTF section" + return + fi + done +} + +cat <<EOF >file1.c +#include <stdio.h> +struct foo { int a; }; +int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); } +EOF + +cat <<EOF >file2.cc +struct bar { char *tar; }; +void mycxxfunc(char *c) { c[0] = '9'; }; +EOF + +cat <<EOF >file3.s +.globl caller +.type caller,@function +caller: + movl 4(%ebp), %eax + ret +EOF + +echo "$progname: ctfconvert should fail on a .cc-derived object" +$ctf_cxx -c -o file2.o file2.cc +fail_non_c file2.o +$ctf_cxx -c -o file2.o file2.cc +$ctf_convert -i file2.o + +echo "$progname: ctfconvert shouldn't process .cc-derived DWARF" +$ctf_cc $DEBUGFLAGS -c -o file2.o file2.cc +$ctf_convert -i file2.o +no_ctf file2.o + +echo "$progname: ctfconvert should fail on a .s-derived object" +$ctf_as -o file3.o file3.s +fail_non_c file3.o +$ctf_as -o file3.o file3.s +$ctf_convert -i file3.o +no_ctf file3.o + +echo "result is $result" +exit $result diff --git a/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh b/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh new file mode 100644 index 0000000000..ac27c08d6c --- /dev/null +++ b/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh @@ -0,0 +1,117 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# Copyright (c) 2019, Joyent, Inc. +# + +set -e + +result=0 + +progname=$(basename $0) + +fail() +{ + echo "Failed: $*" 2>&1 + result=1 +} + +fail_no_ctf() +{ + cmd="$@" + set +e + out=$($cmd 2>&1) + + if [[ $? -eq 0 ]]; then + fail "$cmd succeeded but should have failed" + set -e + return; + fi + + set -e + + if ! echo "$out" | \ + grep "File does not contain CTF data" >/dev/null; then + fail "$cmd: incorrect output $out" + return; + fi +} + +has_ctf() +{ + for f in "$@"; do + if ! elfdump -c -N .SUNW_ctf "$f" | + grep '.SUNW_ctf' >/dev/null; then + fail "$f lacks CTF section" + return + fi + done +} + +cat <<EOF >file1.c +#include <stdio.h> +struct foo { int a; }; +struct foo foos[400]; +int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); } +EOF + +cat <<EOF >file2.c +#include <stdio.h> +struct foo { char b; float c; }; +struct foo stuff[90]; +char myfunc(int a) { printf("%d\n", a); } +EOF + +cat <<EOF >file3.cc +struct bar { char *tar; }; +void mycxxfunc(char *c) { c[0] = '9'; }; +EOF + +cat <<EOF >file4.s +.globl caller +.type caller,@function +caller: + movl 4(%ebp), %eax + ret +EOF + +echo "$progname: ctfmerge should fail if one C-source lacks CTF" + +$ctf_cc $ctf_debugflags -c -o file1.o file1.c +$ctf_convert file1.o +$ctf_cc -c -o file2.o file2.c +ld -r -o files.o file2.o file1.o +fail_no_ctf $ctf_merge -o files.o file2.o file1.o +ld -r -o files.o file2.o file1.o +$ctf_merge -m -o files.o file2.o file1.o +has_ctf files.o +$ctf_cc -o mybin file2.o file1.o +fail_no_ctf $ctf_merge -o mybin file2.o file1.o +$ctf_cc -o mybin file2.o file1.o +$ctf_merge -m -o mybin file2.o file1.o + + +echo "$progname: ctfmerge should allow a .cc file to lack CTF" +$ctf_cxx -c -o file3.o file3.cc +ld -r -o files.o file1.o file3.o +$ctf_merge -o files.o file1.o file3.o +ld -r -o files.o file1.o file3.o +$ctf_merge -m -o files.o file1.o file3.o + +echo "$progname: ctfmerge should allow an .s file to lack CTF" +$ctf_as -o file4.o file4.s +ld -r -o files.o file4.o file1.o +$ctf_merge -o files.o file4.o file1.o +ld -r -o files.o file4.o file1.o +$ctf_merge -m -o files.o file4.o file1.o + +echo "result is $result" +exit $result diff --git a/usr/src/test/util-tests/tests/ctf/ctftest.ksh b/usr/src/test/util-tests/tests/ctf/ctftest.ksh index 62f5cc5dd7..6ed9ca76db 100644 --- a/usr/src/test/util-tests/tests/ctf/ctftest.ksh +++ b/usr/src/test/util-tests/tests/ctf/ctftest.ksh @@ -26,17 +26,18 @@ if [[ -z "$TMPDIR" ]]; then TMPDIR="/tmp" fi + ctf_arg0=$(basename $0) ctf_root=$(cd $(dirname $0) && echo $PWD) ctf_tests= -ctf_compiler="gcc" +ctf_cc="gcc" +ctf_cxx="g++" +ctf_as="as" ctf_convert="ctfconvert" ctf_merge="ctfmerge" ctf_debugflags="-gdwarf-2 " ctf_mach32="-m32" ctf_mach64="-m64" -ctf_32cflags="$ctf_mach32 $ctf_debugflags" -ctf_64cflags="$ctf_mach64 $ctf_debugflags" ctf_temp="$TMPDIR/ctftest.$$.o" ctf_makefile="Makefile.ctftest" ctf_nerrs=0 @@ -46,18 +47,19 @@ usage() typeset msg="$*" [[ -z "$msg" ]] || echo "$msg" >&2 cat <<USAGE >&2 -Usage: $ctf_arg0 [-c compiler] [-g flags] [-m ctfmerge] [-t ctfconvert] +Usage: $ctf_arg0 [-a as] [-c cc] [-C CC] [-g flags] [-m ctfmerge] [-t ctfconvert] Runs the CTF test suite - -c compiler Use the specified compiler, defaults to 'gcc' - on path. + -a assembler Use the specified assembler, defaults to 'as' + -c compiler Use the specified C compiler, defaults to 'gcc' + -C compiler Use the specified C++ compiler, defaults to 'g++' -g flags Use flags to generate debug info. Defaults to "-gdwarf-2". -m ctfmerge Use the specified ctfmerge, defaults to - 'ctfmerge' on path. + 'ctfmerge' -t ctfconvert Use the specified ctfconvert, defaults to - 'ctfconvert' on path. + 'ctfconvert' USAGE exit 2 } @@ -80,22 +82,15 @@ fatal() exit 1 } -check_env() -{ - if which "$1" 2>/dev/null >/dev/null; then - return - fi - - [[ -f "$1" ]] || fatal "failed to find tool $1" -} - announce() { cat << EOF Beginning CTF tests with the following settings: -COMPILER: $(which $ctf_compiler) -CTFCONVERT: $(which $ctf_convert) -CTFMERGE: $(which $ctf_merge) +cc: $(which $ctf_cc) +CC: $(which $ctf_cxx) +as: $(which $ctf_as) +ctfconvert: $(which $ctf_convert) +ctfmerge: $(which $ctf_merge) 32-bit CFLAGS: $ctf_32cflags 64-bit CFLAGS: $ctf_64cflags @@ -106,7 +101,7 @@ run_one() { typeset source=$1 checker=$2 flags=$3 - if ! "$ctf_compiler" $flags -o "$ctf_temp" -c "$source"; then + if ! "$ctf_cc" $flags -o "$ctf_temp" -c "$source"; then test_fail "failed to compile $source with flags: $flags" return fi @@ -146,7 +141,7 @@ run_dir() if ! make -C $dir -f Makefile.ctftest \ BUILDDIR="$outdir" \ - CC="$ctf_compiler" \ + CC="$ctf_cc" \ CFLAGS32="$ctf_mach32" \ CFLAGS64="$ctf_mach64" \ DEBUGFLAGS="$ctf_debugflags" \ @@ -210,12 +205,38 @@ run_tests() test_fail "missing checker for $t" fi done + + outdir="$TMPDIR/ctftest.$$" + + for f in $(find "$ctf_root" -maxdepth 1 -type f -name 'ctftest-*'); do + if ! mkdir $outdir; then + fatal "failed to make temporary directory '$outdir'" + fi + + echo "Running $f in $outdir" + + (cd $outdir && $f) + + if [[ $? -ne 0 ]]; then + test_fail "$f failed" + else + echo "TEST PASSED: $f" + fi + + rm -rf $outdir + done } -while getopts ":c:g:m:t:" c $@; do +while getopts ":a:C:c:g:m:t:" c $@; do case "$c" in + a) + ctf_as=$OPTARG + ;; + C) + ctf_cxx=$OPTARG + ;; c) - ctf_compiler=$OPTARG + ctf_cc=$OPTARG ;; g) ctf_debugflags=$OPTARG @@ -238,9 +259,8 @@ done ctf_32cflags="$ctf_mach32 $ctf_debugflags" ctf_64cflags="$ctf_mach64 $ctf_debugflags" -check_env "$ctf_compiler" -check_env "$ctf_convert" -check_env "$ctf_merge" +export ctf_as ctf_cc ctf_cxx ctf_debugflags ctf_merge ctf_convert + announce run_tests @@ -251,6 +271,7 @@ if [[ $ctf_nerrs -ne 0 ]]; then else printf "\n%s: %u tests failed\n" "$ctf_arg0" "$ctf_nerrs" fi + exit 1 else printf "\n%s: All tests passed successfully\n" "$ctf_arg0" exit 0 diff --git a/usr/src/test/util-tests/tests/ctf/precheck.ksh b/usr/src/test/util-tests/tests/ctf/precheck.ksh new file mode 100644 index 0000000000..bf6f6be8d8 --- /dev/null +++ b/usr/src/test/util-tests/tests/ctf/precheck.ksh @@ -0,0 +1,39 @@ +#!/usr/bin/ksh +# +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2019, Joyent, Inc. +# + +unalias -a + +check_env() +{ + if which "$1" 2>/dev/null >/dev/null; then + return + fi + + [[ -f "$1" ]] || { + echo "failed to find $1" >&2 + exit 1 + } +} + +check_env as +check_env ctfconvert +check_env ctfmerge +check_env elfdump +check_env gcc +check_env g++ +check_env ld +check_env make diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules index 958e3bbf8c..69ac2a57db 100644 --- a/usr/src/uts/common/Makefile.rules +++ b/usr/src/uts/common/Makefile.rules @@ -23,7 +23,7 @@ # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2016 Garrett D'Amore <garrett@damore.org> # Copyright 2013 Saso Kiselkov. All rights reserved. -# Copyright 2017 Joyent, Inc. +# Copyright 2019 Joyent, Inc. # Copyright 2018 Nexenta Systems, Inc. # Copyright (c) 2016 by Delphix. All rights reserved. # @@ -387,7 +387,6 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/scsi/adapters/pmcs/%.c $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/scsi/adapters/pmcs/%.bin $(COMPILE.b) -o $@ $< - $(CTFCONVERT_O) $(OBJS_DIR)/%.o: $(COMMONBASE)/fsreparse/%.c $(COMPILE.c) -o $@ $< diff --git a/usr/src/uts/common/sys/ctf_api.h b/usr/src/uts/common/sys/ctf_api.h index 073cc4f0d6..190720246f 100644 --- a/usr/src/uts/common/sys/ctf_api.h +++ b/usr/src/uts/common/sys/ctf_api.h @@ -24,7 +24,7 @@ * Use is subject to license terms. */ /* - * Copyright 2018 Joyent, Inc. + * Copyright 2019 Joyent, Inc. */ /* @@ -116,7 +116,7 @@ enum { ECTF_ZLIB, /* zlib library failure */ ECTF_CONVBKERR, /* CTF conversion backend error */ ECTF_CONVNOCSRC, /* No C source to convert from */ - ECTF_NOCONVBKEND /* No applicable conversion backend */ + ECTF_CONVNODEBUG, /* No debug info to convert into CTF */ }; /* diff --git a/usr/src/uts/intel/Makefile.rules b/usr/src/uts/intel/Makefile.rules index 7824f6c03d..998fb97496 100644 --- a/usr/src/uts/intel/Makefile.rules +++ b/usr/src/uts/intel/Makefile.rules @@ -21,7 +21,7 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. -# Copyright 2018 Joyent, Inc. All rights reserved. +# Copyright 2019 Joyent, Inc. All rights reserved. # Copyright 2017 Nexenta Systems, Inc. # @@ -302,7 +302,6 @@ $(OBJS_DIR)/kobj.o := CPPFLAGS += -D_DBOOT $(OBJS_DIR)/%.o: $(UTSBASE)/intel/$(SUBARCH_DIR)/krtld/%.s $(COMPILE.s) $(KRTLD_INC_PATH) $(KRTLD_CPPFLAGS) -o $@ $< - $(CTFCONVERT_O) $(OBJS_DIR)/%.o: $(SRC)/common/util/$(SUBARCH_DIR)/%.c $(COMPILE.c) $(KRTLD_INC_PATH) $(KRTLD_CPPFLAGS) -o $@ $< diff --git a/usr/src/uts/intel/aes/Makefile b/usr/src/uts/intel/aes/Makefile index d48f310aaa..8a85669e3d 100644 --- a/usr/src/uts/intel/aes/Makefile +++ b/usr/src/uts/intel/aes/Makefile @@ -23,9 +23,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# This makefile drives the production of the AES KEF provider. -# -# Intel implementation architecture dependent +# Copyright (c) 2019, Joyent, Inc. # # @@ -97,11 +95,10 @@ $(OBJS_DIR)/%.ln: $(COM_DIR)/amd64/%.c $(OBJS_DIR)/%.o: $(COM_DIR)/amd64/%.c $(COMPILE.c) -o $@ $(COM_DIR)/amd64/${@F:.o=.c} - $(POST_PROCESS_O) + $(CTFCONVERT_O) $(OBJS_DIR)/%.o: $(COM_DIR)/amd64/%.s $(COMPILE.s) -o $@ $(COM_DIR)/amd64/${@F:.o=.s} - $(POST_PROCESS_O) $(OBJS_DIR)/%.ln: $(COM_DIR)/amd64/%.s @($(LHEAD) $(LINT.s) $(COM_DIR)/amd64/${@F:.ln=.s} $(LTAIL)) diff --git a/usr/src/uts/intel/arcfour/Makefile b/usr/src/uts/intel/arcfour/Makefile index ba66fafbe1..81ffa27f17 100644 --- a/usr/src/uts/intel/arcfour/Makefile +++ b/usr/src/uts/intel/arcfour/Makefile @@ -23,9 +23,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# This makefile drives the production of the ARCFOUR KEF provider. -# -# Intel implementation architecture dependent +# Copyright (c) 2019, Joyent, Inc. # # @@ -92,7 +90,6 @@ include $(UTSBASE)/intel/Makefile.targ $(OBJS_DIR)/arcfour-x86_64.o: arcfour-x86_64.s $(COMPILE.s) -o $@ ${@F:.o=.s} - $(POST_PROCESS_O) $(OBJS_DIR)/arcfour-x86_64.ln: arcfour-x86_64.s @($(LHEAD) $(LINT.s) ${@F:.ln=.s} $(LTAIL)) diff --git a/usr/src/uts/intel/bignum/Makefile b/usr/src/uts/intel/bignum/Makefile index a7d2760596..4698384443 100644 --- a/usr/src/uts/intel/bignum/Makefile +++ b/usr/src/uts/intel/bignum/Makefile @@ -18,12 +18,12 @@ # # CDDL HEADER END # +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. # # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # -# This makefile drives the production of the RSA KEF provider. -# -# intel implementation architecture dependent +# Copyright (c) 2019, Joyent, Inc. # # @@ -41,9 +41,7 @@ OBJECTS = $(BIGNUM_OBJS:%=$(OBJS_DIR)/%) LINTS = $(BIGNUM_OBJS:%.o=$(LINTS_DIR)/%.ln) ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE) -BIGNUM_OBJS_32 = bignum_i386.o bignum_i386_asm.o -BIGNUM_OBJS_64 = bignum_amd64.o bignum_amd64_asm.o -BIGNUM_PSR_OBJS = $(BIGNUM_OBJS_$(CLASS)) +BIGNUM_PSR_OBJS = bignum_amd64.o bignum_amd64_asm.o # # Include common rules. @@ -90,5 +88,40 @@ install: $(INSTALL_DEPS) # include $(UTSBASE)/intel/Makefile.targ - -include Makefile.$(CLASS) +# Bignum configuration (BIGNUM_CFG): +# PSR_MUL: +# There is a processor-specific implementation bignum multiply functions +# HWCAP: +# There are multiple implementations of bignum functions, and the +# appropriate one must be chosen at run time, based on testing +# hardware capabilites. +# +# -DPSR_MUL: +# For AMD64, there is a processor-specific implementation of +# the bignum multiply functions, which takes advantage of the +# 64x64->128 bit multiply instruction. +# +# -UHWCAP: +# There is only one implementation, because the 128 bit multiply using +# general-purpose registers is faster than any MMX or SSE2 implementation. + +BIGNUM_CFG = -DPSR_MUL +CFLAGS += -xO4 -xcrossfile +$(OBJS_DIR)/bignumimpl.o $(LINTS_DIR)/bignumimpl.ln := \ + CPPFLAGS += $(BIGNUM_CFG) +$(OBJS_DIR)/bignum_amd64.o $(LINTS_DIR)/bignum_amd64.ln := \ + CPPFLAGS += $(BIGNUM_CFG) + +$(OBJS_DIR)/bignum_amd64.o: $(BIGNUMDIR)/amd64/bignum_amd64.c + $(COMPILE.c) -o $@ $(BIGNUM_CFG) $(BIGNUMDIR)/amd64/bignum_amd64.c + $(CTFCONVERT_O) + +$(OBJS_DIR)/bignum_amd64_asm.o: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s + $(COMPILE.s) -P -o $@ $(BIGNUM_CFG) \ + $(BIGNUMDIR)/amd64/bignum_amd64_asm.s + +$(LINTS_DIR)/bignum_amd64.ln: $(BIGNUMDIR)/amd64/bignum_amd64.c + @($(LHEAD) $(LINT.c) $(BIGNUMDIR)/amd64/bignum_amd64.c $(LTAIL)) + +$(LINTS_DIR)/bignum_amd64_asm.ln: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s + @($(LHEAD) $(LINT.s) $(BIGNUMDIR)/amd64/bignum_amd64_asm.s $(LTAIL)) diff --git a/usr/src/uts/intel/bignum/Makefile.32 b/usr/src/uts/intel/bignum/Makefile.32 deleted file mode 100644 index ae8df68350..0000000000 --- a/usr/src/uts/intel/bignum/Makefile.32 +++ /dev/null @@ -1,64 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" -# -# Configuration and targets for bignum module -# specific to Intel 32-bit architecture, i386. -# -# Bignum configuration (BIGNUM_CFG): -# PSR_MUL: -# There is a processor-specific implementation bignum multiply functions -# HWCAP: -# There are multiple implementations of bignum functions, and the -# appropriate one must be chosen at run time, based on testing -# hardware capabilites. -# MMX_MANAGE: -# Multimedia registers must be saved and restored. -# Normally MMX_MANAGE iff _KERNEL, but for testing purposes, -# MMX_MANAGE can be defined in userland. - -BIGNUM_CFG = -DPSR_MUL -DHWCAP -DMMX_MANAGE - -LDFLAGS += -M $(BIGNUMDIR)/i386/cap_mapfile - -$(OBJS_DIR)/bignumimpl.o $(LINTS_DIR)/bignumimpl.ln := \ - CPPFLAGS += $(BIGNUM_CFG) -$(OBJS_DIR)/bignum_i386.o $(LINTS_DIR)/bignum_i386.ln := \ - CPPFLAGS += $(BIGNUM_CFG) - -$(OBJS_DIR)/bignum_i386.o: $(BIGNUMDIR)/i386/bignum_i386.c - $(COMPILE.c) -o $@ $(BIGNUMDIR)/i386/bignum_i386.c - $(CTFCONVERT_O) - $(POST_PROCESS_O) - -$(OBJS_DIR)/bignum_i386_asm.o: $(BIGNUMDIR)/i386/bignum_i386_asm.s - $(COMPILE.s) -P -o $@ $(BIGNUM_CFG) $(BIGNUMDIR)/i386/bignum_i386_asm.s - $(POST_PROCESS_O) - -$(LINTS_DIR)/bignum_i386.ln: $(BIGNUMDIR)/i386/bignum_i386.c - @($(LHEAD) $(LINT.c) $(BIGNUMDIR)/i386/bignum_i386.c $(LTAIL)) - -$(LINTS_DIR)/bignum_i386_asm.ln: $(BIGNUMDIR)/i386/bignum_i386_asm.s - @($(LHEAD) $(LINT.s) $(BIGNUMDIR)/i386/bignum_i386_asm.s $(LTAIL)) diff --git a/usr/src/uts/intel/bignum/Makefile.64 b/usr/src/uts/intel/bignum/Makefile.64 deleted file mode 100644 index 0982ba32fb..0000000000 --- a/usr/src/uts/intel/bignum/Makefile.64 +++ /dev/null @@ -1,66 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Configuration and targets for bignum module -# specific to AMD 64-bit architecture, amd64. -# -# Bignum configuration (BIGNUM_CFG): -# PSR_MUL: -# There is a processor-specific implementation bignum multiply functions -# HWCAP: -# There are multiple implementations of bignum functions, and the -# appropriate one must be chosen at run time, based on testing -# hardware capabilites. -# -# -DPSR_MUL: -# For AMD64, there is a processor-specific implementation of -# the bignum multiply functions, which takes advantage of the -# 64x64->128 bit multiply instruction. -# -# -UHWCAP: -# There is only one implementation, because the 128 bit multiply using -# general-purpose registers is faster than any MMX or SSE2 implementation. - -BIGNUM_CFG = -DPSR_MUL -CFLAGS += -xO4 -xcrossfile -$(OBJS_DIR)/bignumimpl.o $(LINTS_DIR)/bignumimpl.ln := \ - CPPFLAGS += $(BIGNUM_CFG) -$(OBJS_DIR)/bignum_amd64.o $(LINTS_DIR)/bignum_amd64.ln := \ - CPPFLAGS += $(BIGNUM_CFG) - -$(OBJS_DIR)/bignum_amd64.o: $(BIGNUMDIR)/amd64/bignum_amd64.c - $(COMPILE.c) -o $@ $(BIGNUM_CFG) $(BIGNUMDIR)/amd64/bignum_amd64.c - $(CTFCONVERT_O) - $(POST_PROCESS_O) - -$(OBJS_DIR)/bignum_amd64_asm.o: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s - $(COMPILE.s) -P -o $@ $(BIGNUM_CFG) \ - $(BIGNUMDIR)/amd64/bignum_amd64_asm.s - $(POST_PROCESS_O) - -$(LINTS_DIR)/bignum_amd64.ln: $(BIGNUMDIR)/amd64/bignum_amd64.c - @($(LHEAD) $(LINT.c) $(BIGNUMDIR)/amd64/bignum_amd64.c $(LTAIL)) - -$(LINTS_DIR)/bignum_amd64_asm.ln: $(BIGNUMDIR)/amd64/bignum_amd64_asm.s - @($(LHEAD) $(LINT.s) $(BIGNUMDIR)/amd64/bignum_amd64_asm.s $(LTAIL)) diff --git a/usr/src/uts/intel/kcf/Makefile b/usr/src/uts/intel/kcf/Makefile index 3357077237..3ce1d9720c 100644 --- a/usr/src/uts/intel/kcf/Makefile +++ b/usr/src/uts/intel/kcf/Makefile @@ -22,7 +22,7 @@ # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # # Path to the base of the uts directory tree (usually /usr/src/uts). @@ -101,7 +101,6 @@ include $(UTSBASE)/intel/Makefile.targ $(OBJS_DIR)/%.o: $(COM_DIR)/modes/amd64/%.s $(COMPILE.s) -o $@ $(COM_DIR)/modes/amd64/${@F:.o=.s} - $(POST_PROCESS_O) $(OBJS_DIR)/%.ln: $(COM_DIR)/modes/amd64/%.s @($(LHEAD) $(LINT.s) $(COM_DIR)/modes/amd64/${@F:.ln=.s} $(LTAIL)) diff --git a/usr/src/uts/intel/md5/Makefile b/usr/src/uts/intel/md5/Makefile index aaa61d3243..0f7515139a 100644 --- a/usr/src/uts/intel/md5/Makefile +++ b/usr/src/uts/intel/md5/Makefile @@ -24,9 +24,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# This makefile drives the production of the md5 crypto kernel module. -# -# intel architecture dependent +# Copyright (c) 2019, Joyent, Inc. # # @@ -103,7 +101,6 @@ md5_amd64.s: $(COMDIR)/amd64/md5_amd64.pl $(OBJS_DIR)/md5_amd64.o: md5_amd64.s $(COMPILE.s) -o $@ md5_amd64.s - $(POST_PROCESS_O) $(OBJS_DIR)/md5_amd64.ln: md5_amd64.s @($(LHEAD) $(LINT.c) md5_amd64.s $(LTAIL)) diff --git a/usr/src/uts/intel/sha1/Makefile b/usr/src/uts/intel/sha1/Makefile index 9741208e96..d0cb272374 100644 --- a/usr/src/uts/intel/sha1/Makefile +++ b/usr/src/uts/intel/sha1/Makefile @@ -18,16 +18,10 @@ # # CDDL HEADER END # -# -# uts/intel/sha1/Makefile -# # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# -# This makefile drives the production of the sha1 crypto kernel module. -# -# intel architecture dependent +# Copyright (c) 2019, Joyent, Inc. # # @@ -105,7 +99,6 @@ include $(UTSBASE)/intel/Makefile.targ $(OBJS_DIR)/sha1-x86_64.o: sha1-x86_64.s $(COMPILE.s) -o $@ ${@F:.o=.s} - $(POST_PROCESS_O) $(OBJS_DIR)/sha1-x86_64.ln: sha1-x86_64.s @($(LHEAD) $(LINT.c) ${@F:.ln=.s} $(LTAIL)) diff --git a/usr/src/uts/intel/sha2/Makefile b/usr/src/uts/intel/sha2/Makefile index e8f0be7d51..320d5700eb 100644 --- a/usr/src/uts/intel/sha2/Makefile +++ b/usr/src/uts/intel/sha2/Makefile @@ -22,11 +22,7 @@ # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# -# This makefile drives the production of the sha2 crypto kernel module. -# -# intel architecture dependent -# +# Copyright (c) 2019, Joyent, Inc. # # Path to the base of the uts directory tree (usually /usr/src/uts). @@ -105,7 +101,6 @@ include $(UTSBASE)/intel/Makefile.targ $(OBJS_DIR)/%.o: %.s $(COMPILE.s) -o $@ ${@F:.o=.s} - $(POST_PROCESS_O) $(OBJS_DIR)/%.ln: %.s @($(LHEAD) $(LINT.c) ${@F:.ln=.s} $(LTAIL)) |