Skip to contentSkip to conversation

pc-bios/s390-ccw: Small Makefile improvements

PATCH In review Marc Hartmayer 2 participants 6 messages Oct 1, 2024 – Oct 2, 2024

lore
Share & tools
lore
#0 lore raw

cover pc-bios/s390-ccw: Small Makefile improvements

Jens Remus (2):
pc-bios/s390-ccw: Clarify alignment is in bytes
pc-bios/s390-ccw: Don't generate TEXTRELs

Marc Hartmayer (1):
pc-bios/s390-ccw: Introduce EXTRA_LDFLAGS

 pc-bios/s390-ccw/netboot.mak |  2 +-
 pc-bios/s390-ccw/Makefile    |  5 +++--
 pc-bios/s390-ccw/start.S     | 11 +++++++----
 3 files changed, 11 insertions(+), 7 deletions(-)

base-commit: 718780d20470c66a3a36d036b29148d5809dc855

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 pc-bios/s390-ccw: Clarify alignment is in bytes

From: Jens Remus <[email protected]>

The assembler directive .align [1] has architecture-dependent behavior, which may be ambiguous for the reader. Some architectures perform the alignment in bytes, others in power of two. s390 does in bytes.

Use the directive .balign [2] instead, to clarify that the alignment request is in bytes. No functional change.

[1] https://sourceware.org/binutils/docs/as/Align.html
[2] https://sourceware.org/binutils/docs/as/Balign.html

---
 pc-bios/s390-ccw/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/start.S +2 -2
index 061b06591cff..576fc12c06e8 100644
@@ -112,7 +112,7 @@ io_new_code:
     lctlg   %c6,%c6,0(%r15)
     br      %r14
 
-    .align  8
+    .balign 8
 bss_start_literal:
     .quad   __bss_start
 disabled_wait_psw:
@@ -125,7 +125,7 @@ io_new_mask:
     .quad   0x0000000180000000
 
 .bss
-    .align  8
+    .balign 8
 stack:
     .space  STACK_SIZE
     .size   stack,STACK_SIZE
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 pc-bios/s390-ccw: Don't generate TEXTRELs

In reply to Marc Hartmayer

From: Jens Remus <[email protected]>

Commit 7cd50cbe4ca3 ("pc-bios/s390-ccw: Don't use __bss_start with the "larl" instruction") introduced the address constant bss_start_literal for __bss_start in the .text section, which introduced a relocation in code (i.e. TEXTREL). The dedicated constant is required, as __bss_start may not necessarily be aligned on a 2-byte boundary (see subject commit for details).

Move the constant to the .data section to get rid of the relocation in the .text section. Add the linker option -z text to prevent TEXTRELs to get introduced in the future.

Note that the R_390_RELATIVE relocations are taken care of by function glue() in include/hw/elf_ops.h.inc introduced by commit 5dce07e1cb67 ("elf-loader: Provide the possibility to relocate s390 ELF files").

---
 pc-bios/s390-ccw/Makefile | 2 +-
 pc-bios/s390-ccw/start.S  | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/Makefile +1 -1
index 6207911b53aa..ab6bd1edf41e 100644
@@ -40,7 +40,7 @@ EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
 EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
 EXTRA_CFLAGS += -msoft-float
 EXTRA_CFLAGS += -std=gnu99
-LDFLAGS += -Wl,-pie -nostdlib -z noexecstack
+LDFLAGS += -Wl,-pie -nostdlib -z noexecstack -z text
 
 cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
 cc-option = if $(call cc-test, $1); then \
pc-bios/s390-ccw/start.S +5 -2
index 576fc12c06e8..b70213e41246 100644
@@ -113,8 +113,6 @@ io_new_code:
     br      %r14
 
     .balign 8
-bss_start_literal:
-    .quad   __bss_start
 disabled_wait_psw:
     .quad   0x0002000180000000,0x0000000000000000
 enabled_wait_psw:
@@ -124,6 +122,11 @@ external_new_mask:
 io_new_mask:
     .quad   0x0000000180000000
 
+.data
+    .balign 8
+bss_start_literal:
+    .quad   __bss_start
+
 .bss
     .balign 8
 stack:
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 pc-bios/s390-ccw: Introduce `EXTRA_LDFLAGS`

In reply to Marc Hartmayer

Some packaging tools want to override LDFLAGS when building QEMU, this will result in a build error as most likely no -nostdlib flag is passed. Introduce EXTRA_LDFLAGS so that the packager can override LDFLAGS without breaking the build.

---
Note: Normally, I would rather use ALL_LDFLAGS, but adding EXTRA_LDFLAGS matches
with the current Makefile style.

---
 pc-bios/s390-ccw/netboot.mak | 2 +-
 pc-bios/s390-ccw/Makefile    | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/netboot.mak +1 -1
index 046aa35587ac..b1bc12603d99 100644
@@ -6,7 +6,7 @@ NETOBJS := start.o sclp.o cio.o virtio.o virtio-net.o jump2ipl.o netmain.o
 LIBC_INC := -nostdinc -I$(SLOF_DIR)/lib/libc/include
 LIBNET_INC := -I$(SLOF_DIR)/lib/libnet
 
-NETLDFLAGS := $(LDFLAGS) -Wl,-Ttext=0x7800000
+NETLDFLAGS := $(EXTRA_LDFLAGS) $(LDFLAGS) -Wl,-Ttext=0x7800000
 
 $(NETOBJS): EXTRA_CFLAGS += $(LIBC_INC) $(LIBNET_INC)
 
pc-bios/s390-ccw/Makefile +3 -2
index ab6bd1edf41e..56c971462992 100644
@@ -4,6 +4,7 @@ all: build-all
 
 include config-host.mak
 CFLAGS = -O2 -g
+LDFLAGS ?=
 MAKEFLAGS += -rR
 
 GIT_SUBMODULES = roms/SLOF
@@ -40,7 +41,7 @@ EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
 EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
 EXTRA_CFLAGS += -msoft-float
 EXTRA_CFLAGS += -std=gnu99
-LDFLAGS += -Wl,-pie -nostdlib -z noexecstack -z text
+EXTRA_LDFLAGS += -Wl,-pie -nostdlib -z noexecstack -z text
 
 cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
 cc-option = if $(call cc-test, $1); then \
@@ -58,7 +59,7 @@ config-cc.mak: Makefile
 build-all: s390-ccw.img s390-netboot.img
 
 s390-ccw.elf: $(OBJECTS)
-	$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),Linking)
+	$(call quiet-command,$(CC) $(EXTRA_LDFLAGS) $(LDFLAGS) -o $@ $(OBJECTS),Linking)
 
 s390-ccw.img: s390-ccw.elf
 	$(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,Stripping $< into)
Signature · 1 line
2.43.0
Reviewed-by on the v1 series
#4 lore raw
In reply to Marc Hartmayer
Quoted 5 lines · Marc Hartmayer

Jens Remus (2):
pc-bios/s390-ccw: Clarify alignment is in bytes pc-bios/s390-ccw: Don't generate TEXTRELs

Quoted 7 lines

Marc Hartmayer (1):
pc-bios/s390-ccw: Introduce EXTRA_LDFLAGS

  pc-bios/s390-ccw/netboot.mak |  2 +-
  pc-bios/s390-ccw/Makefile    |  5 +++--
  pc-bios/s390-ccw/start.S     | 11 +++++++----
  3 files changed, 11 insertions(+), 7 deletions(-)

Series

I'll queue it ... but will likely wait with sending a merge request for a while to see whether other s390-ccw bios patches will be ready within the next weeks (so that I don't have to build the s390-ccw.img multiple times within a release cycle)

Thomas

#5 lore raw
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Marc Hartmayer

Jens Remus (2):
pc-bios/s390-ccw: Clarify alignment is in bytes pc-bios/s390-ccw: Don't generate TEXTRELs

Marc Hartmayer (1):
pc-bios/s390-ccw: Introduce EXTRA_LDFLAGS

Quoted 7 lines
Quoted 4 lines
  pc-bios/s390-ccw/netboot.mak |  2 +-
  pc-bios/s390-ccw/Makefile    |  5 +++--
  pc-bios/s390-ccw/start.S     | 11 +++++++----
  3 files changed, 11 insertions(+), 7 deletions(-)

Series

Thanks.

Quoted 5 lines

I'll queue it ... but will likely wait with sending a merge request for a while to see whether other s390-ccw bios patches will be ready within the next weeks (so that I don't have to build the s390-ccw.img multiple times within a release cycle)

Makes sense.

Quoted 4 lines

Thomas

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294