@@ -210,52 +210,39 @@ register_binfmt() {
210210 return
211211 fi
212212 _cpu=arm
213- _magic=" \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00"
214- _mask=" \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
215213 ;;
216214 aarch64)
217215 _cpu=aarch64
218- _magic=" \x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7"
219- _mask=" \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
220216 ;;
221217 ppc64le)
222218 _cpu=ppc64le
223- _magic=" \x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00"
224- _mask=" \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00"
225219 ;;
226220 ppc64)
227221 _cpu=ppc64
228- _magic=" \x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15"
229- _mask=" \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
230222 ;;
231223 ppc)
232224 if [ " $_hostarch " = " ppc64" ] ; then
233225 return
234226 fi
235227 _cpu=ppc
236- _magic=" \x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14"
237- _mask=" \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
238228 ;;
239229 mipsel)
240230 if [ " $_hostarch " = " mips64el" ] ; then
241231 return
242232 fi
243233 _cpu=mipsel
244- _magic=" \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00"
245- _mask=" \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
246234 ;;
247235 x86_64)
248236 _cpu=x86_64
249- _magic=" \x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00"
250- _mask=" \xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
251237 ;;
252238 i686)
253239 if [ " $_hostarch " = " x86_64" ] ; then
254240 return
255241 fi
256242 _cpu=i386
257- _magic=" \x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00"
258- _mask=" \xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
243+ ;;
244+ riscv64)
245+ _cpu=riscv64
259246 ;;
260247 * )
261248 die " Unknown target architecture!"
@@ -264,7 +251,7 @@ register_binfmt() {
264251
265252 # For builds that do not match the host architecture, the correct
266253 # qemu binary will be required.
267- QEMU_BIN=" qemu-${_cpu} -static "
254+ QEMU_BIN=" qemu-${_cpu} "
268255 if ! $QEMU_BIN -version > /dev/null 2>&1 ; then
269256 die " $QEMU_BIN binary is missing in your system, exiting."
270257 fi
@@ -278,7 +265,10 @@ register_binfmt() {
278265
279266 # Only register if the map is incomplete
280267 if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then
281- echo " :qemu-$_cpu :M::$_magic :$_mask :/usr/bin/$QEMU_BIN :F" > /proc/sys/fs/binfmt_misc/register 2> /dev/null
268+ if ! command -v update-binfmts > /dev/null 2>&1 ; then
269+ die " could not add binfmt: update-binfmts binary is missing in your system"
270+ fi
271+ update-binfmts --import " qemu-$_cpu "
282272 fi
283273}
284274
0 commit comments