From: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
To: Nilay Vaish <nilayvaish@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86 <x86@kernel.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86, relocs: add function attributes to die()
Date: Sat, 3 Sep 2016 17:51:54 +0200 [thread overview]
Message-ID: <173b263e-76ff-c8c9-aff8-ee6097164f4c@m4x.org> (raw)
In-Reply-To: <CACbG309_Wa3QcYxCF6WEomEcDefaOjJdNiLqWdAYJgCup7kvvA@mail.gmail.com>
On 03/09/16 17:16, Nilay Vaish wrote:
> On 3 September 2016 at 09:50, Nicolas Iooss <nicolas.iooss_linux@m4x.org> wrote:
>>
>> arch/x86/tools/relocs.c:460:5: error: format specifies type 'int'
>> but the argument has type 'Elf64_Xword' (aka 'unsigned long')
>> [-Werror,-Wformat]
>> sec->shdr.sh_size);
>> ^~~~~~~~~~~~~~~~~
>> arch/x86/tools/relocs.c:464:5: error: format specifies type 'int'
>> but the argument has type 'Elf64_Off' (aka 'unsigned long')
>> [-Werror,-Wformat]
>> sec->shdr.sh_offset, strerror(errno));
>> ^~~~~~~~~~~~~~~~~~~
>>
>> To support both 32-bit and 64-bit modes, add casts to long types and use
>> %lu and %ld to format the numbers.
>>
>
> Nicolas, should not just changing the format specifiers fix the
> problem? How do those type casts help?
The problem is that I did not found a simple format which would make
both arch/x86/tools/relocs_32.o and arch/x86/tools/relocs_64.o build
without any warning. Here are the types:
* When compiling relocs_32.c, sec->shdr.sh_size is of type Elf32_Word
(unsigned int) and sec->shdr.sh_offset is Elf32_Off (unsigned int).
* When compiling relocs_64.c, sec->shdr.sh_size is Elf64_Xword (long
long unsigned int when the compiler is in 32-bit mode, long unsigned int
in 64-bit mode) and sec->shdr.sh_offset is Elf64_Off (same real type as
sec->shdr.sh_size).
I though that casting everything to long integers was fine but now I
have realized this does not take into account compiling relocs_64.c on a
32-bit host system (where HOSTCC compiles in 32-bit mode and long
integers are 32-bit wide).
A possible solution would be using format definitions from <inittypes.h>
like PRIu32, PRIu64... in relocs.c depending on the file being compiled
(relocs_32.c or relocs_64.c). What would you think of such a solution?
-- Nicolas
next prev parent reply other threads:[~2016-09-03 15:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-03 14:50 Nicolas Iooss
2016-09-03 15:16 ` Nilay Vaish
2016-09-03 15:51 ` Nicolas Iooss [this message]
2016-09-04 16:51 ` [PATCH v2 " Nicolas Iooss
2016-09-05 15:28 ` Nilay Vaish
2016-10-23 16:47 ` Nicolas Iooss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=173b263e-76ff-c8c9-aff8-ee6097164f4c@m4x.org \
--to=nicolas.iooss_linux@m4x.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nilayvaish@gmail.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®