Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Aug 2010 23:42:36 -0700
From:      Neel Natu <neelnatu@gmail.com>
To:        Stefan Farfeleder <stefanf@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r211130 - head/libexec/rtld-elf/mips
Message-ID:  <AANLkTimwoLfMXrNb7NmG%2BHWonug1-asmNdAE9AcSNHkK@mail.gmail.com>
In-Reply-To: <20100810062829.GA1737@mole.fafoe.narf.at>
References:  <201008100515.o7A5FZZF017552@svn.freebsd.org> <20100810062829.GA1737@mole.fafoe.narf.at>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Stefan,

On Mon, Aug 9, 2010 at 11:28 PM, Stefan Farfeleder <stefanf@freebsd.org> wr=
ote:
> On Tue, Aug 10, 2010 at 05:15:35AM +0000, Neel Natu wrote:
>> Author: neel
>> Date: Tue Aug 10 05:15:35 2010
>> New Revision: 211130
>> URL: http://svn.freebsd.org/changeset/base/211130
>>
>> Log:
>> =A0 Fix compilation error for 64-bit little endian build:
>> =A0 libexec/rtld-elf/mips/reloc.c:196: warning: right shift count >=3D w=
idth of type
>>
>> =A0 When the expression '(r_info) >> 32' was passed to bswap32() it was =
promptly
>> =A0 changed to '(uint32_t)(r_info) >> 32' which is not what we intended.
>
> Wouldn't it be better to fix the bswap32 macro instead?
>

I think you are right. Can you take a look at the following patch instead?

If I hear no objections, I will commit it tomorrow.

Index: libexec/rtld-elf/mips/reloc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- libexec/rtld-elf/mips/reloc.c	(revision 211131)
+++ libexec/rtld-elf/mips/reloc.c	(working copy)
@@ -83,7 +83,7 @@
 #undef ELF_R_SYM
 #undef ELF_R_TYPE
 #define ELF_R_SYM(r_info)		((r_info) & 0xffffffff)
-#define ELF_R_TYPE(r_info)		bswap32(((r_info) >> 32))
+#define ELF_R_TYPE(r_info)		bswap32((r_info) >> 32)
 #endif
 #else
 #define	ELF_R_NXTTYPE_64_P(r_type)	(0)
Index: sys/sys/endian.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/sys/endian.h	(revision 211131)
+++ sys/sys/endian.h	(working copy)
@@ -56,9 +56,9 @@
 /*
  * General byte order swapping functions.
  */
-#define	bswap16(x)	__bswap16(x)
-#define	bswap32(x)	__bswap32(x)
-#define	bswap64(x)	__bswap64(x)
+#define	bswap16(x)	__bswap16((x))
+#define	bswap32(x)	__bswap32((x))
+#define	bswap64(x)	__bswap64((x))

 /*
  * Host to big endian, host to little endian, big endian to host, and litt=
le

best
Neel

>> Modified:
>> =A0 head/libexec/rtld-elf/mips/reloc.c
>>
>> Modified: head/libexec/rtld-elf/mips/reloc.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>> --- head/libexec/rtld-elf/mips/reloc.c =A0 =A0 =A0 =A0Mon Aug =A09 23:32=
:37 2010 =A0 =A0 =A0 =A0(r211129)
>> +++ head/libexec/rtld-elf/mips/reloc.c =A0 =A0 =A0 =A0Tue Aug 10 05:15:3=
5 2010 =A0 =A0 =A0 =A0(r211130)
>> @@ -75,7 +75,7 @@ void _rtld_relocate_nonplt_self(Elf_Dyn
>> =A0 * ELF64 MIPS encodes the relocs uniquely. =A0The first 32-bits of in=
fo contain
>> =A0 * the symbol index. =A0The top 32-bits contain three relocation type=
s encoded
>> =A0 * in big-endian integer with first relocation in LSB. =A0This means =
for little
>> - * endian we have to byte swap that interger (r_type).
>> + * endian we have to byte swap that integer (r_type).
>> =A0 */
>> =A0#define =A0 =A0 =A0Elf_Sxword =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0Elf64_Sxword
>> =A0#define =A0 =A0 =A0ELF_R_NXTTYPE_64_P(r_type) =A0 =A0 =A0((((r_type) =
>> 8) & 0xff) =3D=3D R_TYPE(64))
>> @@ -83,7 +83,7 @@ void _rtld_relocate_nonplt_self(Elf_Dyn
>> =A0#undef ELF_R_SYM
>> =A0#undef ELF_R_TYPE
>> =A0#define ELF_R_SYM(r_info) =A0 =A0 =A0 =A0 =A0 =A0((r_info) & 0xffffff=
ff)
>> -#define ELF_R_TYPE(r_info) =A0 =A0 =A0 =A0 =A0 bswap32((r_info) >> 32)
>> +#define ELF_R_TYPE(r_info) =A0 =A0 =A0 =A0 =A0 bswap32(((r_info) >> 32)=
)
>> =A0#endif
>> =A0#else
>> =A0#define =A0 =A0 =A0ELF_R_NXTTYPE_64_P(r_type) =A0 =A0 =A0(0)
>>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimwoLfMXrNb7NmG%2BHWonug1-asmNdAE9AcSNHkK>