Re: [PATCH] libgloss: Fix lseek semihosting bug on nios2 and m68k

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Feb  4 21:34, Sandra Loosemore wrote:
> 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 <[email protected]>
> ---
>  libgloss/m68k/io-lseek.c  | 2 +-
>  libgloss/nios2/io-lseek.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libgloss/m68k/io-lseek.c b/libgloss/m68k/io-lseek.c
> index 63ec564..eaaf557 100644
> --- a/libgloss/m68k/io-lseek.c
> +++ b/libgloss/m68k/io-lseek.c
> @@ -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);
> diff --git a/libgloss/nios2/io-lseek.c b/libgloss/nios2/io-lseek.c
> index bfc23c1..d47fe07 100644
> --- a/libgloss/nios2/io-lseek.c
> +++ b/libgloss/nios2/io-lseek.c
> @@ -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);
> -- 
> 2.8.1

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl475FgACgkQ9TYGna5E
T6BLrBAAidhn5K17ceAsbY4UQxLepEihT4mLqX4n/cFUS/qMPOTbaS0OAvuV/qFt
pGItS04gFICQ5Gdx2W2Z3C/LdGJzgOifq3Y3iY1Qi0kkWFXxtkAim/6xoM2Y0nAx
7U/NDpEJG08gLUgH5BxQdzpENGvcu7TVzdgEpeeiQEOC4mIV+oh2bjpAnP5And9e
wVVQb/ZvPe9p5LV67mSxUTx6p9qG3aNlbd0CU0KJ0V6AiGzlzbt1U2p3wng5ODkN
D9oSd/ytsZLcTz+lNkX1zSCT1iPGYbnh4MNYnxbNY7tdgC2mo4XIKYF5wVrsbVir
dKODmcFuonqdY6AjMYXDDHmKWT95eGbeGohmxiWyb8s3KsV3ozYWRiM3ku64O9bP
ubgtk5oa/olBabmq+TumBsW+k07hI4PIohBYjDSmcM5ZDNmYKTqYbHf6Vut2PLGF
OmtJrMnYsy2P506TUZw3/7gKV/DuOfBhcin25d4Chsr3FZboGKQr8aXfK3Kk21mk
7Lnr2gc6XdX59IEO8kysuiqtZDrdH9Gb0P3nSuK4PmtyAdXr9LXRZkRfR2PosMxR
SwcN6Ts2pDnYEjUcRHvJm/QTBuKDSIFjiCxCwlEp3bUb8Zt5tN+FJltOJpBDlUSH
O+JcoIY7/npDBsvl7Q3jhkxwdWI0QCAWktTBFAOWDX4YekiRJU4=
=kGT1
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.