qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [PATCH 17/17] Build elf test cases instead of raw binaries
Date: Sat, 11 May 2024 13:54:00 +0200	[thread overview]
Message-ID: <20240511115400.7587-18-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240511115400.7587-1-richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 Makefile       | 19 ++++++++++---------
 test.ld        | 12 ++++++++++++
 test_aarch64.s |  4 ++--
 test_arm.s     | 16 +++++++++++-----
 test_i386.S    |  4 +++-
 5 files changed, 38 insertions(+), 17 deletions(-)
 create mode 100644 test.ld

diff --git a/Makefile b/Makefile
index ad7f879..2bd08aa 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,8 @@ ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) -U$(ARCH) $(BUILD_INC) $(CFLAGS)
 PROG=risu
 SRCS=risu.c comms.c risu_$(ARCH).c risu_reginfo_$(ARCH).c
 HDRS=risu.h risu_reginfo_$(ARCH).h
-BINS=test_$(ARCH).bin
+BINO=test_$(ARCH).o
+BINE=test_$(ARCH).elf
 
 # For dumping test patterns
 RISU_BINS=$(wildcard *.risu.bin)
@@ -30,7 +31,7 @@ RISU_ASMS=$(patsubst %.bin,%.asm,$(RISU_BINS))
 
 OBJS=$(SRCS:.c=.o)
 
-all: $(PROG) $(BINS)
+all: $(PROG) $(BINE)
 
 dump: $(RISU_ASMS)
 
@@ -43,17 +44,17 @@ $(PROG): $(OBJS)
 %.o: %.c $(HDRS)
 	$(CC) $(CPPFLAGS) $(ALL_CFLAGS) -o $@ -c $<
 
-%_$(ARCH).bin: %_$(ARCH).elf
-	$(OBJCOPY) -O binary $< $@
+%_$(ARCH).o: %_$(ARCH).s
+	$(CC) -o $@ -c $<
 
-%_$(ARCH).elf: %_$(ARCH).s
-	$(AS) -o $@ $<
-
-%_$(ARCH).elf: %_$(ARCH).S
+%_$(ARCH).o: %_$(ARCH).S
 	$(CC) $(CPPFLAGS) -o $@ -c $<
 
+%_$(ARCH).elf: test.ld %_$(ARCH).o
+	$(LD) -o $@ -T $^
+
 clean:
-	rm -f $(PROG) $(OBJS) $(BINS)
+	rm -f $(PROG) $(OBJS) $(BINO) $(BINE)
 
 distclean: clean
 	rm -f config.h Makefile.in
diff --git a/test.ld b/test.ld
new file mode 100644
index 0000000..eb0a76a
--- /dev/null
+++ b/test.ld
@@ -0,0 +1,12 @@
+ENTRY(start)
+
+PHDRS {
+    text PT_LOAD FILEHDR PHDRS;
+}
+
+SECTIONS {
+    . = SIZEOF_HEADERS;
+    PROVIDE(start = .);
+    .text : { *(.text) } :text
+    .data : { *(.data) } :text
+}
diff --git a/test_aarch64.s b/test_aarch64.s
index f75d588..88902c6 100644
--- a/test_aarch64.s
+++ b/test_aarch64.s
@@ -80,6 +80,6 @@ fmov d31, #31.0
 /* do compare.
  * The manual says instr with bits (28,27) == 0 0 are UNALLOCATED
  */
-.int 0x00005af0
+.inst 0x00005af0
 /* exit test */
-.int 0x00005af1
+.inst 0x00005af1
diff --git a/test_arm.s b/test_arm.s
index 49552f2..62582e7 100644
--- a/test_arm.s
+++ b/test_arm.s
@@ -9,20 +9,26 @@
  *     Peter Maydell (Linaro) - initial implementation
  *******************************************************************************/
 
+.text
+
 /* magic instruction to force ARM mode whether we were in ARM or Thumb before */
-.int 0xe0004778
+.inst 0xe0004778
+
 /* Initialise the gp regs */
 add r0, pc, #4
 ldmia r0, {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r14}
-b next
+b 1f
+
 .int 0,1,2,3,4,5,6,7,8,9,10,11,12,14
-next:
+
+1:
 msr CPSR_fs, #0
+
 /* do compare.
  * The space 0xE7F___F_ is guaranteed to always UNDEF
  * and not to be allocated for insns in future architecture
  * revisions.
  */
-.int 0xe7fe5af0
+.inst 0xe7fe5af0
 /* exit test */
-.int 0xe7fe5af1
+.inst 0xe7fe5af1
diff --git a/test_i386.S b/test_i386.S
index 05344d7..2e2b090 100644
--- a/test_i386.S
+++ b/test_i386.S
@@ -13,6 +13,7 @@
 
 /* Initialise the registers to avoid spurious mismatches */
 
+.text
 #ifdef __x86_64__
 #define BASE	%rax
 	lea	2f(%rip), BASE
@@ -71,7 +72,8 @@
 /* exit test */
 	ud1	%ecx, %eax
 
-	.p2align 16
+.data
+	.balign 16
 2:
 	.set	i, 0
 	.rept	256
-- 
2.34.1



  parent reply	other threads:[~2024-05-11 11:55 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11 11:53 [PATCH 00/17] RISU misc updates Richard Henderson
2024-05-11 11:53 ` [PATCH 01/17] ppc64: Fix <sys/user.h> include order Richard Henderson
2024-05-15 13:11   ` Philippe Mathieu-Daudé
2024-05-15 13:53     ` Richard Henderson
2024-05-15 16:55       ` Philippe Mathieu-Daudé
2024-05-16 13:32         ` Richard Henderson
2024-05-11 11:53 ` [PATCH 02/17] Fix load_image error check for mmap Richard Henderson
2024-05-15 12:51   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 03/17] Standardize reginfo_dump_mismatch printing Richard Henderson
2024-05-21 12:20   ` Peter Maydell
2024-05-11 11:53 ` [PATCH 04/17] Add --fulldump and --diffdup options Richard Henderson
2024-05-11 11:53 ` [PATCH 05/17] Remove return value from reginfo_dump Richard Henderson
2024-05-15 12:52   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 06/17] ppc64: Clean register values in reginfo_init Richard Henderson
2024-05-21 12:22   ` Peter Maydell
2024-05-11 11:53 ` [PATCH 07/17] ppc64: Compare all bits of CCR Richard Henderson
2024-05-15 12:54   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 08/17] ppc64: Simplify reginfo_is_eq Richard Henderson
2024-05-21 12:23   ` Peter Maydell
2024-05-11 11:53 ` [PATCH 09/17] ppc64: Clean up reginfo_dump Richard Henderson
2024-05-21 12:25   ` Peter Maydell
2024-05-11 11:53 ` [PATCH 10/17] aarch64: Tidy reginfo dumping ahead of ZA state Richard Henderson
2024-05-15 12:55   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 11/17] aarch64: Add support for ZA storage Richard Henderson
2024-05-11 11:53 ` [PATCH 12/17] aarch64: Trivial SME test Richard Henderson
2024-05-21 12:27   ` Peter Maydell
2024-05-11 11:53 ` [PATCH 13/17] Use bool for reginfo_is_eq Richard Henderson
2024-05-15 12:56   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 14/17] aarch64: Use bool for sve_{z,p}reg_is_eq Richard Henderson
2024-05-15 12:56   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 15/17] risu: Allow use of ELF test files Richard Henderson
2024-05-15 13:03   ` Philippe Mathieu-Daudé
2024-05-11 11:53 ` [PATCH 16/17] configure: Enable loongarch64 Richard Henderson
2024-05-15 13:06   ` Philippe Mathieu-Daudé
2024-05-15 13:08   ` Philippe Mathieu-Daudé
2024-05-11 11:54 ` Richard Henderson [this message]
2024-05-15 13:08   ` [PATCH 17/17] Build elf test cases instead of raw binaries Philippe Mathieu-Daudé
2024-05-21 12:46 ` [PATCH 00/17] RISU misc updates Peter Maydell

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=20240511115400.7587-18-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).