From: Marc Hartmayer <mhartmay@linux.ibm.com>
To: <linux-s390@vger.kernel.org>, Thomas Huth <thuth@redhat.com>,
Nicholas Piggin <npiggin@gmail.com>
Cc: <kvm@vger.kernel.org>, Janosch Frank <frankja@linux.ibm.com>,
Nico Boehr <nrb@linux.ibm.com>,
Steffen Eiden <seiden@linux.ibm.com>
Subject: [kvm-unit-tests PATCH v1 2/3] s390x/Makefile: snippets: Avoid creation of .eh_frame and .eh_frame_hdr sections
Date: Tue, 4 Jun 2024 13:59:31 +0200 [thread overview]
Message-ID: <20240604115932.86596-3-mhartmay@linux.ibm.com> (raw)
In-Reply-To: <20240604115932.86596-1-mhartmay@linux.ibm.com>
Use `-fno-asynchronous-unwind-tables` and `-fno-exceptions` to avoid creating
`.eh_frame` and `.eh_frame_hdr` sections. They are not used by the snippets and
the creation of the sections may result in the creation of an RWX
segment (depending on the toolchain used).
Before this change:
$ make -j s390x/snippets/c/spec_ex.elf >/dev/null && readelf -l s390x/snippets/c/spec_ex.elf
/usr/bin/s390x-linux-gnu-ld: warning: s390x/snippets/c/spec_ex.elf has a LOAD segment with RWX permissions
Elf file type is EXEC (Executable file)
Entry point 0x4000
There are 4 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000001000 0x0000000000000000 0x0000000000000000
0x00000000000001b0 0x00000000000001b0 RW 0x1000
LOAD 0x0000000000002000 0x0000000000004000 0x0000000000004000
0x000000000000104c 0x0000000000001060 RWE 0x1000
GNU_EH_FRAME 0x0000000000003038 0x0000000000005038 0x0000000000005038
0x0000000000000014 0x0000000000000014 R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
Section to Segment mapping:
Segment Sections...
00 .lowcore
01 .text .eh_frame .eh_frame_hdr .bss
02 .eh_frame_hdr
03
After this change, there is no warning and no RWX ELF segment:
$ make -j s390x/snippets/c/spec_ex.elf >/dev/null && readelf -l s390x/snippets/c/spec_ex.elf
Elf file type is EXEC (Executable file)
Entry point 0x4000
There are 4 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000001000 0x0000000000000000 0x0000000000000000
0x00000000000001b0 0x00000000000001b0 RW 0x1000
LOAD 0x0000000000002000 0x0000000000004000 0x0000000000004000
0x00000000000000a8 0x00000000000000a8 R E 0x1000
LOAD 0x0000000000000000 0x0000000000005000 0x0000000000005000
0x0000000000000000 0x0000000000000010 RW 0x1000
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
Section to Segment mapping:
Segment Sections...
00 .lowcore
01 .text
02 .bss
03
Linker used:
$ s390x-linux-gnu-ld -v
GNU ld version 2.41-1.fc40
Therefore the commit 9801dbbe9ea4 ("s390x: Specify program headers with flags to
avoid linker warnings") can be reverted.
---
Note: we have to double check whether__builtin_frame_address() in s390x/stack.c
needs the .eh_frame or not.
---
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
s390x/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/s390x/Makefile b/s390x/Makefile
index 784818b2883e..f1bbf5e9f457 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -148,10 +148,10 @@ endif
# the asm/c snippets %.o have additional generated files as dependencies
$(SNIPPET_DIR)/asm/%.o: $(SNIPPET_DIR)/asm/%.S $(asm-offsets)
- $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
+ $(CC) $(CFLAGS) -c -nostdlib -fno-asynchronous-unwind-tables -fno-exceptions -o $@ $<
$(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets)
- $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
+ $(CC) $(CFLAGS) -c -nostdlib -fno-asynchronous-unwind-tables -fno-exceptions -o $@ $<
$(SNIPPET_DIR)/asm/%.elf: $(SNIPPET_DIR)/asm/%.o $(SNIPPET_DIR)/asm/flat.lds
$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/asm/flat.lds $<
--
2.34.1
next prev parent reply other threads:[~2024-06-04 11:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-04 11:59 [kvm-unit-tests PATCH v1 0/3] s390x: small Makefile improvements Marc Hartmayer
2024-06-04 11:59 ` [kvm-unit-tests PATCH v1 1/3] s390x/Makefile: snippets: Add separate target for the ELF snippets Marc Hartmayer
2024-06-05 1:21 ` Nicholas Piggin
2024-06-05 7:32 ` Marc Hartmayer
2024-07-26 10:01 ` Janosch Frank
2024-07-29 7:00 ` Janosch Frank
2024-07-29 7:41 ` Marc Hartmayer
2024-06-04 11:59 ` Marc Hartmayer [this message]
2024-06-04 11:59 ` [kvm-unit-tests PATCH v1 3/3] Revert "s390x: Specify program headers with flags to avoid linker warnings" Marc Hartmayer
2024-06-04 12:04 ` Marc Hartmayer
2024-06-05 1:30 ` [kvm-unit-tests PATCH v1 0/3] s390x: small Makefile improvements Nicholas Piggin
2024-06-05 8:03 ` Marc Hartmayer
2024-07-26 8:31 ` Marc Hartmayer
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=20240604115932.86596-3-mhartmay@linux.ibm.com \
--to=mhartmay@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=npiggin@gmail.com \
--cc=nrb@linux.ibm.com \
--cc=seiden@linux.ibm.com \
--cc=thuth@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox