On Mon, Feb 01, 2021 at 08:30:17PM -0500, Daniel Jakots wrote:
> On Mon, 01 Feb 2021 18:18:43 -0700, "Theo de Raadt"
> <dera...@openbsd.org> wrote:
> 
> > Should rdsetroot be able to edit gzip'd files?  I am not sure about
> > that.
> 
> Yeah, I don't think so either. gzip(1) can be easily used to uncompress
> it beforehand. 
> 
> But the result is still that rdsetroot on -current is not able to
> extract a bsd.rd even when given an uncompressed bsd.rd (i.e. a "ELF
> 64-bit LSB executable, x86-64, version 1" bsd.rd).
> 

I looked at what it is done for amd64/ramdisk_cd

bsd.rd target is made from bsd (kernel) + mr.fs (rdboot filesystem) with 
rdsetroot(8)
bsd.gz target is made from bsd.rd with strip(1) + gzip(1).

with current method, it is bsd.gz which is installed in RELEASEDIR as
bsd.rd file.


the problem is rdsetroot(8) doesn't support extracting the mr.fs part
from image when the image is stripped: it expects to find
"rd_root_size" and "rd_root_image" symbols to locate the size and the
offset of the mr.fs part inside the image.

It is possible to use strip with -K rd_root_size -K rd_root_image
option to preserve these specifics symbols (and make rdsetroot -x to
work again). I tested it successfully on i386.

diff a6394f126ec0ed0606e8aac07a82ab1a4c4f2988 /home/semarie/repos/openbsd/src
blob - 77fdc3e10fc525e725a40528b728c06976eefc06
file + distrib/i386/ramdisk_cd/Makefile
--- distrib/i386/ramdisk_cd/Makefile
+++ distrib/i386/ramdisk_cd/Makefile
@@ -56,8 +56,8 @@ MRMAKEFSARGS= -o disklabel=${MRDISKTYPE},minfree=0,den
 
 bsd.gz: bsd.rd
        cp bsd.rd bsd.strip
-       strip bsd.strip
-       strip -R .comment -R .SUNW_ctf bsd.strip
+       strip -K rd_root_size -K rd_root_image bsd.strip
+       strip -K rd_root_size -K rd_root_image -R .comment -R .SUNW_ctf 
bsd.strip
        gzip -9cn bsd.strip > bsd.gz
 
 bsd.rd: mr.fs bsd
                 
Please note that the second strip call need -K option too, else the
symtab is removed. I am a bit surprised by this behaviour.

I am unsure I will be able to provide a patch for all
architectures. Please comment if the direction is right or not.

Thanks.
-- 
Sebastien Marie

Reply via email to