[main] replace computed value by a constant
authorMiguel de Icaza <miguel@gnome.org>
Wed, 15 Jun 2016 06:24:48 +0000 (23:24 -0700)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 15 Jun 2016 06:25:30 +0000 (23:25 -0700)
The reason why mkbundle is not working is that for some reason
this constant expression is producing different code than the
-24 that it is supposed to.

What is odd is that the return value from the lseek system
call is the same, but yet, read fails with an end-of-file with
this value, and otherwise it passes.

With this call:

     lseek (fd, -(16+sizeof(uint64_t)), SEEK_END)

strace displays:

lseek(0x3, 0xFFFFFFE8, 0x2)  = 19375512 0

With this call:

     lseek (fd, -24, SEEK_END)

strace displays:

lseek(0x3, 0xFFFFFFFFFFFFFFE8, 0x2)  = 19375512 0

Now, while both results from lseek are the same, a subsequent read
with 24 bytes to read returns zero on the former case, and 24 on
the latter case.

mono/mini/main.c

index 276f7952fba6624a64c7ac93449080c14aa9876f..241e6f57e59772d39287fe0b22cb5c2326ce0925 100644 (file)
@@ -52,7 +52,7 @@ probe_embedded (const char *program, int *ref_argc, char **ref_argv [])
        int fd = open (program, O_RDONLY);
        if (fd == -1)
                return FALSE;
-       if ((sigstart = lseek (fd, -(16+sizeof(uint64_t)), SEEK_END)) == -1)
+       if ((sigstart = lseek (fd, -24, SEEK_END)) == -1)
                goto doclose;
        if (read (fd, sigbuffer, sizeof (sigbuffer)) == -1)
                goto doclose;