summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/lib/libstand/arp.c5
-rw-r--r--usr/src/boot/lib/libstand/assert.c5
-rw-r--r--usr/src/boot/lib/libstand/bzipfs.c2
-rw-r--r--usr/src/boot/lib/libstand/netif.c8
-rw-r--r--usr/src/boot/lib/libstand/sbrk.c3
-rw-r--r--usr/src/boot/sys/boot/common/interp_forth.c14
-rw-r--r--usr/src/boot/sys/boot/common/multiboot2.c4
-rw-r--r--usr/src/boot/sys/boot/common/tem.c2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/bio.c2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/biosdisk.c2
-rw-r--r--usr/src/boot/sys/boot/uboot/lib/copy.c2
-rw-r--r--usr/src/boot/sys/boot/uboot/lib/net.c4
-rw-r--r--usr/src/cmd/sgs/libld/common/machrel.amd.c3
-rw-r--r--usr/src/cmd/sgs/packages/common/SUNWonld-README1
-rw-r--r--usr/src/cmd/sgs/test/ld/x64/tls/ie/README9
-rw-r--r--usr/src/pkg/manifests/system-test-elftest.mf57
-rw-r--r--usr/src/test/Makefile11
-rw-r--r--usr/src/test/elf-tests/Makefile20
-rw-r--r--usr/src/test/elf-tests/cmd/Makefile38
-rw-r--r--usr/src/test/elf-tests/cmd/elftest.ksh49
-rw-r--r--usr/src/test/elf-tests/doc/Makefile36
-rw-r--r--usr/src/test/elf-tests/doc/README59
-rw-r--r--usr/src/test/elf-tests/runfiles/Makefile40
-rw-r--r--usr/src/test/elf-tests/runfiles/default.run37
-rw-r--r--usr/src/test/elf-tests/tests/Makefile21
-rw-r--r--usr/src/test/elf-tests/tests/assert-deflib/Makefile48
-rw-r--r--usr/src/test/elf-tests/tests/assert-deflib/link.c (renamed from usr/src/cmd/sgs/test/ld/assert-deflib/link.c)0
-rw-r--r--usr/src/test/elf-tests/tests/assert-deflib/test-deflib.sh (renamed from usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh)9
-rw-r--r--usr/src/test/elf-tests/tests/tls/Makefile19
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/Makefile19
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile58
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile.test (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile)20
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/README5
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/amd64-ie-test.sh (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh)8
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style1-func.c (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c)0
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style1-main.c (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c)0
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style2.c (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c)0
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func-with-r12.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s)2
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func-with-r13.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s)0
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s)0
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style1-main.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s)0
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-badness.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s)2
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-r12.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s)3
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-r13.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s)2
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ie/style2.s (renamed from usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s)2
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile51
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile.test38
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ld/amd64-ld-test.sh46
-rw-r--r--usr/src/test/elf-tests/tests/tls/amd64/ld/ld-with-addend.s43
-rw-r--r--usr/src/test/elf-tests/tests/tls/i386/Makefile19
-rw-r--r--usr/src/test/elf-tests/tests/tls/i386/ld/Makefile51
-rw-r--r--usr/src/test/elf-tests/tests/tls/i386/ld/Makefile.test38
-rw-r--r--usr/src/test/elf-tests/tests/tls/i386/ld/half-ldm.s49
-rw-r--r--usr/src/test/elf-tests/tests/tls/i386/ld/i386-ld-test.sh43
55 files changed, 945 insertions, 66 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 46d94fffb8..5b10c5b63d 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2019.02.26.1
+BOOT_VERSION = $(LOADER_VERSION)-2019.02.26.2
diff --git a/usr/src/boot/lib/libstand/arp.c b/usr/src/boot/lib/libstand/arp.c
index 4280b90575..7f836689c8 100644
--- a/usr/src/boot/lib/libstand/arp.c
+++ b/usr/src/boot/lib/libstand/arp.c
@@ -118,9 +118,8 @@ arpwhohas(struct iodesc *d, struct in_addr addr)
i = sendrecv(d,
arpsend, &wbuf.data, sizeof (wbuf.data),
arprecv, &pkt, (void **)&ah, NULL);
- if (i == -1) {
- panic("arp: no response for %s\n", inet_ntoa(addr));
- }
+ if (i == -1)
+ panic("arp: no response for %s", inet_ntoa(addr));
/* Store ethernet address in cache */
#ifdef ARP_DEBUG
diff --git a/usr/src/boot/lib/libstand/assert.c b/usr/src/boot/lib/libstand/assert.c
index bfc1933dea..7ed70d70ee 100644
--- a/usr/src/boot/lib/libstand/assert.c
+++ b/usr/src/boot/lib/libstand/assert.c
@@ -34,10 +34,9 @@ void
__assert(const char *func, const char *file, int line, const char *expression)
{
if (func == NULL)
- panic("Assertion failed: (%s), file %s, line %d.\n",
+ panic("Assertion failed: (%s), file %s, line %d.",
expression, file, line);
else
- panic(
- "Assertion failed: (%s), function %s, file %s, line %d.\n",
+ panic("Assertion failed: (%s), function %s, file %s, line %d.",
expression, func, file, line);
}
diff --git a/usr/src/boot/lib/libstand/bzipfs.c b/usr/src/boot/lib/libstand/bzipfs.c
index 2e2a3d8963..1c2cc39904 100644
--- a/usr/src/boot/lib/libstand/bzipfs.c
+++ b/usr/src/boot/lib/libstand/bzipfs.c
@@ -374,7 +374,7 @@ bzf_stat(struct open_file *f, struct stat *sb)
void
bz_internal_error(int errorcode)
{
- panic("bzipfs: critical error %d in bzip2 library occured\n",
+ panic("bzipfs: critical error %d in bzip2 library occured",
errorcode);
}
diff --git a/usr/src/boot/lib/libstand/netif.c b/usr/src/boot/lib/libstand/netif.c
index 8f46a29668..0e6c71569d 100644
--- a/usr/src/boot/lib/libstand/netif.c
+++ b/usr/src/boot/lib/libstand/netif.c
@@ -179,7 +179,7 @@ netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint)
desc->io_netif = nif;
#ifdef PARANOID
if (drv->netif_init == NULL)
- panic("%s%d: no netif_init support\n", drv->netif_bname,
+ panic("%s%d: no netif_init support", drv->netif_bname,
nif->nif_unit);
#endif
drv->netif_init(desc, machdep_hint);
@@ -198,7 +198,7 @@ netif_detach(struct netif *nif)
#endif
#ifdef PARANOID
if (drv->netif_end == NULL)
- panic("%s%d: no netif_end support\n", drv->netif_bname,
+ panic("%s%d: no netif_end support", drv->netif_bname,
nif->nif_unit);
#endif
drv->netif_end(nif);
@@ -219,7 +219,7 @@ netif_get(struct iodesc *desc, void **pkt, time_t timo)
#endif
#ifdef PARANOID
if (drv->netif_get == NULL)
- panic("%s%d: no netif_get support\n", drv->netif_bname,
+ panic("%s%d: no netif_get support", drv->netif_bname,
nif->nif_unit);
#endif
rv = drv->netif_get(desc, pkt, timo);
@@ -246,7 +246,7 @@ netif_put(struct iodesc *desc, void *pkt, size_t len)
#endif
#ifdef PARANOID
if (drv->netif_put == NULL)
- panic("%s%d: no netif_put support\n", drv->netif_bname,
+ panic("%s%d: no netif_put support", drv->netif_bname,
nif->nif_unit);
#endif
rv = drv->netif_put(desc, pkt, len);
diff --git a/usr/src/boot/lib/libstand/sbrk.c b/usr/src/boot/lib/libstand/sbrk.c
index d4143a0c61..fb2dab1d44 100644
--- a/usr/src/boot/lib/libstand/sbrk.c
+++ b/usr/src/boot/lib/libstand/sbrk.c
@@ -51,6 +51,9 @@ sbrk(int incr)
{
char *ret;
+ if (heapbase == NULL)
+ panic("No heap setup");
+
if ((heapsize + incr) <= maxheap) {
ret = (char *)heapbase + heapsize;
bzero(ret, incr);
diff --git a/usr/src/boot/sys/boot/common/interp_forth.c b/usr/src/boot/sys/boot/common/interp_forth.c
index 280bbee732..0151c52b49 100644
--- a/usr/src/boot/sys/boot/common/interp_forth.c
+++ b/usr/src/boot/sys/boot/common/interp_forth.c
@@ -152,7 +152,7 @@ bf_command(ficlVm *vm)
command_errmsg = NULL;
break;
case CMD_FATAL:
- panic("%s\n", command_errmsg);
+ panic("%s", command_errmsg);
}
free(line);
@@ -278,13 +278,13 @@ bf_init(char *rc)
rv = ficlVmEvaluate(bf_vm,
"vocabulary builtins also builtins definitions");
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
- panic("error interpreting forth: %d\n", rv);
+ panic("error interpreting forth: %d", rv);
}
/* Builtin constructor word */
rv = ficlVmEvaluate(bf_vm, BUILTIN_CONSTRUCTOR);
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
- panic("error interpreting forth: %d\n", rv);
+ panic("error interpreting forth: %d", rv);
}
/* make all commands appear as Forth words */
@@ -294,21 +294,21 @@ bf_init(char *rc)
bf_command, FICL_WORD_DEFAULT);
rv = ficlVmEvaluate(bf_vm, "forth definitions builtins");
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
- panic("error interpreting forth: %d\n", rv);
+ panic("error interpreting forth: %d", rv);
}
sprintf(create_buf, "builtin: %s", (*cmdp)->c_name);
rv = ficlVmEvaluate(bf_vm, create_buf);
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
- panic("error interpreting forth: %d\n", rv);
+ panic("error interpreting forth: %d", rv);
}
rv = ficlVmEvaluate(bf_vm, "builtins definitions");
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
- panic("error interpreting forth: %d\n", rv);
+ panic("error interpreting forth: %d", rv);
}
}
rv = ficlVmEvaluate(bf_vm, "only forth definitions");
if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
- panic("error interpreting forth: %d\n", rv);
+ panic("error interpreting forth: %d", rv);
}
/*
diff --git a/usr/src/boot/sys/boot/common/multiboot2.c b/usr/src/boot/sys/boot/common/multiboot2.c
index aadf39a850..67c28b1528 100644
--- a/usr/src/boot/sys/boot/common/multiboot2.c
+++ b/usr/src/boot/sys/boot/common/multiboot2.c
@@ -1193,7 +1193,7 @@ multiboot2_exec(struct preloaded_file *fp)
break;
}
if (map->PhysicalStart == 0)
- panic("Could not find memory for relocater\n");
+ panic("Could not find memory for relocater");
if (keep_bs == 0) {
status = BS->ExitBootServices(IH, key);
@@ -1253,7 +1253,7 @@ multiboot2_exec(struct preloaded_file *fp)
mp->mb_mod_start = efi_physaddr(module, tmp, map,
map_size / desc_size, desc_size, mp->mb_mod_end);
if (mp->mb_mod_start == 0)
- panic("Could not find memory for module\n");
+ panic("Could not find memory for module");
mp->mb_mod_end += mp->mb_mod_start;
chunk->chunk_paddr = mp->mb_mod_start;
diff --git a/usr/src/boot/sys/boot/common/tem.c b/usr/src/boot/sys/boot/common/tem.c
index f06733fb78..4311e0cb64 100644
--- a/usr/src/boot/sys/boot/common/tem.c
+++ b/usr/src/boot/sys/boot/common/tem.c
@@ -515,7 +515,7 @@ tems_setup_terminal(struct vis_devinit *tp, size_t height, size_t width)
tems.ts_font.vf_bytes =
malloc(font_data->uncompressed_size);
if (tems.ts_font.vf_bytes == NULL)
- panic("out of memory\n");
+ panic("out of memory");
(void) lz4_decompress(
font_data->compressed_data,
tems.ts_font.vf_bytes,
diff --git a/usr/src/boot/sys/boot/i386/libi386/bio.c b/usr/src/boot/sys/boot/i386/libi386/bio.c
index 9b72e606eb..07a330a06c 100644
--- a/usr/src/boot/sys/boot/i386/libi386/bio.c
+++ b/usr/src/boot/sys/boot/i386/libi386/bio.c
@@ -62,5 +62,5 @@ bio_free(void *ptr, size_t size)
bio_buffer_ptr -= size;
if (bio_buffer_ptr != ptr)
- panic("bio_alloc()/bio_free() mismatch\n");
+ panic("bio_alloc()/bio_free() mismatch");
}
diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
index b8fea9592a..38eda5171a 100644
--- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
+++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c
@@ -984,7 +984,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
if (bbuf == NULL) {
bio_size = V86_IO_BUFFER_SIZE;
if (bio_size / bd->bd_sectorsize == 0)
- panic("BUG: Real mode buffer is too small\n");
+ panic("BUG: Real mode buffer is too small");
/* Use alternate 4k buffer */
bbuf = PTOV(V86_IO_BUFFER);
diff --git a/usr/src/boot/sys/boot/uboot/lib/copy.c b/usr/src/boot/sys/boot/uboot/lib/copy.c
index 4cd17f62f3..b41246f179 100644
--- a/usr/src/boot/sys/boot/uboot/lib/copy.c
+++ b/usr/src/boot/sys/boot/uboot/lib/copy.c
@@ -133,7 +133,7 @@ uboot_loadaddr(uint_t type, void *data, uint64_t addr)
}
}
if (biggest_size == 0)
- panic("Not enough DRAM to load kernel\n");
+ panic("Not enough DRAM to load kernel");
#if 0
printf("Loading kernel into region 0x%08jx-0x%08jx (%ju MiB)\n",
(uintmax_t)biggest_block,
diff --git a/usr/src/boot/sys/boot/uboot/lib/net.c b/usr/src/boot/sys/boot/uboot/lib/net.c
index 667db42f7c..ba3909d215 100644
--- a/usr/src/boot/sys/boot/uboot/lib/net.c
+++ b/usr/src/boot/sys/boot/uboot/lib/net.c
@@ -323,7 +323,7 @@ net_init(struct iodesc *desc, void *machdep_hint)
sc = nif->nif_devdata = &uboot_softc;
if ((err = ub_dev_open(sc->sc_handle)) != 0)
- panic("%s%d: initialisation failed with error %d\n",
+ panic("%s%d: initialisation failed with error %d",
nif->nif_driver->netif_bname, nif->nif_unit, err);
/* Get MAC address */
@@ -358,6 +358,6 @@ net_end(struct netif *nif)
int err;
if ((err = ub_dev_close(sc->sc_handle)) != 0)
- panic("%s%d: net_end failed with error %d\n",
+ panic("%s%d: net_end failed with error %d",
nif->nif_driver->netif_bname, nif->nif_unit, err);
}
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/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/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/pkg/manifests/system-test-elftest.mf b/usr/src/pkg/manifests/system-test-elftest.mf
new file mode 100644
index 0000000000..696fd56652
--- /dev/null
+++ b/usr/src/pkg/manifests/system-test-elftest.mf
@@ -0,0 +1,57 @@
+#
+# 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 2018, Richard Lowe.
+#
+
+set name=pkg.fmri value=pkg:/system/test/elftest@$(PKGVERS)
+set name=pkg.description value="ELF Unit Tests"
+set name=pkg.summary value="ELF Test Suite"
+set name=info.classification \
+ value=org.opensolaris.category.2008:Development/System
+set name=variant.arch value=$(ARCH)
+dir path=opt/elf-tests
+dir path=opt/elf-tests/bin
+dir path=opt/elf-tests/runfiles
+dir path=opt/elf-tests/tests
+dir path=opt/elf-tests/tests/assert-deflib
+dir path=opt/elf-tests/tests/tls
+dir path=opt/elf-tests/tests/tls/amd64
+dir path=opt/elf-tests/tests/tls/amd64/ie
+dir path=opt/elf-tests/tests/tls/amd64/ld
+dir path=opt/elf-tests/tests/tls/i386
+dir path=opt/elf-tests/tests/tls/i386/ld
+file path=opt/elf-tests/README mode=0444
+file path=opt/elf-tests/bin/elftest mode=0555
+file path=opt/elf-tests/runfiles/default.run mode=0444
+file path=opt/elf-tests/tests/assert-deflib/link.c mode=0444
+file path=opt/elf-tests/tests/assert-deflib/test-deflib mode=0555
+file path=opt/elf-tests/tests/tls/amd64/ie/Makefile.test mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/amd64-ie-test mode=0555
+file path=opt/elf-tests/tests/tls/amd64/ie/style1-func-with-r12.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style1-func-with-r13.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style1-func.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style1-main.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style2-with-badness.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style2-with-r12.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style2-with-r13.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ie/style2.s mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ld/Makefile.test mode=0444
+file path=opt/elf-tests/tests/tls/amd64/ld/amd64-ld-test mode=0555
+file path=opt/elf-tests/tests/tls/amd64/ld/ld-with-addend.s mode=0444
+file path=opt/elf-tests/tests/tls/i386/ld/Makefile.test mode=0444
+file path=opt/elf-tests/tests/tls/i386/ld/half-ldm.s mode=0444
+file path=opt/elf-tests/tests/tls/i386/ld/i386-ld-test mode=0555
+license lic_CDDL license=lic_CDDL
+depend fmri=developer/linker type=require
+depend fmri=developer/object-file type=require
+depend fmri=system/test/testrunner type=require
diff --git a/usr/src/test/Makefile b/usr/src/test/Makefile
index 9ca989ce57..fa57d36772 100644
--- a/usr/src/test/Makefile
+++ b/usr/src/test/Makefile
@@ -16,7 +16,14 @@
.PARALLEL: $(SUBDIRS)
-SUBDIRS = libc-tests crypto-tests os-tests test-runner util-tests zfs-tests \
- smbclient-tests
+SUBDIRS = \
+ crypto-tests \
+ elf-tests \
+ libc-tests \
+ os-tests \
+ smbclient-tests \
+ test-runner \
+ util-tests \
+ zfs-tests
include Makefile.com
diff --git a/usr/src/test/elf-tests/Makefile b/usr/src/test/elf-tests/Makefile
new file mode 100644
index 0000000000..6669972e13
--- /dev/null
+++ b/usr/src/test/elf-tests/Makefile
@@ -0,0 +1,20 @@
+#
+# 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 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+.PARALLEL: $(SUBDIRS)
+
+SUBDIRS = cmd doc runfiles tests
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/elf-tests/cmd/Makefile b/usr/src/test/elf-tests/cmd/Makefile
new file mode 100644
index 0000000000..ccda4af74e
--- /dev/null
+++ b/usr/src/test/elf-tests/cmd/Makefile
@@ -0,0 +1,38 @@
+#
+# 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 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/test/Makefile.com
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+ROOTBIN = $(ROOTOPTPKG)/bin
+
+PROGS = elftest
+
+CMDS = $(PROGS:%=$(ROOTBIN)/%)
+$(CMDS) := FILEMODE = 0555
+
+all lint clean clobber:
+
+install: $(CMDS)
+
+$(CMDS): $(ROOTBIN)
+
+$(ROOTBIN):
+ $(INS.dir)
+
+$(ROOTBIN)/%: %.ksh
+ $(INS.rename)
diff --git a/usr/src/test/elf-tests/cmd/elftest.ksh b/usr/src/test/elf-tests/cmd/elftest.ksh
new file mode 100644
index 0000000000..b5a0d9b52f
--- /dev/null
+++ b/usr/src/test/elf-tests/cmd/elftest.ksh
@@ -0,0 +1,49 @@
+#!/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 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+ELF_TESTS="/opt/elf-tests"
+runner="/opt/test-runner/bin/run"
+
+function fail
+{
+ echo $1
+ exit ${2:-1}
+}
+
+function find_runfile
+{
+ typeset distro=default
+
+ [[ -n $distro ]] && echo $ELF_TESTS/runfiles/$distro.run
+}
+
+while getopts c: c; do
+ case $c in
+ 'c')
+ runfile=$OPTARG
+ [[ -f $runfile ]] || fail "Cannot read file: $runfile"
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+[[ -z $runfile ]] && runfile=$(find_runfile)
+[[ -z $runfile ]] && fail "Couldn't determine distro"
+
+$runner -c $runfile
+
+exit $?
diff --git a/usr/src/test/elf-tests/doc/Makefile b/usr/src/test/elf-tests/doc/Makefile
new file mode 100644
index 0000000000..b2d50b7b93
--- /dev/null
+++ b/usr/src/test/elf-tests/doc/Makefile
@@ -0,0 +1,36 @@
+#
+# 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 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+include $(SRC)/Makefile.master
+
+READMES = README
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+
+FILES = $(READMES:%=$(ROOTOPTPKG)/%)
+$(FILES) := FILEMODE = 0444
+
+all: $(READMES)
+
+install: $(ROOTOPTPKG) $(FILES)
+
+clean lint clobber:
+
+$(ROOTOPTPKG):
+ $(INS.dir)
+
+$(ROOTOPTPKG)/%: %
+ $(INS.file)
diff --git a/usr/src/test/elf-tests/doc/README b/usr/src/test/elf-tests/doc/README
new file mode 100644
index 0000000000..ef8ecda914
--- /dev/null
+++ b/usr/src/test/elf-tests/doc/README
@@ -0,0 +1,59 @@
+#
+# 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 by Delphix. All rights reserved.
+# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+#
+
+ELF Software Generation Utilities Unit Test Suite README
+
+1. Building and installing the ELF/SGS Unit Test Suite
+2. Running the ELF/SGS Unit Test Suite
+3. Test results
+
+--------------------------------------------------------------------------------
+
+1. Building and installing the ELF/SGS Unit Test Suite
+
+The ELF/SGS Unit Test Suite runs under the testrunner framework (which can be
+installed as pkg:/system/test/testrunner). To build both the ELF/SGS Unit Test Suite
+and the testrunner without running a full nightly:
+
+ build_machine$ bldenv [-d] <your_env_file>
+ build_machine$ cd $SRC/test
+ build_machine$ dmake install
+ build_machine$ cd $SRC/pkg
+ build_machine$ dmake install
+
+Then set the publisher on the test machine to point to your repository and
+install the ELF/SGS Unit Test Suite.
+
+ test_machine# pkg install pkg:/system/test/elftest
+
+Note, the framework will be installed automatically, as the ELF/SGS Unit Test Suite
+depends on it.
+
+2. Running the ELF/SGS Unit Test Suite
+
+The pre-requisites for running the ELF/SGS Unit Test Suite are:
+ None
+
+Once the pre-requisites are satisfied, simply run the elftest script:
+
+ test_machine$ /opt/elf-tests/bin/elftest
+
+3. Test results
+
+While the ELF/SGS Unit Test Suite is running, one informational line is printed at
+the end of each test, and a results summary is printed at the end of the run.
+The results summary includes the location of the complete logs, which is of the
+form /var/tmp/test_results/<ISO 8601 date>.
diff --git a/usr/src/test/elf-tests/runfiles/Makefile b/usr/src/test/elf-tests/runfiles/Makefile
new file mode 100644
index 0000000000..cf1ac703d7
--- /dev/null
+++ b/usr/src/test/elf-tests/runfiles/Makefile
@@ -0,0 +1,40 @@
+#
+# 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 by Delphix. All rights reserved.
+# Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+include $(SRC)/Makefile.master
+
+SRCS = default.run
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+RUNFILES = $(ROOTOPTPKG)/runfiles
+
+CMDS = $(SRCS:%=$(RUNFILES)/%)
+$(CMDS) := FILEMODE = 0444
+
+all: $(SRCS)
+
+install: $(CMDS)
+
+clean lint clobber:
+
+$(CMDS): $(RUNFILES) $(SRCS)
+
+$(RUNFILES):
+ $(INS.dir)
+
+$(RUNFILES)/%: %
+ $(INS.file)
diff --git a/usr/src/test/elf-tests/runfiles/default.run b/usr/src/test/elf-tests/runfiles/default.run
new file mode 100644
index 0000000000..f1b0c8980a
--- /dev/null
+++ b/usr/src/test/elf-tests/runfiles/default.run
@@ -0,0 +1,37 @@
+
+#
+# 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 2018, Richard Lowe.
+
+[DEFAULT]
+pre =
+verbose = False
+quiet = False
+timeout = 60
+post =
+outputdir = /var/tmp/test_results
+
+[/opt/elf-tests/tests/assert-deflib]
+tests = ['test-deflib']
+
+
+[/opt/elf-tests/tests/tls/amd64/ie]
+arch = i86pc
+tests = ['amd64-ie-test']
+
+[/opt/elf-tests/tests/tls/i386/ld]
+arch = i86pc
+tests = ['i386-ld-test']
+
+[/opt/elf-tests/tests/tls/amd64/ld]
+arch = i86pc
+tests = ['amd64-ld-test']
diff --git a/usr/src/test/elf-tests/tests/Makefile b/usr/src/test/elf-tests/tests/Makefile
new file mode 100644
index 0000000000..e3894ac07d
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/Makefile
@@ -0,0 +1,21 @@
+#
+# 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, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = \
+ assert-deflib \
+ tls
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/elf-tests/tests/assert-deflib/Makefile b/usr/src/test/elf-tests/tests/assert-deflib/Makefile
new file mode 100644
index 0000000000..768182efbc
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/assert-deflib/Makefile
@@ -0,0 +1,48 @@
+#
+# 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 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG = test-deflib
+
+DATAFILES = link.c
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/assert-deflib
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/cmd/sgs/test/ld/assert-deflib/link.c b/usr/src/test/elf-tests/tests/assert-deflib/link.c
index 823c7a3785..823c7a3785 100644
--- a/usr/src/cmd/sgs/test/ld/assert-deflib/link.c
+++ b/usr/src/test/elf-tests/tests/assert-deflib/link.c
diff --git a/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh b/usr/src/test/elf-tests/tests/assert-deflib/test-deflib.sh
index cf07c35788..f2f710e0c1 100644
--- a/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh
+++ b/usr/src/test/elf-tests/tests/assert-deflib/test-deflib.sh
@@ -24,13 +24,15 @@
#
unalias -a
+TESTDIR=$(dirname $0)
+
sh_path=
sh_lib="lib"
sh_lib64="$sh_lib/64"
sh_soname="libld.so.4"
-sh_cc="cc"
+sh_cc="gcc"
sh_cflags="-m32"
-sh_file="link.c"
+sh_file="${TESTDIR}/link.c"
sh_arg0=$(basename $0)
function fatal
@@ -73,8 +75,7 @@ function run
fi
}
-sh_path=$1
-[[ -z "$1" ]] && fatal "<proto root>"
+sh_path=${1:-/}
validate
run "-Wl,-zassert-deflib" 0 \
diff --git a/usr/src/test/elf-tests/tests/tls/Makefile b/usr/src/test/elf-tests/tests/tls/Makefile
new file mode 100644
index 0000000000..d0dc53a033
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/Makefile
@@ -0,0 +1,19 @@
+#
+# 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, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = amd64 i386
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/Makefile b/usr/src/test/elf-tests/tests/tls/amd64/Makefile
new file mode 100644
index 0000000000..c7755dcb5b
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/Makefile
@@ -0,0 +1,19 @@
+#
+# 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, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = ie ld
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile b/usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile
new file mode 100644
index 0000000000..7ffb91e837
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile
@@ -0,0 +1,58 @@
+#
+# 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 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG = amd64-ie-test
+
+DATAFILES = \
+ Makefile.test \
+ style1-func-with-r12.s \
+ style1-func-with-r13.s \
+ style1-func.s \
+ style1-main.s \
+ style2-with-badness.s \
+ style2-with-r12.s \
+ style2-with-r13.s \
+ style2.s
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/tls/amd64/ie
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile b/usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile.test
index d4e11255f0..7f08ba0538 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/Makefile
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/Makefile.test
@@ -11,29 +11,21 @@
# Copyright 2012, Richard Lowe.
-include $(SRC)/Makefile.master
+CC = gcc
+CFLAGS = -O1 -m64
-# 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 $@ $^
+LINK.c = $(CC) $(CFLAGS) -o $@ $^
COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^
.KEEP_STATE:
install default: all
-.c.o:
- $(COMPILE.c)
-
-.s.o:
+%.o: $(TESTDIR)/%.s
$(COMPILE.s)
# A basic use of TLS that uses the movq m/r --> movq i/r variant
-PROGS += style2
+PROGS += style2
STYLE2OBJS = style2.o
style2: $(STYLE2OBJS)
$(LINK.c)
@@ -78,7 +70,7 @@ style1-with-r12: $(STYLE1R12OBJS)
all: $(PROGS)
-clobber clean:
+clobber clean:
rm -f $(PROGS) $(STYLE1OBJS) $(STYLE1R13OBJS) $(STYLE1R12OBJS) \
$(STYLE2OBJS) $(STYLE2R13OBJS) $(STYLE2R12OBJS) $(STYLE2BADNESSOBJS)
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/ie/README b/usr/src/test/elf-tests/tests/tls/amd64/ie/README
new file mode 100644
index 0000000000..cdbf6a4b20
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/README
@@ -0,0 +1,5 @@
+This tests the amd64 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.
+
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh b/usr/src/test/elf-tests/tests/tls/amd64/ie/amd64-ie-test.sh
index 61dd87bce0..4b9c9cd2d6 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/amd64-ie-test.sh
@@ -20,8 +20,9 @@ function grep_test {
print -u2 "pass: $name"
else
print -u2 "FAIL: $name"
+ exit 1
fi
-}
+}
function dis_test {
name=${1}
@@ -32,7 +33,8 @@ function dis_test {
dis -F${func} ${file} | grep_test "${name}" "${pattern}"
}
-make PROTO="${1}"
+TESTDIR=$(dirname $0)
+make -f ${TESTDIR}/Makefile.test TESTDIR=${TESTDIR}
dis_test "addq-->leaq 1" func style1 \
'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
@@ -58,5 +60,5 @@ dis_test "movq-->movq w/REX" main style2-with-r13 \
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" \
+make -f ${TESTDIR}/Makefile.test fail TESTDIR=${TESTDIR} 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'
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c b/usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style1-func.c
index ed06493f66..ed06493f66 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-func.c
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style1-func.c
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c b/usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style1-main.c
index ac95fe9a58..ac95fe9a58 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style1-main.c
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style1-main.c
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c b/usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style2.c
index c8b9ae407c..c8b9ae407c 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/orig/style2.c
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/orig/style2.c
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func-with-r12.s
index 68badef3d1..7d7821bed5 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r12.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func-with-r12.s
@@ -29,7 +29,7 @@ func:
movq %r12, %rdx
addq bar@GOTTPOFF(%rip), %rdx
addq foo@GOTTPOFF(%rip), %r12
- movq %r12, %rsi
+ movq %r12, %rsi
movl $.LC0, %edi
movl $0, %eax
call printf
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func-with-r13.s
index 97908bd720..97908bd720 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func-with-r13.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func-with-r13.s
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func.s
index ae03161880..ae03161880 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-func.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-func.s
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-main.s
index 08362f3c93..08362f3c93 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style1-main.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style1-main.s
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-badness.s
index 48572ccf25..74534f8dd3 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-badness.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-badness.s
@@ -11,7 +11,7 @@
/*
* Copyright 2012, Richard Lowe.
- */
+ */
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-r12.s
index 00753f7d0e..d446982d90 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r12.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-r12.s
@@ -11,7 +11,7 @@
/*
* Copyright 2012, Richard Lowe.
- */
+ */
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
@@ -40,6 +40,7 @@ main:
.section .rodata.str1.1
.LC1:
.string "foo"
+
.section .tdata,"awT",@progbits
.align 8
.type foo, @object
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-r13.s
index 40cf796234..cc740903da 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2-with-r13.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2-with-r13.s
@@ -11,7 +11,7 @@
/*
* Copyright 2012, Richard Lowe.
- */
+ */
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2.s
index 90352f918e..8ab6cc9d40 100644
--- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/style2.s
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ie/style2.s
@@ -11,7 +11,7 @@
/*
* Copyright 2012, Richard Lowe.
- */
+ */
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile b/usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile
new file mode 100644
index 0000000000..29bf217170
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile
@@ -0,0 +1,51 @@
+#
+# 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 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG = amd64-ld-test
+
+DATAFILES = \
+ Makefile.test \
+ ld-with-addend.s \
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/tls/amd64/ld
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile.test b/usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile.test
new file mode 100644
index 0000000000..026b70b6d5
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile.test
@@ -0,0 +1,38 @@
+#
+# 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.
+
+CC = gcc
+CFLAGS = -O1 -m64
+
+LINK.c = $(CC) $(CFLAGS) -o $@ $^
+COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^
+
+.KEEP_STATE:
+
+install default: all
+
+%.o: $(TESTDIR)/%.s
+ $(COMPILE.s)
+
+# an R_AMD64_DTPOFF32 with an addend, which must be preserved
+PROGS += ld-with-addend
+
+ld-with-addend: ld-with-addend.o
+ $(LINK.c)
+
+all: $(PROGS)
+
+clobber clean:
+ rm -f $(PROGS) ld-with-addend.o
+
+FRC:
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/ld/amd64-ld-test.sh b/usr/src/test/elf-tests/tests/tls/amd64/ld/amd64-ld-test.sh
new file mode 100644
index 0000000000..08eb00be54
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ld/amd64-ld-test.sh
@@ -0,0 +1,46 @@
+#!/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/grep -q "${pattern}"; then
+ print -u2 "pass: $name"
+ else
+ print -u2 "FAIL: $name"
+ exit 1
+ fi
+}
+
+function dis_test {
+ name=${1}
+ func=${2}
+ file=${3}
+ pattern=${4}
+
+ dis -F${func} ${file} | grep_test "${name}" "${pattern}"
+}
+
+TESTDIR=$(dirname $0)
+
+make -f ${TESTDIR}/Makefile.test TESTDIR=${TESTDIR}
+
+# if we fail, the addend won't be applied, the leaq with be -0x10(%rax)
+dis_test "addend is preserved" main ld-with-addend \
+ 'main+0x10: 48 8d b0 f2 ff ff leaq -0xe(%rax),%rsi'
+
+# We have an addend of 2, a failure will print 'incorrect'
+./ld-with-addend | grep_test 'ld-with-addend execution' \
+ '^foo: correct ([a-f0-9]*)$'
diff --git a/usr/src/test/elf-tests/tests/tls/amd64/ld/ld-with-addend.s b/usr/src/test/elf-tests/tests/tls/amd64/ld/ld-with-addend.s
new file mode 100644
index 0000000000..1c919462f3
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/amd64/ld/ld-with-addend.s
@@ -0,0 +1,43 @@
+/*
+ * 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: %s (%p)\n"
+ .text
+ .section .tdata,"awT",@progbits
+foo:
+ .string "incorrect"
+ .text
+.globl main
+ .type main, @function
+main:
+.LFB0:
+ pushq %rbp
+.LCFI0:
+ movq %rsp, %rbp
+ .LCFI1:
+ leaq foo@tlsld(%rip), %rdi
+ call __tls_get_addr@plt
+ leaq 2+foo@dtpoff(%rax), %rsi
+ movq %rsi, %rdx
+ movq %rsi, %rsi
+ movl $.LC0, %edi
+ movl $0, %eax
+ call printf
+ movl $0, %eax
+ leave
+ ret
+ .size main, .-main
diff --git a/usr/src/test/elf-tests/tests/tls/i386/Makefile b/usr/src/test/elf-tests/tests/tls/i386/Makefile
new file mode 100644
index 0000000000..51053ae31b
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/i386/Makefile
@@ -0,0 +1,19 @@
+#
+# 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, 2016 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
+#
+
+SUBDIRS = ld
+
+include $(SRC)/test/Makefile.com
diff --git a/usr/src/test/elf-tests/tests/tls/i386/ld/Makefile b/usr/src/test/elf-tests/tests/tls/i386/ld/Makefile
new file mode 100644
index 0000000000..2550e1c457
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/i386/ld/Makefile
@@ -0,0 +1,51 @@
+#
+# 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 2018, Richard Lowe.
+
+include $(SRC)/cmd/Makefile.cmd
+include $(SRC)/test/Makefile.com
+
+PROG = i386-ld-test
+
+DATAFILES = \
+ Makefile.test \
+ half-ldm.s \
+
+ROOTOPTPKG = $(ROOT)/opt/elf-tests
+TESTDIR = $(ROOTOPTPKG)/tests/tls/i386/ld
+
+CMDS = $(PROG:%=$(TESTDIR)/%)
+$(CMDS) := FILEMODE = 0555
+
+
+DATA = $(DATAFILES:%=$(TESTDIR)/%)
+$(DATA) := FILEMODE = 0444
+
+all: $(PROG)
+
+install: all $(CMDS) $(DATA)
+
+lint:
+
+clobber: clean
+ -$(RM) $(PROG)
+
+clean:
+ -$(RM) $(CLEANFILES)
+
+$(CMDS): $(TESTDIR) $(PROG)
+
+$(TESTDIR):
+ $(INS.dir)
+
+$(TESTDIR)/%: %
+ $(INS.file)
diff --git a/usr/src/test/elf-tests/tests/tls/i386/ld/Makefile.test b/usr/src/test/elf-tests/tests/tls/i386/ld/Makefile.test
new file mode 100644
index 0000000000..f6e9413310
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/i386/ld/Makefile.test
@@ -0,0 +1,38 @@
+#
+# 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.
+
+CC = gcc
+CFLAGS = -O1 -m32
+
+LINK.c = $(CC) $(CFLAGS) -o $@ $^
+COMPILE.s = $(CC) $(CFLAGS) -c -o $@ $^
+
+.KEEP_STATE:
+
+install default: all
+
+%.o: $(TESTDIR)/%.s
+ $(COMPILE.s)
+
+# an R_386_TLS_LDM with a regular R_386_PLT32 not a R_386_TLS_LDM_PLT
+PROGS += half-ldm
+
+half-ldm: half-ldm.o
+ $(LINK.c)
+
+all: $(PROGS)
+
+clobber clean:
+ rm -f $(PROGS) half-ldm.o
+
+FRC:
diff --git a/usr/src/test/elf-tests/tests/tls/i386/ld/half-ldm.s b/usr/src/test/elf-tests/tests/tls/i386/ld/half-ldm.s
new file mode 100644
index 0000000000..f8e6dbc528
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/i386/ld/half-ldm.s
@@ -0,0 +1,49 @@
+/*
+ * 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.u
+ */
+
+/*
+ * Copyright 2019, Richard Lowe.
+ */
+
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "foo: %s (%p)\n"
+ .section .tdata,"awT",@progbits
+ .align 4
+ .type foo, @object
+ .size foo,4
+.local foo
+foo:
+ .string "foo"
+ .text
+.globl main
+ .type main, @function
+main:
+ pushl %ebp
+ movl %esp, %ebp
+ /*
+ * an R_386_TLS_LDM relocation without a following
+ * followed by an R_386_PLT32 relocation, rather than an
+ * R_386_TLS_LDM_PLT the call should be removed, and _not_
+ * left alone unrelocated as it was prior to:
+ * 10267 ld and GCC disagree about i386 local dynamic TLS
+ */
+ leal foo@TLSLDM(%ebx), %eax
+ call ___tls_get_addr@PLT
+ leal foo@DTPOFF(%eax), %edx
+ pushl %edx
+ pushl %edx
+ pushl $.LC0
+ call printf@PLT
+ movl $0x0,%eax
+ leave
+ ret
+ .size main, .-main
diff --git a/usr/src/test/elf-tests/tests/tls/i386/ld/i386-ld-test.sh b/usr/src/test/elf-tests/tests/tls/i386/ld/i386-ld-test.sh
new file mode 100644
index 0000000000..a86cc5a717
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/tls/i386/ld/i386-ld-test.sh
@@ -0,0 +1,43 @@
+#!/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/grep -q "${pattern}"; then
+ print -u2 "pass: $name"
+ else
+ print -u2 "FAIL: $name"
+ exit 1
+ fi
+}
+
+function dis_test {
+ name=${1}
+ func=${2}
+ file=${3}
+ pattern=${4}
+
+ dis -F${func} ${file} | grep_test "${name}" "${pattern}"
+}
+
+TESTDIR=$(dirname $0)
+make -f ${TESTDIR}/Makefile.test TESTDIR=${TESTDIR}
+
+dis_test "call-->nop" main half-ldm \
+ 'main\+0x9: 0f 1f 44 00 00 nopl 0x0(%eax,%eax)'
+
+./half-ldm | grep_test 'half-ldm execution' \
+ '^foo: foo ([a-f0-9]*)$'