From e0f86d4dc09865956afef3277299a00a9136918d Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Tue, 13 Apr 2021 11:55:32 +0200 Subject: [PATCH] d/s390fw.mak: retain boot rom debuginfo Currently we have stripped roms which can be non-useful in some debugging cases: s390-ccw.img: ELF 64-bit MSB pie executable, IBM S/390, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, BuildID[sha1]=13d565dd0aaed9c6b14f1c406a7d069c19013bce, stripped s390-netboot.img: ELF 64-bit MSB pie executable, IBM S/390, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, BuildID[sha1]=7f9b1ec0a9343bc907335ba7978881354a843a30, stripped They appear as linked objects with a build-id (strange right). I've learned that for bootloader debugging you'd ant to load that debug data. If you had debuginfo example steps are: 1. use qemu with gdbserver https://wiki.qemu.org/Features/gdbstub 2. attach to gdbserver gdb /usr/bin/qemu-system-s390x -ex "target remote localhost:1234" 3. add-symbol-file "path-to-bios" -o 0x7fe00000 # because this is the guest address the bios is loaded to Note: in the s390x case as a bonus some of it is EBSDIC encoded. So you might also want to use `set target-charset ...` Developers are used to debuginfo being stored by buildid as it is done in dh_strip. Also the FHS kind of implies this path, therefore this fillows those usual paths. In dh_strip the path is split and due to that Build ID: e65a23729d5a540c689b725703e095c961ff72c1 Becomes /usr/lib/debug/.build-id/e6/5a23729d5a540c689b725703e095c961ff72c1.debug The calls it uses are: objcopy --only-keep-debug --compress-debug-sections infile outfile strip --remove-section=.comment --remove-section=.note" --strip-unneeded infile This implements the same in debian/s390fw.mak for our s390x FW builds. In regard to size we talk about 14k+18k, so IMHO an extra qemu-system-data-dbgsym isn't needed, but could be created if preferred. Signed-off-by: Christian Ehrhardt --- debian/rom-strip | 16 ++++++++++++++++ debian/rules | 4 +++- debian/s390fw.mak | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 debian/rom-strip diff --git a/debian/rom-strip b/debian/rom-strip new file mode 100755 index 0000000000..21d0bc0f70 --- /dev/null +++ b/debian/rom-strip @@ -0,0 +1,16 @@ +#!/bin/sh +set -uxe +CROSSPFX=${1} +IMAGE=${2} +DEBUGPATH="b/s390fw/usr/lib/debug/.build-id" + +BUILDID1=$(readelf -n ${IMAGE} | grep '^\s*Build ID:' | cut -c 15-16) +BUILDID2=$(readelf -n ${IMAGE} | grep '^\s*Build ID:' | cut -c 17-) + +mkdir -p "${DEBUGPATH}/${BUILDID1}" + +${CROSSPFX}objcopy --only-keep-debug --compress-debug-sections \ + "${IMAGE}" "${DEBUGPATH}/${BUILDID1}/${BUILDID2}.debug" + +${CROSSPFX}strip --remove-section=.comment --remove-section=.note \ + --strip-unneeded "${IMAGE}" diff --git a/debian/rules b/debian/rules index 9d9f18f740..7031395acf 100755 --- a/debian/rules +++ b/debian/rules @@ -38,7 +38,8 @@ enable_linux_user = $(if $(filter qemu-user,${BUILD_PACKAGES}),enable,disable) FIRMWAREPATH = /usr/share/qemu:/usr/share/seabios:/usr/lib/ipxe/qemu PKGVERSION = Debian ${DEB_VERSION} SAVEMODDIR = /run/qemu/$(shell echo -n "${PKGVERSION}" | tr --complement '[:alnum:]+-.~' '_') -sysdatadir = debian/qemu-system-data/usr/share/qemu +sysdatabase = debian/qemu-system-data +sysdatadir = ${sysdatabase}/usr/share/qemu ALPHAEV67_CROSSPFX = alpha-linux-gnu- PPC64_CROSSPFX = powerpc64-linux-gnu- @@ -488,6 +489,7 @@ b/s390fw/built: touch $@ install-s390x-fw: build-s390x-fw install -m 0644 -t "${sysdatadir}" b/s390fw/s390*.img + cp -av b/s390fw/usr debian/qemu-system-data sysdata-components += s390x-fw ### hppa-firmware (roms/seabios-hppa) diff --git a/debian/s390fw.mak b/debian/s390fw.mak index 64fab0f2c0..7061db7e56 100644 --- a/debian/s390fw.mak +++ b/debian/s390fw.mak @@ -20,7 +20,7 @@ CCW_FSRCS = $(addprefix pc-bios/s390-ccw/,${CCW_SRCS}) ${OUT}s390-ccw.img: $(CCW_FSRCS) ${S390X_CROSSPFX}gcc -o $@ ${LDFLAGS} $^ - ${S390X_CROSSPFX}strip --strip-unneeded $@ + ./debian/rom-strip $(S390X_CROSSPFX) $@ chmod -x $@ NETBOOT_SRCS = start.S sclp.c cio.c virtio.c virtio-net.c jump2ipl.c netmain.c @@ -45,5 +45,5 @@ ${OUT}s390-netboot.img: ${NETBOOT_FSRCS} ${SLOF_LIBSRCS} ${S390X_CROSSPFX}gcc -o $@ ${LDFLAGS} -Ttext=0x7800000 \ -nostdinc -I${SLOFLIB}include -I${SLOF}/lib/libnet -DDHCPARCH=0x1F \ $^ - ${S390X_CROSSPFX}strip --strip-unneeded $@ + ./debian/rom-strip $(S390X_CROSSPFX) $@ chmod -x $@ -- GitLab