summaryrefslogtreecommitdiffstats
path: root/scripts/signrom.py
diff options
context:
space:
mode:
authorPeter Maydell2016-08-10 16:59:08 +0200
committerPeter Maydell2016-08-10 16:59:08 +0200
commit4b3e5c06a15298d870e81c2d3a5a16dc2a93f5cc (patch)
tree7b52e327678a89a0baf99ef2405deb67bf4a2df0 /scripts/signrom.py
parentMerge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.7-20160810' into... (diff)
parentcheckpatch: default to success if only warnings (diff)
downloadqemu-4b3e5c06a15298d870e81c2d3a5a16dc2a93f5cc.tar.gz
qemu-4b3e5c06a15298d870e81c2d3a5a16dc2a93f5cc.tar.xz
qemu-4b3e5c06a15298d870e81c2d3a5a16dc2a93f5cc.zip
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* pc-bios/optionrom/Makefile fixes * warning fixes for __atomic_load and -1 << x in clang * missed interrupt fix from Gonglei * checkpatch fix from Radim and myself # gpg: Signature made Wed 10 Aug 2016 14:54:31 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: checkpatch: default to success if only warnings checkpatch: bump most warnings to errors CODING_STYLE, checkpatch: update line length rules checkpatch: check for CVS keywords on all sources checkpatch: tweak the files in which TABs are checked timer: set vm_clock disabled default checkpatch: ignore automatically imported Linux headers clang: Fix warning reg. expansion to 'defined' Disable warn about left shifts of negative values atomic: strip "const" from variables declared with typeof optionrom: fix compilation with mingw docker target optionrom: add -fno-stack-protector build-sys: fix building with make CFLAGS=.. argument linuxboot_dma: avoid guest ABI breakage on gcc vs. clang compilation Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/signrom.py')
-rw-r--r--scripts/signrom.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/scripts/signrom.py b/scripts/signrom.py
index 5629bca222..d1dabe0240 100644
--- a/scripts/signrom.py
+++ b/scripts/signrom.py
@@ -23,26 +23,21 @@ if magic != '\x55\xaa':
size_byte = ord(fin.read(1))
fin.seek(0)
+data = fin.read()
-if size_byte == 0:
- # If the caller left the size field blank then we will fill it in,
- # also rounding the whole input to a multiple of 512 bytes.
- data = fin.read()
- # +1 because we need a byte to store the checksum.
- size = len(data) + 1
- # Round up to next multiple of 512.
- size += 511
- size -= size % 512
- if size >= 65536:
- sys.exit("%s: option ROM size too large" % sys.argv[1])
+size = size_byte * 512
+if len(data) > size:
+ sys.stderr.write('error: ROM is too large (%d > %d)\n' % (len(data), size))
+ sys.exit(1)
+elif len(data) < size:
+ # Add padding if necessary, rounding the whole input to a multiple of
+ # 512 bytes according to the third byte of the input.
# size-1 because a final byte is added below to store the checksum.
data = data.ljust(size-1, '\0')
- data = data[:2] + chr(size/512) + data[3:]
else:
- # Otherwise the input file specifies the size so use it.
- # -1 because we overwrite the last byte of the file with the checksum.
- size = size_byte * 512 - 1
- data = fin.read(size)
+ if ord(data[-1:]) != 0:
+ sys.stderr.write('WARNING: ROM includes nonzero checksum\n')
+ data = data[:size-1]
fout.write(data)