diff options
Diffstat (limited to 'usr/src/cmd/sgs')
28 files changed, 238 insertions, 944 deletions
diff --git a/usr/src/cmd/sgs/ar/common/main.c b/usr/src/cmd/sgs/ar/common/main.c index a452d403ff..e5667aa196 100644 --- a/usr/src/cmd/sgs/ar/common/main.c +++ b/usr/src/cmd/sgs/ar/common/main.c @@ -25,6 +25,10 @@ * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright (c) 2018, Joyent, Inc. + */ + #include "inc.h" #include "conv.h" @@ -277,7 +281,7 @@ setup(int argc, char *argv[], Cmd_info *cmd_info) MSG_ORIG(MSG_FMT_VERSION), (const char *)SGU_PKG, (const char *)SGU_REL); - Vflag++; + Vflag++; } break; case 'C': diff --git a/usr/src/cmd/sgs/elfdump/common/elfdump.msg b/usr/src/cmd/sgs/elfdump/common/elfdump.msg index 253ea4a788..5876b59f1f 100644 --- a/usr/src/cmd/sgs/elfdump/common/elfdump.msg +++ b/usr/src/cmd/sgs/elfdump/common/elfdump.msg @@ -37,7 +37,7 @@ [-N name] [-O osabi] [-T type] [-p | -w outfile] \ file...\n" @ MSG_USAGE_DETAIL1 "\t[-c]\t\tdump section header information\n" -@ MSG_USAGE_DETAIL2 "\t[-C]\t\tdemangle C++ symbol names\n" +@ MSG_USAGE_DETAIL2 "\t[-C]\t\tdemangle symbol names\n" @ MSG_USAGE_DETAIL3 "\t[-d]\t\tdump the contents of the .dynamic section\n" @ MSG_USAGE_DETAIL4 "\t[-e]\t\tdump the elf header\n" @ MSG_USAGE_DETAIL5 "\t[-g]\t\tdump the contents of the .group sections\n" diff --git a/usr/src/cmd/sgs/libld/common/machrel.amd.c b/usr/src/cmd/sgs/libld/common/machrel.amd.c index 694a9ad8be..ebf7cc5a8f 100644 --- a/usr/src/cmd/sgs/libld/common/machrel.amd.c +++ b/usr/src/cmd/sgs/libld/common/machrel.amd.c @@ -740,7 +740,6 @@ tls_fixups(Ofl_desc *ofl, Rel_desc *arsp) DBG_CALL(Dbg_reloc_transition(ofl->ofl_lml, M_MACH, R_AMD64_TPOFF32, arsp, ld_reloc_sym_name)); arsp->rel_rtype = R_AMD64_TPOFF32; - arsp->rel_raddend = 0; return (FIX_RELOC); } @@ -764,7 +763,7 @@ ld_do_activerelocs(Ofl_desc *ofl) */ REL_CACHE_TRAVERSE(&ofl->ofl_actrels, idx, rcbp, arsp) { uchar_t *addr; - Xword value; + Xword value; Sym_desc *sdp; const char *ifl_name; Xword refaddr; diff --git a/usr/src/cmd/sgs/m4/common/m4.c b/usr/src/cmd/sgs/m4/common/m4.c index e96fb17c26..8888f49eef 100644 --- a/usr/src/cmd/sgs/m4/common/m4.c +++ b/usr/src/cmd/sgs/m4/common/m4.c @@ -30,6 +30,10 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ +/* + * Copyright (c) 2018, Joyent, Inc. + */ + #include <signal.h> #include <unistd.h> #include <fcntl.h> @@ -576,7 +580,7 @@ expand(wchar_t **a1, int c) pbstr(lquote); if (i <= 0) - break; + break; pbstr(L","); } diff --git a/usr/src/cmd/sgs/nm/amd64/Makefile b/usr/src/cmd/sgs/nm/amd64/Makefile index 0b9d1b6992..cb2d8a5fb5 100644 --- a/usr/src/cmd/sgs/nm/amd64/Makefile +++ b/usr/src/cmd/sgs/nm/amd64/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. # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. # @@ -44,10 +44,6 @@ INCLIST= -I../../include -I../../include/i386 \ -I$(SRCBASE)/uts/$(ARCH)/sys CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master) -I$(ELFCAP) -CERRWARN += -_gcc=-Wno-uninitialized - -SMOFF += precedence,indenting - LDLIBS += $(CONVLIBDIR64) $(CONV_LIB) $(ELFLIBDIR) -lelf %.o: ../common/%.c diff --git a/usr/src/cmd/sgs/nm/common/nm.c b/usr/src/cmd/sgs/nm/common/nm.c index fc3ded721e..2e750a559b 100644 --- a/usr/src/cmd/sgs/nm/common/nm.c +++ b/usr/src/cmd/sgs/nm/common/nm.c @@ -26,6 +26,7 @@ * * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2018 Jason King + * Copyright 2019, Joyent, Inc. */ #include <stdio.h> @@ -76,7 +77,7 @@ typedef struct { /* structure to translate symbol table data */ #define REG_WEAK "R*" #define REG_LOCL "r" -#define OPTSTR ":APDoxhvnursplLCVefgRTt:" /* option string for getopt() */ +#define OPTSTR ":APDoxhvniursplLCVefgRTt:" /* option string for getopt() */ #define DATESIZE 60 @@ -116,6 +117,7 @@ static int /* flags: ?_flag corresponds to ? option */ h_flag = 0, /* suppress printing of headings */ v_flag = 0, /* sort external symbols by value */ n_flag = 0, /* sort external symbols by name */ + i_flag = 0, /* don't sort symbols */ u_flag = 0, /* print only undefined symbols */ r_flag = 0, /* prepend object file or archive name */ /* to each symbol name */ @@ -210,141 +212,185 @@ main(int argc, char *argv[], char *envp[]) while ((optchar = getopt(argc, argv, optstr)) != -1) { switch (optchar) { - case 'o': if (COMPAT_FMT_FLAG(FMT_T_OCT)) - fmt_flag = FMT_T_OCT; - else - (void) fprintf(stderr, gettext( - "%s: -x or -t set, -o ignored\n"), - prog_name); - break; - case 'x': if (COMPAT_FMT_FLAG(FMT_T_HEX)) - fmt_flag = FMT_T_HEX; - else - (void) fprintf(stderr, gettext( - "%s: -o or -t set, -x ignored\n"), - prog_name); - break; - case 'h': h_flag = 1; - break; - case 'v': if (!n_flag) - v_flag = 1; - else - (void) fprintf(stderr, gettext( - "%s: -n set, -v ignored\n"), - prog_name); - break; - case 'n': if (!v_flag) - n_flag = 1; - else - (void) fprintf(stderr, gettext( - "%s: -v set, -n ignored\n"), - prog_name); - break; - case 'u': if (!e_flag && !g_flag) - u_flag = 1; - else - (void) fprintf(stderr, gettext( - "%s: -e or -g set, -u ignored\n"), - prog_name); - break; - case 'e': if (!u_flag && !g_flag) - e_flag = 1; - else - (void) fprintf(stderr, gettext( - "%s: -u or -g set, -e ignored\n"), - prog_name); - break; - case 'g': if (!u_flag && !e_flag) - g_flag = 1; - else - (void) fprintf(stderr, gettext( - "%s: -u or -e set, -g ignored\n"), - prog_name); - break; - case 'r': if (R_flag) { - R_flag = 0; - (void) fprintf(stderr, gettext( - "%s: -r set, -R ignored\n"), - prog_name); - } - r_flag = 1; - break; - case 's': s_flag = 1; - break; - case 'p': if (P_flag == 1) { - (void) fprintf(stderr, gettext( - "nm: -P set. -p ignored\n")); - } else - p_flag = 1; - break; - case 'P': if (p_flag == 1) { - (void) fprintf(stderr, gettext( - "nm: -p set. -P ignored\n")); - } else - P_flag = 1; - break; - case 'l': l_flag = 1; - break; - case 'L': if (D_flag == 1) { - (void) fprintf(stderr, gettext( - "nm: -D set. -L ignored\n")); - } else - L_flag = 1; - break; - case 'D': if (L_flag == 1) { - (void) fprintf(stderr, gettext( - "nm: -L set. -D ignored\n")); - } else - D_flag = 1; - break; + case 'o': + if (COMPAT_FMT_FLAG(FMT_T_OCT)) { + fmt_flag = FMT_T_OCT; + } else { + (void) fprintf(stderr, gettext( + "%s: -x or -t set, -o ignored\n"), + prog_name); + } + break; + case 'x': + if (COMPAT_FMT_FLAG(FMT_T_HEX)) { + fmt_flag = FMT_T_HEX; + } else { + (void) fprintf(stderr, gettext( + "%s: -o or -t set, -x ignored\n"), + prog_name); + } + break; + case 'h': + h_flag = 1; + break; + case 'v': + if (!n_flag && !i_flag) { + v_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -n or -i set, -v ignored\n"), + prog_name); + } + break; + case 'n': + if (!v_flag && !i_flag) { + n_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -v or -i set, -n ignored\n"), + prog_name); + } + break; + case 'i': + if (!n_flag && !v_flag) { + i_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -n or -v set, -i ignored\n"), + prog_name); + } + break; + case 'u': + if (!e_flag && !g_flag) { + u_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -e or -g set, -u ignored\n"), + prog_name); + } + break; + case 'e': + if (!u_flag && !g_flag) { + e_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -u or -g set, -e ignored\n"), + prog_name); + } + break; + case 'g': + if (!u_flag && !e_flag) { + g_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -u or -e set, -g ignored\n"), + prog_name); + } + break; + case 'r': + if (R_flag) { + R_flag = 0; + (void) fprintf(stderr, gettext( + "%s: -r set, -R ignored\n"), + prog_name); + } + r_flag = 1; + break; + case 's': + s_flag = 1; + break; + case 'p': + if (P_flag == 1) { + (void) fprintf(stderr, gettext( + "nm: -P set. -p ignored\n")); + } else { + p_flag = 1; + } + break; + case 'P': + if (p_flag == 1) { + (void) fprintf(stderr, gettext( + "nm: -p set. -P ignored\n")); + } else { + P_flag = 1; + } + break; + case 'l': + l_flag = 1; + break; + case 'L': + if (D_flag == 1) { + (void) fprintf(stderr, gettext( + "nm: -D set. -L ignored\n")); + } else { + L_flag = 1; + } + break; + case 'D': + if (L_flag == 1) { + (void) fprintf(stderr, gettext( + "nm: -L set. -D ignored\n")); + } else { + D_flag = 1; + } + break; case 'C': - C_flag = 1; - break; - case 'A': A_flag = 1; - break; - case 'V': V_flag = 1; - (void) fprintf(stderr, "nm: %s %s\n", - (const char *)SGU_PKG, - (const char *)SGU_REL); - break; + C_flag = 1; + break; + case 'A': + A_flag = 1; + break; + case 'V': + V_flag = 1; + (void) fprintf(stderr, "nm: %s %s\n", + (const char *)SGU_PKG, + (const char *)SGU_REL); + break; case 'f': /* -f is a noop, see man page */ - break; - case 'R': if (!r_flag) - R_flag = 1; - else - (void) fprintf(stderr, gettext( - "%s: -r set, -R ignored\n"), - prog_name); - break; + break; + case 'R': + if (!r_flag) { + R_flag = 1; + } else { + (void) fprintf(stderr, gettext( + "%s: -r set, -R ignored\n"), + prog_name); + } + break; case 'T': - break; - case 't': if (strcmp(optarg, "o") == 0) { - new_fmt_flag = FMT_T_OCT; - } else if (strcmp(optarg, "d") == 0) { - new_fmt_flag = FMT_T_DEC; - } else if (strcmp(optarg, "x") == 0) { - new_fmt_flag = FMT_T_HEX; - } else { - new_fmt_flag = FMT_T_NONE; - } - if (new_fmt_flag == FMT_T_NONE) { - errflag += 1; - (void) fprintf(stderr, gettext( -"nm: -t requires radix value (d, o, x): %s\n"), optarg); - } else if (COMPAT_FMT_FLAG(new_fmt_flag)) { - fmt_flag = new_fmt_flag; - } else { - (void) fprintf(stderr, gettext( - "nm: -t or -o or -x set. -t ignored.\n")); - } - break; - case ':': errflag += 1; + break; + case 't': + if (strcmp(optarg, "o") == 0) { + new_fmt_flag = FMT_T_OCT; + } else if (strcmp(optarg, "d") == 0) { + new_fmt_flag = FMT_T_DEC; + } else if (strcmp(optarg, "x") == 0) { + new_fmt_flag = FMT_T_HEX; + } else { + new_fmt_flag = FMT_T_NONE; + } + if (new_fmt_flag == FMT_T_NONE) { + errflag += 1; + (void) fprintf(stderr, gettext( + "nm: -t requires radix value (d, o, x): " + "%s\n"), optarg); + } else if (COMPAT_FMT_FLAG(new_fmt_flag)) { + fmt_flag = new_fmt_flag; + } else { (void) fprintf(stderr, gettext( - "nm: %c requires operand\n"), optopt); - break; - case '?': errflag += 1; - break; - default: break; + "nm: -t or -o or -x set. -t ignored.\n")); + } + break; + case ':': + errflag += 1; + (void) fprintf(stderr, gettext( + "nm: %c requires operand\n"), optopt); + break; + case '?': + errflag += 1; + break; + default: + break; } } @@ -381,7 +427,7 @@ static void usage() { (void) fprintf(stderr, gettext( -"Usage: nm [-ACDhLlnPpRrsTVv] [-efox] [-g | -u] [-t d|o|x] file ...\n")); +"Usage: nm [-ACDhiLlnPpRrsTVv] [-efox] [-g | -u] [-t d|o|x] file ...\n")); } /* @@ -451,20 +497,20 @@ each_file(char *filename) (void) printf(gettext( "\n\nUndefined symbols from %s:\n\n"), filename); - } else if (!h_flag & !P_flag) + } else if ((h_flag == 0) && (P_flag == 0)) { #else - if (!h_flag & !P_flag) + if ((h_flag == 0) && (P_flag == 0)) { #endif - { - if (p_flag) + if (p_flag) { (void) printf("\n\n%s:\n", filename); - else { - if (A_flag != 0) + } else { + if (A_flag != 0) { (void) printf("\n\n%s%s:\n", A_header, filename); - else + } else { (void) printf("\n\n%s:\n", filename); + } } } archive_name = (char *)0; @@ -616,11 +662,11 @@ print_ar_files(int fd, Elf * elf_file, char *filename) continue; } - if (!h_flag & !P_flag) { - if (p_flag) + if ((h_flag == 0) && (P_flag == 0)) { + if (p_flag) { (void) printf("\n\n%s[%s]:\n", filename, p_ar->ar_name); - else { + } else { if (A_flag != 0) (void) printf("\n\n%s%s[%s]:\n", A_header, filename, p_ar->ar_name); @@ -715,8 +761,10 @@ print_symtab(Elf *elf_file, unsigned int shstrndx, prog_name, filename); return; } - qsort((char *)sym_data, count-1, sizeof (SYM), - (int (*)(const void *, const void *))compare); + if (i_flag == 0) { + qsort((char *)sym_data, count-1, sizeof (SYM), + (int (*)(const void *, const void *))compare); + } s = sym_data; while (count > 1) { #ifndef XPG4 @@ -725,18 +773,19 @@ print_symtab(Elf *elf_file, unsigned int shstrndx, * U_flag specified */ print_with_uflag(sym_data, filename); - } else if (p_flag) + } else if (p_flag) { #else - if (p_flag) + if (p_flag) { #endif print_with_pflag(ndigits, elf_file, shstrndx, sym_data, filename); - else if (P_flag) + } else if (P_flag) { print_with_Pflag(ndigits, elf_file, shstrndx, sym_data); - else + } else { print_with_otherflags(ndigits, elf_file, shstrndx, sym_data, filename); + } sym_data++; count--; } @@ -803,9 +852,9 @@ readsyms(Elf_Data * data, GElf_Sxword num, Elf *elf, buf->indx = i; /* allow to work on machines where NULL-derefs dump core */ - if (sym.st_name == 0) + if (sym.st_name == 0) { buf->name = ""; - else if (C_flag) { + } else if (C_flag) { const char *dn = NULL; char *name = (char *)elf_strptr(elf, link, sym.st_name); @@ -817,9 +866,9 @@ readsyms(Elf_Data * data, GElf_Sxword num, Elf *elf, name = FormatName(name, d_buf); } buf->name = name; - } - else + } else { buf->name = (char *)elf_strptr(elf, link, sym.st_name); + } buf->value = sym.st_value; buf->size = sym.st_size; @@ -1456,29 +1505,34 @@ parsename(char *s) void parse_fn_and_print(const char *str, char *s) { - char c, *p1, *p2; + char c = '\0', *p1, *p2; int yes = 1; - if ((p1 = p2 = strstr(s, "_c_")) == NULL) - if ((p1 = p2 = strstr(s, "_C_")) == NULL) - if ((p1 = p2 = strstr(s, "_cc_")) == NULL) - if ((p1 = p2 = strstr(s, "_cxx_")) == NULL) + if ((p1 = p2 = strstr(s, "_c_")) == NULL) { + if ((p1 = p2 = strstr(s, "_C_")) == NULL) { + if ((p1 = p2 = strstr(s, "_cc_")) == NULL) { + if ((p1 = p2 = strstr(s, "_cxx_")) == NULL) { if ((p1 = p2 = strstr(s, "_h_")) == - NULL) - yes = 0; - else + NULL) { + yes = 0; + } else { p2 += 2; - else + } + } else { p2 += 4; - else + } + } else { p2 += 3; - else + } + } else { p2 += 2; - else + } + } else { p2 += 2; + } if (yes) { - *p1 = '.'; + *p1 = '.'; c = *p2; *p2 = '\0'; } diff --git a/usr/src/cmd/sgs/nm/i386/Makefile b/usr/src/cmd/sgs/nm/i386/Makefile index c7d5bf8b0b..a6f7735af2 100644 --- a/usr/src/cmd/sgs/nm/i386/Makefile +++ b/usr/src/cmd/sgs/nm/i386/Makefile @@ -21,7 +21,7 @@ # # Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2018, Joyent, Inc. +# Copyright (c) 2019, Joyent, Inc. # Copyright 2019 OmniOS Community Edition (OmniOSce) Association. # @@ -46,10 +46,6 @@ INCLIST= -I../../include -I../../include/i386 \ DEFLIST= -DTARGET=I386 -DI386=1 -D$(ARFORMAT) -DELF CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master) -I$(ELFCAP) -CERRWARN += -_gcc=-Wno-uninitialized - -SMOFF += precedence,indenting - LDLIBS += $(CONVLIBDIR) $(CONV_LIB) $(ELFLIBDIR) -lelf objs.xpg4/%.o := CPPFLAGS += -DXPG4 diff --git a/usr/src/cmd/sgs/nm/sparc/Makefile b/usr/src/cmd/sgs/nm/sparc/Makefile index 0fa774a310..a76d967545 100644 --- a/usr/src/cmd/sgs/nm/sparc/Makefile +++ b/usr/src/cmd/sgs/nm/sparc/Makefile @@ -45,7 +45,6 @@ INCLIST= -I../../include -I../../include/sparc \ -I$(SRCBASE)/uts/$(ARCH)/sys DEFLIST= -DTARGET=SPARC -DSPARC=1 -D$(ARFORMAT) -DELF CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master) -I$(ELFCAP) -CERRWARN += -_gcc=-Wno-uninitialized LDLIBS += $(CONVLIBDIR) $(CONV_LIB) $(ELFLIBDIR) -lelf objs.xpg4/%.o := CPPFLAGS += -DXPG4 diff --git a/usr/src/cmd/sgs/nm/sparcv9/Makefile b/usr/src/cmd/sgs/nm/sparcv9/Makefile index 58bc8a5aff..75772f807c 100644 --- a/usr/src/cmd/sgs/nm/sparcv9/Makefile +++ b/usr/src/cmd/sgs/nm/sparcv9/Makefile @@ -43,7 +43,6 @@ INCLIST= -I../../include -I../../include/sparc \ -I$(SRCBASE)/uts/$(ARCH)/sys DEFLIST= -DTARGET=SPARC -DSPARC=1 -D$(ARFORMAT) -DELF CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master) -I$(ELFCAP) -CERRWARN += -_gcc=-Wno-uninitialized LDLIBS += $(CONVLIBDIR64) $(CONV_LIB) $(ELFLIBDIR) -lelf diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README index 44cf7146e8..7e549775e0 100644 --- a/usr/src/cmd/sgs/packages/common/SUNWonld-README +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README @@ -1662,3 +1662,4 @@ Bugid Risk Synopsis 7594 ld -zaslr should accept Solaris-compatible values 8616 ld has trouble parsing -z options specified with -Wl 10267 ld and GCC disagree about i386 local dynamic TLS +10471 ld(1) amd64 LD->LE TLS transition causes memory corruption diff --git a/usr/src/cmd/sgs/pvs/common/pvs.c b/usr/src/cmd/sgs/pvs/common/pvs.c index 4d51ce300d..4c353b887c 100644 --- a/usr/src/cmd/sgs/pvs/common/pvs.c +++ b/usr/src/cmd/sgs/pvs/common/pvs.c @@ -27,7 +27,7 @@ /* * Analyze the versioning information within a file. * - * -C demangle C++ symbol names. + * -C demangle symbol names. * * -d dump version definitions. * diff --git a/usr/src/cmd/sgs/pvs/common/pvs.msg b/usr/src/cmd/sgs/pvs/common/pvs.msg index 82a61385cd..eb888a753a 100644 --- a/usr/src/cmd/sgs/pvs/common/pvs.msg +++ b/usr/src/cmd/sgs/pvs/common/pvs.msg @@ -22,6 +22,7 @@ # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2018, Joyent, Inc. # @ _START_ @@ -34,7 +35,7 @@ # Argument usage messages. @ MSG_USAGE_BRIEF "usage: %s [-Cdlnorsv] [-I index] [-N Name] file(s)\n" -@ MSG_USAGE_DETAIL "\t[-C]\t\tdemangle C++ symbol names\n\ +@ MSG_USAGE_DETAIL "\t[-C]\t\tdemangle symbol names\n\ \t[-d]\t\tprint version definition information\n\ \t[-I index]\tqualify version with an index\n\ \t[-l]\t\tprint reduced symbols\n\ diff --git a/usr/src/cmd/sgs/test/ld/assert-deflib/link.c b/usr/src/cmd/sgs/test/ld/assert-deflib/link.c deleted file mode 100644 index 823c7a3785..0000000000 --- a/usr/src/cmd/sgs/test/ld/assert-deflib/link.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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) 2012, Joyent, Inc. - */ - -#include <stdio.h> - -int -main(void) -{ - (void) printf("Hello, world!\n"); - return (0); -} diff --git a/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh b/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh deleted file mode 100644 index cf07c35788..0000000000 --- a/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash -# -# 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) 2012, Joyent, Inc. -# - -# -# This test validates that the -zassert-deflib option of ld(1) works correctly. -# It requires that some cc is in your path and that you have passed in the path -# to the proto area with the new version of libld.so.4. One thing that we have -# to do is be careful with using LD_LIBRARY_PATH. Setting LD_LIBRARY_PATH does -# not change the default search path so we want to make sure that we use a -# different ISA (e.g. 32-bit vs 64-bit) from the binary we're generating. -# -unalias -a - -sh_path= -sh_lib="lib" -sh_lib64="$sh_lib/64" -sh_soname="libld.so.4" -sh_cc="cc" -sh_cflags="-m32" -sh_file="link.c" -sh_arg0=$(basename $0) - -function fatal -{ - local msg="$*" - [[ -z "$msg" ]] && msg="failed" - echo "$sh_arg0: $msg" >&2 - exit 1 -} - - -# -# Validate that everything we need is in our path. That includes having cc -# and the proto area libld. -# -function validate -{ - [[ -f $sh_path/$sh_lib/$sh_soname ]] || fatal "missing 32-bit $sh_soname" - [[ -f $sh_path/$sh_lib64/$sh_soname ]] || - fatal "missing 64-bit $sh_soname" - which $sh_cc >/dev/null || fatal "cc not in path" -} - -# -# $1 is a series of flags to append -# $2 is expected exit status -# $3 is pre-test message -# $4 is the failure message -# -function run -{ - local ret - - echo $3 - LD_LIBRARY_PATH_64="$sh_path/$sh_lib64" $sh_cc $sh_cflags $sh_file $1 - if [[ $? -eq $2 ]]; then - printf "success\n\n" - else - fatal $4 - fi -} - -sh_path=$1 -[[ -z "$1" ]] && fatal "<proto root>" -validate - -run "-Wl,-zassert-deflib" 0 \ - "Testing basic compilation succeeds with warnings..." \ - "failed to compile with warnings" - -run "-Wl,-zassert-deflib -Wl,-zfatal-warnings" 1 \ - "Testing basic compilation fails if warning are fatal..." \ - "linking succeeeded, expected failure" - -run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \ - "Testing basic exception with fatal warnings..." \ - "linking failed despite exception" - -run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \ - "Testing basic exception with fatal warnings..." \ - "linking failed despite exception" - - -run "-Wl,-zassert-deflib=lib.so -Wl,-zfatal-warnings" 1 \ - "Testing invalid library name..." \ - "ld should not allow invalid library name" - -run "-Wl,-zassert-deflib=libf -Wl,-zfatal-warnings" 1 \ - "Testing invalid library name..." \ - "ld should not allow invalid library name" - -run "-Wl,-zassert-deflib=libf.s -Wl,-zfatal-warnings" 1 \ - "Testing invalid library name..." \ - "ld should not allow invalid library name" - -run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings -lelf" 1 \ - "Errors even if one library is under exception path..." \ - "one exception shouldn't stop another" - -args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelf.so" -args="$args -Wl,-zfatal-warnings -lelf" - -run "$args" 0 \ - "Multiple exceptions work..." \ - "multiple exceptions don't work" - -args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelfe.so" -args="$args -Wl,-zfatal-warnings -lelf" - -run "$args" 1 \ - "Exceptions only catch the specific library" \ - "exceptions caught the wrong library" - -args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libel.so" -args="$args -Wl,-zfatal-warnings -lelf" - -run "$args" 1 \ - "Exceptions only catch the specific library" \ - "exceptions caught the wrong library" - -echo "Tests passed." -exit 0 diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile b/usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile deleted file mode 100644 index d4e11255f0..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# 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 2012, Richard Lowe. - -include $(SRC)/Makefile.master - -# We have to use GCC, and only GCC. The best way is to ask cw(1) which GCC to use. -CC_CMD = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc -_compiler -CC = $(CC_CMD:sh) -CFLAGS = -O1 -m64 - -LINK.c = env LD_ALTEXEC=$(PROTO)/usr/bin/amd64/ld $(CC) $(CFLAGS) -o $@ $^ -COMPILE.c = $(CC) $(CFLAGS) -c -o $@ $^ -COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^ - -.KEEP_STATE: - -install default: all - -.c.o: - $(COMPILE.c) - -.s.o: - $(COMPILE.s) - -# A basic use of TLS that uses the movq m/r --> movq i/r variant -PROGS += style2 -STYLE2OBJS = style2.o -style2: $(STYLE2OBJS) - $(LINK.c) - -# A copy of style2 that uses %r13 in the TLS sequence, and thus excercises the -# REX transitions of the movq mem,reg -> movq imm,reg variant. -PROGS += style2-with-r13 -STYLE2R13OBJS = style2-with-r13.o -style2-with-r13: $(STYLE2R13OBJS) - $(LINK.c) - -# A copy of style2 that uses %r12 in the TLS sequence, so we can verify that -# it is _not_ special to this variant -PROGS += style2-with-r12 -STYLE2R12OBJS = style2-with-r12.o -style2-with-r12: $(STYLE2R12OBJS) - $(LINK.c) - -# A copy of style2 that has a R_AMD64_GOTTPOFF relocation with a bad insn sequence -STYLE2BADNESSOBJS = style2-with-badness.o -style2-with-badness: $(STYLE2BADNESSOBJS) - -$(LINK.c) - -# A basic use of TLS that uses the addq mem/reg --> leaq mem,reg variant -PROGS += style1 -STYLE1OBJS = style1-main.o style1-func.o -style1: $(STYLE1OBJS) - $(LINK.c) - -# A copy of style1-func that uses %r13 in the TLS sequence and thus excercises -# the REX transitions. of the addq mem,reg --> leaq mem,reg variant -PROGS += style1-with-r13 -STYLE1R13OBJS = style1-main.o style1-func-with-r13.o -style1-with-r13: $(STYLE1R13OBJS) - $(LINK.c) - -# A copy of style1-func that uses %r12 to test the addq mem,reg --> addq imm,reg variant -PROGS += style1-with-r12 -STYLE1R12OBJS = style1-main.o style1-func-with-r12.o -style1-with-r12: $(STYLE1R12OBJS) - $(LINK.c) - -all: $(PROGS) - -clobber clean: - rm -f $(PROGS) $(STYLE1OBJS) $(STYLE1R13OBJS) $(STYLE1R12OBJS) \ - $(STYLE2OBJS) $(STYLE2R13OBJS) $(STYLE2R12OBJS) $(STYLE2BADNESSOBJS) - -fail: style2-with-badness FRC - -FRC: diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/README b/usr/src/cmd/sgs/test/ld/x64/tls/ie/README deleted file mode 100644 index 835b3a80ea..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/README +++ /dev/null @@ -1,9 +0,0 @@ -This tests the x64 link-editor's handling of Initial Executable TLS sequences. - -The original C source files are in orig/ but unused, since we need to avoid -any changes to the compiler influencing our tests. - - % ksh x64-ie-test.sh /path/to/proto/root - pass: addq-->leaq 1 - ... - pass: bad insn sequence diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c b/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c deleted file mode 100644 index ed06493f66..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - -#include <stdio.h> - -extern __thread char *foo, *bar; - -void -func() -{ - printf("foo: %p bar: %p\n", &foo, &bar); -} diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c b/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c deleted file mode 100644 index ac95fe9a58..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - -#include <stdio.h> - -extern void func(); - -__thread char *foo = "foo"; -__thread char *bar = "bar"; - -int -main(void) -{ - printf("foo: %p bar: %p\n", &foo, &bar); - func(); - return (0); -} diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c b/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c deleted file mode 100644 index c8b9ae407c..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - -#include <stdio.h> - -__thread char *foo __attribute__((tls_model("initial-exec"))) = "foo"; - -int -main(void) -{ - printf("foo: %p\n", &foo); - return (0); -} diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s deleted file mode 100644 index 68badef3d1..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p bar: %p\n" - .text -.globl func - .type func, @function -func: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq %fs:0, %r12 - movq %r12, %rdx - addq bar@GOTTPOFF(%rip), %rdx - addq foo@GOTTPOFF(%rip), %r12 - movq %r12, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - leave - ret -.LFE0: - .size func, .-func diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s deleted file mode 100644 index 97908bd720..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p bar: %p\n" - .text -.globl func - .type func, @function -func: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq %fs:0, %r13 - movq %r13, %rdx - addq bar@GOTTPOFF(%rip), %rdx - addq foo@GOTTPOFF(%rip), %r13 - movq %r13, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - leave - ret -.LFE0: - .size func, .-func diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s deleted file mode 100644 index ae03161880..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p bar: %p\n" - .text -.globl func - .type func, @function -func: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq %fs:0, %rsi - movq %rsi, %rdx - addq bar@GOTTPOFF(%rip), %rdx - addq foo@GOTTPOFF(%rip), %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - leave - ret -.LFE0: - .size func, .-func diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s deleted file mode 100644 index 08362f3c93..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p bar: %p\n" - .text -.globl main - .type main, @function -main: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq %fs:0, %rsi - leaq bar@TPOFF(%rsi), %rdx - addq $foo@TPOFF, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - movl $0, %eax - call func - movl $0, %eax - leave - ret -.LFE0: - .size main, .-main -.globl foo - .section .rodata.str1.1 -.LC1: - .string "foo" - .section .tdata,"awT",@progbits - .align 8 - .type foo, @object - .size foo, 8 -foo: - .quad .LC1 -.globl bar - .section .rodata.str1.1 -.LC2: - .string "bar" - .section .tdata - .align 8 - .type bar, @object - .size bar, 8 -bar: - .quad .LC2 diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s deleted file mode 100644 index 48572ccf25..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p\n" - .text -.globl main - .type main, @function -main: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - leaq foo@GOTTPOFF(%rip), %rsi - addq %fs:0, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - movl $0, %eax - leave - ret -.LFE0: - .size main, .-main -.globl foo - .section .rodata.str1.1 -.LC1: - .string "foo" - .section .tdata,"awT",@progbits - .align 8 - .type foo, @object - .size foo, 8 -foo: - .quad .LC1 diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s deleted file mode 100644 index 00753f7d0e..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p\n" - .text -.globl main - .type main, @function -main: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq foo@GOTTPOFF(%rip), %r12 - addq %fs:0, %r12 - movq %r12, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - movl $0, %eax - leave - ret -.LFE0: - .size main, .-main -.globl foo - .section .rodata.str1.1 -.LC1: - .string "foo" - .section .tdata,"awT",@progbits - .align 8 - .type foo, @object - .size foo, 8 -foo: - .quad .LC1 diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s deleted file mode 100644 index 40cf796234..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p\n" - .text -.globl main - .type main, @function -main: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq foo@GOTTPOFF(%rip), %r13 - addq %fs:0, %r13 - movq %r13, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - movl $0, %eax - leave - ret -.LFE0: - .size main, .-main -.globl foo - .section .rodata.str1.1 -.LC1: - .string "foo" - .section .tdata,"awT",@progbits - .align 8 - .type foo, @object - .size foo, 8 -foo: - .quad .LC1 diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s b/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s deleted file mode 100644 index 90352f918e..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 2012, Richard Lowe. - */ - - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "foo: %p\n" - .text -.globl main - .type main, @function -main: -.LFB0: - pushq %rbp -.LCFI0: - movq %rsp, %rbp -.LCFI1: - movq foo@GOTTPOFF(%rip), %rsi - addq %fs:0, %rsi - movl $.LC0, %edi - movl $0, %eax - call printf - movl $0, %eax - leave - ret -.LFE0: - .size main, .-main -.globl foo - .section .rodata.str1.1 -.LC1: - .string "foo" - .section .tdata,"awT",@progbits - .align 8 - .type foo, @object - .size foo, 8 -foo: - .quad .LC1 diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh b/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh deleted file mode 100644 index 61dd87bce0..0000000000 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/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 2012, Richard Lowe. - -function grep_test { - name=$1 - pattern=$2 - - if /usr/bin/fgrep -q "${pattern}"; then - print -u2 "pass: $name" - else - print -u2 "FAIL: $name" - fi -} - -function dis_test { - name=${1} - func=${2} - file=${3} - pattern=${4} - - dis -F${func} ${file} | grep_test "${name}" "${pattern}" -} - -make PROTO="${1}" - -dis_test "addq-->leaq 1" func style1 \ - 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx' -dis_test "addq-->leaq 2" func style1 \ - 'func+0x17: 48 8d b6 f0 ff ff leaq -0x10(%rsi),%rsi' - -dis_test "addq-->leaq w/REX 1" func style1-with-r13 \ - 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx' -dis_test "addq-->leaq w/REX 2" func style1-with-r13 \ - 'func+0x17: 4d 8d ad f0 ff ff leaq -0x10(%r13),%r13' - -dis_test "addq-->addq for SIB 1" func style1-with-r12 \ - 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx' -dis_test "addq-->addq for SIB 2" func style1-with-r12 \ - 'func+0x17: 49 81 c4 f0 ff ff addq $-0x10,%r12 <0xfffffffffffffff0>' - -dis_test "movq-->movq" main style2 \ - 'main+0x4: 48 c7 c6 f0 ff ff movq $-0x10,%rsi <0xfffffffffffffff0>' - -dis_test "movq-->movq w/REX" main style2-with-r13 \ - 'main+0x4: 49 c7 c5 f0 ff ff movq $-0x10,%r13 <0xfffffffffffffff0>' - -dis_test "movq-->movq incase of SIB" main style2-with-r12 \ - 'main+0x4: 49 c7 c4 f0 ff ff movq $-0x10,%r12 <0xfffffffffffffff0>' - -make PROTO="${1}" fail 2>&1 | grep_test "bad insn sequence" \ - 'ld: fatal: relocation error: R_AMD64_TPOFF32: file style2-with-badness.o: symbol foo: section .text: offset 0x7, relocation against unknown TLS instruction sequence' |
