This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Add x32 support to dynamic linker audit


On Wed, Mar 21, 2012 at 5:50 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Mar 21, 2012 at 2:39 PM, Carlos O'Donell
> <carlos@systemhalted.org> wrote:
>> On Wed, Mar 21, 2012 at 5:35 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> %lx is wrong for uint64_t, which may be long long, not
>>> long.
>>
>> Yes, that was a typo I should have printed %llx.
>
> But %llx is wrong for unsigned long:
>
> [hjl@gnu-6 tmp]$ cat b.c
> #include <stdio.h>
> #include <stdint.h>
>
> void
> b2 (uint64_t x)
> {
> ?printf ("%llx\n", x);
> }
> [hjl@gnu-6 tmp]$ gcc -Wall -c b.c
> b.c: In function ‘b2’:
> b.c:7:3: warning: format ‘%llx’ expects argument of type ‘long long
> unsigned int’, but argument 2 has type ‘uint64_t’ [-Wformat]
> [hjl@gnu-6 tmp]$
>
> We need to cast to long long for %llx.

Right, this is the difference between x86-32 and x86-64.

This being generic code we want it to work for all targets being tested.

>> So was %tu and ptrdiff_t chosen because they conveniently match the
>> type to be printed no matter the architecture?
>>
>> Even though the meaning of ptrdiff_t isn't really what we intend here?
>>
>
> I don't have the answers.

OK, I just verified that ptrdiff_t works well in this case exactly
because of the properties that it is given by the standard.

Please checkin your patch with the ptrdiff_t casts and the change to
the x32 naming for the library audit arguments.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]