This is the mail archive of the mailing list for the elfutils 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]

[Bug general/24068] readelf.c:10152:15: error: ‘%*llx’ directive output between 4 and 2147483647 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-overflow=] with -m32

Martin Liška <marxin.liska at gmail dot com> changed:

           What    |Removed                     |Added
           See Also|                            |
                   |                            |a/show_bug.cgi?id=88835

--- Comment #2 from Martin Liška <marxin.liska at gmail dot com> ---
(In reply to Mark Wielaard from comment #1)
> This is weird. I cannot replicate with a standard build and gcc (GCC) 9.0.0
> 20190112 (experimental).
> Aha, with -m32. hmmm. Odd.
> So the issue seems to be that GCC doesn't realize digits is capped between 4
> and 16. We could help with with something like:


> diff --git a/src/readelf.c b/src/readelf.c
> index 3a73710ff..83b700eee 100644
> --- a/src/readelf.c
> +++ b/src/readelf.c
> @@ -10128,7 +10128,7 @@ print_debug_str_section (Dwfl_Module *dwflmod
> __attribute__ ((unused)),
>        ++digits;
>        tmp >>= 4;
>      }
> -  digits = MAX (4, digits);
> +  digits = MIN (16, MAX (4, digits));
>    printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"
>                    " %*s  String\n"),
> I that the correct fix though? Or is something else going on?

I can confirm it fixes that.

> I don't understand why this is -m32 specific.

Me neither, so that I created GCC PR for that.

You are receiving this mail because:
You are on the CC list for the bug.

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