This is the mail archive of the mailing list for the binutils 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: PPC64 GOT alignment trouble

On 15/10/15 15:21, Alan Modra wrote:
Not as it is.  I'm a little worried that the warning will trigger when
it shouldn't, and the patch looks to be a bit of a rush job (testing
adjust != 0 is better and it would also be better to use
TOC_BASE_ALIGN in the warning message rather than hard coding 256).
BTW, I'm on vacation tomorrow (huh, today, it's well past midnight),
so probably will be "ignoring" you until Monday.

This version should address the issues with the text.

It's true that the warning can trigger in cases where there is not actually a serious problem (i.e. the r2 register gets set up correctly, even though the section is not aligned).

Given that this problem is likely to bite every PPC64 Linux user if they happen to upgrade binutils before the kernel, and who-knows-how-many other hidden projects, I'm inclined to lean toward adding the warning.

Even in the "harmless warning" cases, it would benefit the user to apply the alignment, both to prevent wasteful padding in the binary, and to preserve the maximum addressable GOT capacity (albeit those are minor wins).

I don't see that we can actually get a "false positive" here; the message will be accurate, even when not helpful.

Add misalignment warning.

2015-10-16  Andrew Stubbs  <>

	* elf64-ppc.c (ppc64_elf_set_toc): Warn about misaligned sections.

diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index e5344df..1bcde43 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -12615,6 +12615,7 @@ ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
   asection *s;
   bfd_vma TOCstart, adjust;
+  static bfd_boolean warned = FALSE;
   if (info != NULL)
@@ -12695,6 +12696,14 @@ ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
   TOCstart -= adjust;
   _bfd_set_gp_value (obfd, TOCstart);
+  if (!warned && adjust != 0)
+    {
+      info->callbacks->einfo
+	(_("%B: warning: section `%A' not %d-byte aligned in linker script\n"),
+	 obfd, s, TOC_BASE_ALIGN);
+      warned = TRUE;
+    }
   if (info != NULL && s != NULL)
       struct ppc_link_hash_table *htab = ppc_hash_table (info);

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