All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com
Cc: borntraeger@linux.ibm.com, svens@linux.ibm.com,
	maskray@google.com,  ndesaulniers@google.com,
	linux-s390@vger.kernel.org,  linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, patches@lists.linux.dev,
	 Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 03/11] s390: vmlinux.lds.S: Explicitly handle '.got' and '.plt' sections
Date: Wed, 07 Feb 2024 17:14:55 -0700	[thread overview]
Message-ID: <20240207-s390-lld-and-orphan-warn-v1-3-8a665b3346ab@kernel.org> (raw)
In-Reply-To: <20240207-s390-lld-and-orphan-warn-v1-0-8a665b3346ab@kernel.org>

When building with CONFIG_LD_ORPHAN_WARN after selecting
CONFIG_ARCH_HAS_LD_ORPHAN_WARN, there are a lot of warnings around the
GOT and PLT sections:

  s390-linux-ld: warning: orphan section `.plt' from `arch/s390/kernel/head64.o' being placed in section `.plt'
  s390-linux-ld: warning: orphan section `.got' from `arch/s390/kernel/head64.o' being placed in section `.got'
  s390-linux-ld: warning: orphan section `.got.plt' from `arch/s390/kernel/head64.o' being placed in section `.got.plt'
  s390-linux-ld: warning: orphan section `.iplt' from `arch/s390/kernel/head64.o' being placed in section `.iplt'
  s390-linux-ld: warning: orphan section `.igot.plt' from `arch/s390/kernel/head64.o' being placed in section `.igot.plt'

  s390-linux-ld: warning: orphan section `.iplt' from `arch/s390/boot/head.o' being placed in section `.iplt'
  s390-linux-ld: warning: orphan section `.igot.plt' from `arch/s390/boot/head.o' being placed in section `.igot.plt'
  s390-linux-ld: warning: orphan section `.got' from `arch/s390/boot/head.o' being placed in section `.got'

Currently, only the '.got' section is actually emitted in the final
binary. In a manner similar to other architectures, put the '.got'
section near the '.data' section and coalesce the PLT sections,
checking that the final section is zero sized, which is a safe/tested
approach versus full discard.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/s390/boot/vmlinux.lds.S   | 19 +++++++++++++++++++
 arch/s390/kernel/vmlinux.lds.S | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/arch/s390/boot/vmlinux.lds.S b/arch/s390/boot/vmlinux.lds.S
index 389df0e0d9e5..4aa2f340c8d9 100644
--- a/arch/s390/boot/vmlinux.lds.S
+++ b/arch/s390/boot/vmlinux.lds.S
@@ -39,6 +39,9 @@ SECTIONS
 		*(.rodata.*)
 		_erodata = . ;
 	}
+	.got : {
+		*(.got)
+	}
 	NOTES
 	.data :	{
 		_data = . ;
@@ -118,6 +121,22 @@ SECTIONS
 	}
 	_end = .;
 
+	/*
+	 * Sections that should stay zero sized, which is safer to
+	 * explicitly check instead of blindly discarding.
+	 */
+	.got.plt : {
+		*(.got.plt)
+	}
+	ASSERT(SIZEOF(.got.plt) == 0, "Unexpected GOT/PLT entries detected!")
+	.plt : {
+		*(.plt)
+		*(.plt.*)
+		*(.iplt)
+		*(.igot .igot.plt)
+	}
+	ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
+
 	/* Sections to be discarded */
 	/DISCARD/ : {
 		*(.eh_frame)
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index d231a3faf981..661a487a3048 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -62,6 +62,9 @@ SECTIONS
 	.data.rel.ro : {
 		*(.data.rel.ro .data.rel.ro.*)
 	}
+	.got : {
+		*(.got)
+	}
 
 	. = ALIGN(PAGE_SIZE);
 	_sdata = .;		/* Start of data section */
@@ -241,6 +244,22 @@ SECTIONS
 	DWARF_DEBUG
 	ELF_DETAILS
 
+	/*
+	 * Sections that should stay zero sized, which is safer to
+	 * explicitly check instead of blindly discarding.
+	 */
+	.got.plt : {
+		*(.got.plt)
+	}
+	ASSERT(SIZEOF(.got.plt) == 0, "Unexpected GOT/PLT entries detected!")
+	.plt : {
+		*(.plt)
+		*(.plt.*)
+		*(.iplt)
+		*(.igot .igot.plt)
+	}
+	ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
+
 	/* Sections to be discarded */
 	DISCARDS
 	/DISCARD/ : {

-- 
2.43.0


  parent reply	other threads:[~2024-02-08  0:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08  0:14 [PATCH 00/11] s390: Support linking with ld.lld Nathan Chancellor
2024-02-08  0:14 ` [PATCH 01/11] s390: boot: Add support for CONFIG_LD_ORPHAN_WARN Nathan Chancellor
2024-02-08  0:14 ` [PATCH 02/11] s390: vmlinux.lds.S: Handle '.data.rel' sections explicitly Nathan Chancellor
2024-02-08  0:14 ` Nathan Chancellor [this message]
2024-02-13  5:31   ` [PATCH 03/11] s390: vmlinux.lds.S: Explicitly handle '.got' and '.plt' sections Fangrui Song
2024-02-14 12:20     ` Heiko Carstens
2024-02-14 19:48       ` Nathan Chancellor
2024-02-08  0:14 ` [PATCH 04/11] s390: vmlinux.lds.S: Discard unnecessary sections Nathan Chancellor
2024-02-12 13:55   ` Heiko Carstens
2024-02-12 15:19     ` Heiko Carstens
2024-02-13  0:15     ` Nathan Chancellor
2024-02-08  0:14 ` [PATCH 05/11] s390/boot: vmlinux.lds.S: Handle '.init.text' Nathan Chancellor
2024-02-08  0:14 ` [PATCH 06/11] s390/boot: vmlinux.lds.S: Handle '.rela' sections Nathan Chancellor
2024-02-13  5:18   ` Fangrui Song
2024-02-14 12:17     ` Heiko Carstens
2024-02-14 21:32       ` Fangrui Song
2024-02-08  0:14 ` [PATCH 07/11] s390/boot: vmlinux.lds.S: Handle DWARF debug sections Nathan Chancellor
2024-02-13  5:33   ` Fangrui Song
2024-02-08  0:15 ` [PATCH 08/11] s390/boot: vmlinux.lds.S: Handle ELF required sections Nathan Chancellor
2024-02-08  0:15 ` [PATCH 09/11] s390/boot: vmlinux.lds.S: Handle commonly discarded sections Nathan Chancellor
2024-02-08  0:15 ` [PATCH 10/11] s390: Select CONFIG_ARCH_WANT_LD_ORPHAN_WARN Nathan Chancellor
2024-02-08  0:15 ` [PATCH 11/11] s390: Link vmlinux with '-z notext' Nathan Chancellor
2024-02-13  5:20   ` Fangrui Song
2024-02-08 23:14 ` [PATCH 00/11] s390: Support linking with ld.lld Justin Stitt
2024-02-09 11:20 ` Heiko Carstens
2024-02-09 15:08   ` Nathan Chancellor
2024-02-14 13:43 ` Heiko Carstens
2024-02-14 19:57   ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240207-s390-lld-and-orphan-warn-v1-3-8a665b3346ab@kernel.org \
    --to=nathan@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=maskray@google.com \
    --cc=ndesaulniers@google.com \
    --cc=patches@lists.linux.dev \
    --cc=svens@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.