[binutils-gdb] elf: Use uint64_t for common symbol alignment warning
H.J. Lu
hjl@sourceware.org
Thu Oct 2 21:30:27 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4cb845ee59587c80bb641209ea109a4a0557f542
commit 4cb845ee59587c80bb641209ea109a4a0557f542
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Oct 2 09:57:35 2025 +0800
elf: Use uint64_t for common symbol alignment warning
Use uint64_t for common symbol alignment warning to avoid
elflink.c:5548:12: runtime error: shift exponent 37 is too large for 32-bit type 'int'
with invalid input in PR ld/33500. Now ld issues:
ld: warning: alignment 137438953472 of common symbol `__afl_global_area_ptr' in pr33500.o is greater than the alignment (8) of its section *COM*
instead of
ld: warning: alignment 32 of common symbol `__afl_global_area_ptr' in pr33500.o is greater than the alignment (8) of its section *COM*
PR ld/33511
* elflink.c (elf_link_add_object_symbols): Use uint64_t for
common symbol alignment warning.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diff:
---
bfd/elflink.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 5c8b822e36a..3f3ea2cce51 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5540,20 +5540,22 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
if (normal_align < common_align)
{
/* PR binutils/2735 */
+ uint64_t c_align = UINT64_C (1) << common_align;
+ uint64_t n_align = UINT64_C (1) << normal_align;
if (normal_bfd == NULL)
_bfd_error_handler
/* xgettext:c-format */
- (_("warning: alignment %u of common symbol `%s' in %pB is"
- " greater than the alignment (%u) of its section %pA"),
- 1 << common_align, name, common_bfd,
- 1 << normal_align, h->root.u.def.section);
+ (_("warning: alignment %" PRIu64 " of common symbol `%s' in %pB is"
+ " greater than the alignment (%" PRIu64 ") of its section %pA"),
+ c_align, name, common_bfd,
+ n_align, h->root.u.def.section);
else
_bfd_error_handler
/* xgettext:c-format */
- (_("warning: alignment %u of normal symbol `%s' in %pB"
- " is smaller than %u used by the common definition in %pB"),
- 1 << normal_align, name, normal_bfd,
- 1 << common_align, common_bfd);
+ (_("warning: alignment %" PRIu64 " of normal symbol `%s' in %pB"
+ " is smaller than %" PRIu64 " used by the common definition in %pB"),
+ n_align, name, normal_bfd,
+ c_align, common_bfd);
/* PR 30499: make sure that users understand that this warning is serious. */
_bfd_error_handler
More information about the Binutils-cvs
mailing list