summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/sgs/libld/common/files.c11
-rw-r--r--usr/src/cmd/sgs/tools/SUNWonld-README1
-rw-r--r--usr/src/pkg/manifests/system-test-elftest.p5m1
-rw-r--r--usr/src/test/elf-tests/runfiles/default.run2
-rw-r--r--usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile3
-rw-r--r--usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile.test9
-rw-r--r--usr/src/test/elf-tests/tests/sections/shf-exclude/unknown-os.sh37
7 files changed, 58 insertions, 6 deletions
diff --git a/usr/src/cmd/sgs/libld/common/files.c b/usr/src/cmd/sgs/libld/common/files.c
index 2073ae2ec5..3afd9ae3e7 100644
--- a/usr/src/cmd/sgs/libld/common/files.c
+++ b/usr/src/cmd/sgs/libld/common/files.c
@@ -2676,10 +2676,15 @@ process_elf(Ifl_desc *ifl, Elf *elf, Ofl_desc *ofl)
} else {
/*
* If this section is below SHT_LOSUNW then we don't
- * really know what to do with it, issue a warning
- * message but do the basic section processing anyway.
+ * really know what to do with it.
+ *
+ * If SHF_EXCLUDE is set we're being told we should
+ * (or may) ignore the section. Otherwise issue a
+ * warning message but do the basic section processing
+ * anyway.
*/
- if (row < (Word)SHT_LOSUNW) {
+ if ((row < (Word)SHT_LOSUNW) &&
+ ((shdr->sh_flags & SHF_EXCLUDE) == 0)) {
Conv_inv_buf_t inv_buf;
ld_eprintf(ofl, ERR_WARNING,
diff --git a/usr/src/cmd/sgs/tools/SUNWonld-README b/usr/src/cmd/sgs/tools/SUNWonld-README
index 36fdba7231..1e15c9fbdc 100644
--- a/usr/src/cmd/sgs/tools/SUNWonld-README
+++ b/usr/src/cmd/sgs/tools/SUNWonld-README
@@ -1684,3 +1684,4 @@ Bugid Risk Synopsis
14250 ld should resolve discarded COMDAT symbols against their mates
14283 ldd should not complain about non-executable shared objects
14308 discard SHF_EXCLUDE sections when linking kernel modules
+14319 ld shouldn't warn about SHF_EXCLUDE unknown sections
diff --git a/usr/src/pkg/manifests/system-test-elftest.p5m b/usr/src/pkg/manifests/system-test-elftest.p5m
index 10f03106d2..490458e6d9 100644
--- a/usr/src/pkg/manifests/system-test-elftest.p5m
+++ b/usr/src/pkg/manifests/system-test-elftest.p5m
@@ -106,6 +106,7 @@ file path=opt/elf-tests/tests/sections/shf-exclude/exclude-so mode=0555
file path=opt/elf-tests/tests/sections/shf-exclude/exclude.s mode=0444
file path=opt/elf-tests/tests/sections/shf-exclude/include-reloc mode=0555
file path=opt/elf-tests/tests/sections/shf-exclude/stub.c mode=0444
+file path=opt/elf-tests/tests/sections/shf-exclude/unknown-os mode=0555
dir path=opt/elf-tests/tests/string-merge
file path=opt/elf-tests/tests/string-merge/simple mode=0555
file path=opt/elf-tests/tests/string-merge/str1.s mode=0444
diff --git a/usr/src/test/elf-tests/runfiles/default.run b/usr/src/test/elf-tests/runfiles/default.run
index 45dde7efd0..6d833f9b53 100644
--- a/usr/src/test/elf-tests/runfiles/default.run
+++ b/usr/src/test/elf-tests/runfiles/default.run
@@ -45,7 +45,7 @@ tests = ['mixed-hidden-comdat']
[/opt/elf-tests/tests/sections/shf-exclude]
arch = i86pc
-tests = ['exclude-kmod', 'exclude-exec', 'exclude-so', 'include-reloc']
+tests = ['exclude-kmod', 'exclude-exec', 'exclude-so', 'include-reloc', 'unknown-os']
[/opt/elf-tests/tests/string-merge/]
tests = ['simple']
diff --git a/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile b/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile
index b1d06c8da7..e92f21bd32 100644
--- a/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile
+++ b/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile
@@ -17,7 +17,8 @@ include $(SRC)/test/Makefile.com
PROG = exclude-kmod \
exclude-so \
exclude-exec \
- include-reloc
+ include-reloc \
+ unknown-os
DATAFILES = Makefile.test exclude.s stub.c
diff --git a/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile.test b/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile.test
index 48515adeea..ed8f00fefb 100644
--- a/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile.test
+++ b/usr/src/test/elf-tests/tests/sections/shf-exclude/Makefile.test
@@ -11,7 +11,7 @@
# Copyright 2021, Richard Lowe.
-OBJS= exclude.o stub.o
+OBJS= exclude.o unknown-os-exclude.o stub.o
# Allow building out of the test harness easily too
SRCDIR=$(PWD)
@@ -20,6 +20,10 @@ SRCDIR=$(PWD)
all: $(OBJS)
+unknown-os-exclude.o: exclude.o
+ cp exclude.o $@;
+ elfedit -e 'shdr:sh_type .test 0x60000000' $@ # SHT_LOOS
+
%.o: $(SRCDIR)/%.c
gcc -m64 -c $< -o $@
@@ -40,3 +44,6 @@ test.exec: exclude.o stub.o
test.o: exclude.o stub.o
ld -zfatal-warnings -r exclude.o stub.o -o test.o
+
+test.unknown-os: unknown-os-exclude.o stub.o
+ ld -zfatal-warnings -r unknown-os-exclude.o stub.o -o test.unknown-os
diff --git a/usr/src/test/elf-tests/tests/sections/shf-exclude/unknown-os.sh b/usr/src/test/elf-tests/tests/sections/shf-exclude/unknown-os.sh
new file mode 100644
index 0000000000..4e892e0fb3
--- /dev/null
+++ b/usr/src/test/elf-tests/tests/sections/shf-exclude/unknown-os.sh
@@ -0,0 +1,37 @@
+#!/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 2021, Richard Lowe.
+
+TESTDIR=$(dirname $0)
+
+tmpdir=/tmp/test.$$
+mkdir $tmpdir
+cd $tmpdir
+
+cleanup() {
+ cd /
+ rm -fr $tmpdir
+}
+
+trap 'cleanup' EXIT
+
+if [[ $PWD != $tmpdir ]]; then
+ print -u2 "Failed to create temporary directory: $tmpdir"
+ exit 1;
+fi
+
+make -f ${TESTDIR}/Makefile.test SRCDIR=${TESTDIR} test.unknown-os
+if (( $? != 0 )); then
+ print -u2 "FAIL: Failed to link test.unknown-os"
+ exit 1;
+fi