[PATCH 1/2] ldso: fix pointer width problem with debug statement

Bernd Petrovitsch bernd at petrovitsch.priv.at
Wed Nov 2 12:20:56 UTC 2011


Hi!

On Die, 2011-11-01 at 17:48 -0500, William Pitcock wrote:
> On 64-bit platforms, the compiler copies a 64-bit memory address into
> an unsigned int, which is 32 bits wide.  This should be unsigned long,
> because unsigned long will always be the width of a long pointer, which
> is 64-bit on 64-bit platforms instead of 32-bit.
> 
> Signed-off-by: William Pitcock <nenolod at dereferenced.org>
> ---
>  ldso/ldso/ldso.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
> index fe463b7..1308f22 100644
> --- a/ldso/ldso/ldso.c
> +++ b/ldso/ldso/ldso.c
> @@ -738,7 +738,7 @@ of this helper program; chances are you did not intend to run this program.\n\
>  	 * case the executable is actually an ET_DYN object.
>  	 */
>  	if (app_tpnt->l_tls_initimage != NULL) {
> -		unsigned int tmp = (unsigned int) app_tpnt->l_tls_initimage;
> +		unsigned long tmp = (unsigned long) app_tpnt->l_tls_initimage;
>  		app_tpnt->l_tls_initimage =
>  			(char *) app_tpnt->l_tls_initimage + app_tpnt->loadaddr;
>  		_dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n",

Hmm, why not just
---- snip  ----
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -738,7 +738,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	 * case the executable is actually an ET_DYN object.
 	 */
 	if (app_tpnt->l_tls_initimage != NULL) {
-		unsigned int tmp = (unsigned int) app_tpnt->l_tls_initimage;
+		void * tmp = app_tpnt->l_tls_initimage;
 		app_tpnt->l_tls_initimage =
 			(char *) app_tpnt->l_tls_initimage + app_tpnt->loadaddr;
 		_dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n",
---- snip  ----
as that's actually the type of l_tls_initimage?

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at



More information about the uClibc mailing list