This is the mail archive of the
mailing list for the binutils project.
Re: PPC64 GOT alignment trouble
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 16 Oct 2015 17:21:35 +0100
- Subject: Re: PPC64 GOT alignment trouble
- Authentication-results: sourceware.org; auth=none
- Newsgroups: gmane.comp.gnu.binutils
- References: <561F7683 dot 7070304 at codesourcery dot com> <561F8E92 dot 2060002 at codesourcery dot com> <20151015142143 dot GC13961 at bubble dot grove dot modra dot org>
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 <firstname.lastname@example.org>
* 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
@@ -12615,6 +12615,7 @@ ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
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)
+ (_("%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);