libgloss: Fix lseek semihosting bug on nios2 and m68k
When off_t is 32 bits, the value needs to be sign-extended to 64 bits before shifting right to extract the high-order word. Previously negative offsets were incorrectly encoded. Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
This commit is contained in:
parent
65ad1c0ab0
commit
cd78225a50
|
@ -38,7 +38,7 @@ off_t lseek (int fd, off_t offset, int whence)
|
|||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
parameters[1] = (uint32_t) ((offset >> 32) & 0xffffffff);
|
||||
parameters[1] = (uint32_t) ((int64_t)offset >> 32);
|
||||
parameters[2] = (uint32_t) (offset & 0xffffffff);
|
||||
parameters[3] = __hosted_to_gdb_lseek_flags (whence);
|
||||
__hosted (HOSTED_LSEEK, parameters);
|
||||
|
|
|
@ -39,7 +39,7 @@ off_t lseek (int fd, off_t offset, int whence)
|
|||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
parameters[1] = (uint32_t) ((offset >> 32) & 0xffffffff);
|
||||
parameters[1] = (uint32_t) ((int64_t)offset >> 32);
|
||||
parameters[2] = (uint32_t) (offset & 0xffffffff);
|
||||
parameters[3] = __hosted_to_gdb_lseek_flags (whence);
|
||||
__io_hosted (HOSTED_LSEEK, parameters);
|
||||
|
|
Loading…
Reference in New Issue