diff options
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/cmd/sgs/libld/common/machrel.amd.c | 3 | ||||
-rw-r--r-- | usr/src/cmd/sgs/packages/common/SUNWonld-README | 1 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-test-elftest.mf | 4 | ||||
-rw-r--r-- | usr/src/test/elf-tests/runfiles/default.run | 3 | ||||
-rw-r--r-- | usr/src/test/elf-tests/tests/tls/amd64/Makefile | 2 | ||||
-rw-r--r-- | usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile | 51 | ||||
-rw-r--r-- | usr/src/test/elf-tests/tests/tls/amd64/ld/Makefile.test | 38 | ||||
-rw-r--r-- | usr/src/test/elf-tests/tests/tls/amd64/ld/amd64-ld-test.sh | 46 | ||||
-rw-r--r-- | usr/src/test/elf-tests/tests/tls/amd64/ld/ld-with-addend.s | 43 |
9 files changed, 188 insertions, 3 deletions
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/pkg/manifests/system-test-elftest.mf b/usr/src/pkg/manifests/system-test-elftest.mf index 1647f2f10f..696fd56652 100644 --- a/usr/src/pkg/manifests/system-test-elftest.mf +++ b/usr/src/pkg/manifests/system-test-elftest.mf @@ -27,6 +27,7 @@ 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 @@ -44,6 +45,9 @@ 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 diff --git a/usr/src/test/elf-tests/runfiles/default.run b/usr/src/test/elf-tests/runfiles/default.run index 7db5874805..f1b0c8980a 100644 --- a/usr/src/test/elf-tests/runfiles/default.run +++ b/usr/src/test/elf-tests/runfiles/default.run @@ -32,3 +32,6 @@ tests = ['amd64-ie-test'] 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/tls/amd64/Makefile b/usr/src/test/elf-tests/tests/tls/amd64/Makefile index c6e750acc6..c7755dcb5b 100644 --- a/usr/src/test/elf-tests/tests/tls/amd64/Makefile +++ b/usr/src/test/elf-tests/tests/tls/amd64/Makefile @@ -14,6 +14,6 @@ # Copyright 2018 Joyent, Inc. # -SUBDIRS = ie +SUBDIRS = ie ld include $(SRC)/test/Makefile.com 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 |