summaryrefslogtreecommitdiff
path: root/libinstaller/syslxmod.c
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2012-11-29 10:15:17 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2012-11-29 10:15:17 +0000
commitede8500d7c710e4ddf650f1a1ef3ccf2a89e5313 (patch)
tree9ad9a12392d6011d384182008cccb0665748cff0 /libinstaller/syslxmod.c
parent38dcca25c8855c95649e3f0b5b09fae862ed5c7a (diff)
parenta0ded54115637b7d239867a79095d20781bb0014 (diff)
downloadsyslinux-ede8500d7c710e4ddf650f1a1ef3ccf2a89e5313.tar.gz
Merge tag 'syslinux-4.05' into ct/genivi/morph
syslinux-4.05
Diffstat (limited to 'libinstaller/syslxmod.c')
-rw-r--r--libinstaller/syslxmod.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c
index a68f19fb..8847b736 100644
--- a/libinstaller/syslxmod.c
+++ b/libinstaller/syslxmod.c
@@ -33,26 +33,29 @@
static void generate_extents(struct syslinux_extent *ex, int nptrs,
const sector_t *sectp, int nsect)
{
- uint32_t addr = 0x7c00 + 2*SECTOR_SIZE;
+ uint32_t addr = 0x8000; /* ldlinux.sys starts loading here */
uint32_t base;
sector_t sect, lba;
unsigned int len;
- len = lba = base = 0;
+ base = addr;
+ len = lba = 0;
memset(ex, 0, nptrs * sizeof *ex);
while (nsect) {
sect = *sectp++;
- if (len && sect == lba + len &&
- ((addr ^ (base + len * SECTOR_SIZE)) & 0xffff0000) == 0) {
- /* We can add to the current extent */
- len++;
- goto next;
- }
-
if (len) {
+ uint32_t xbytes = (len + 1) * SECTOR_SIZE;
+
+ if (sect == lba + len && xbytes < 65536 &&
+ ((addr ^ (base + xbytes - 1)) & 0xffff0000) == 0) {
+ /* We can add to the current extent */
+ len++;
+ goto next;
+ }
+
set_64_sl(&ex->lba, lba);
set_16_sl(&ex->len, len);
ex++;