* [PATCH, rs6000, 5/6] Backport patch to align .toc section
@ 2017-07-23 17:07 Bill Schmidt
2017-07-25 14:54 ` Segher Boessenkool
0 siblings, 1 reply; 2+ messages in thread
From: Bill Schmidt @ 2017-07-23 17:07 UTC (permalink / raw)
To: GCC Patches; +Cc: Segher Boessenkool, amodra
Hi,
Alan added code to have GCC align the .toc section in GCC 7, aligning to
four bytes for 32-bit mode, and 8 bytes for 64-bit mode. This is normally
unnecessary since alignment of the .toc has historically been handled by
the standard linker script. However, people using non-standard toolchains
can still run into problems, so as a courtesy this is now done by the
compiler as well.
We've recently seen this encountered using an out-of-service compiler, and
would like to prevent any more occurrences by people finding interesting
ways to avoid the standard toolchain. Thus I'd like to backport Alan's
patch to GCC 5 and 6. Alan, please review as well to be sure I didn't
miss any release-specific differences.
Bootstrapped and tested on powerpc64le-linux-gnu with no regressions.
Are these backports ok?
Thanks,
Bill
2017-07-23 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline r235874
2016-05-04 Alan Modra <amodra@gmail.com>
* config/rs6000/rs6000.c (rs6000_elf_output_toc_section_asm_op):
Align .toc.
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 250426)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -32699,8 +32699,8 @@ rs6000_elf_output_toc_section_asm_op (const void *
{
if (!toc_initialized)
{
- toc_initialized = 1;
fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);
+ ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2);
(*targetm.asm_out.internal_label) (asm_out_file, "LCTOC", 0);
fprintf (asm_out_file, "\t.tc ");
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],");
@@ -32708,8 +32708,10 @@ rs6000_elf_output_toc_section_asm_op (const void *
fprintf (asm_out_file, "\n");
fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);
+ ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2);
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1");
fprintf (asm_out_file, " = .+32768\n");
+ toc_initialized = 1;
}
else
fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);
@@ -32716,12 +32718,20 @@ rs6000_elf_output_toc_section_asm_op (const void *
}
else if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
&& !TARGET_RELOCATABLE)
- fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);
+ {
+ fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);
+ if (!toc_initialized)
+ {
+ ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2);
+ toc_initialized = 1;
+ }
+ }
else
{
fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);
if (!toc_initialized)
{
+ ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2);
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1");
fprintf (asm_out_file, " = .+32768\n");
toc_initialized = 1;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, rs6000, 5/6] Backport patch to align .toc section
2017-07-23 17:07 [PATCH, rs6000, 5/6] Backport patch to align .toc section Bill Schmidt
@ 2017-07-25 14:54 ` Segher Boessenkool
0 siblings, 0 replies; 2+ messages in thread
From: Segher Boessenkool @ 2017-07-25 14:54 UTC (permalink / raw)
To: Bill Schmidt; +Cc: GCC Patches, amodra
Hi Bill,
On Sun, Jul 23, 2017 at 12:07:37PM -0500, Bill Schmidt wrote:
> Alan added code to have GCC align the .toc section in GCC 7, aligning to
> four bytes for 32-bit mode, and 8 bytes for 64-bit mode. This is normally
> unnecessary since alignment of the .toc has historically been handled by
> the standard linker script. However, people using non-standard toolchains
> can still run into problems, so as a courtesy this is now done by the
> compiler as well.
>
> We've recently seen this encountered using an out-of-service compiler, and
> would like to prevent any more occurrences by people finding interesting
> ways to avoid the standard toolchain. Thus I'd like to backport Alan's
> patch to GCC 5 and 6. Alan, please review as well to be sure I didn't
> miss any release-specific differences.
>
> Bootstrapped and tested on powerpc64le-linux-gnu with no regressions.
> Are these backports ok?
Sure, if Alan is happy with it, please commit.
Segher
> 2017-07-23 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
>
> Backport from mainline r235874
> 2016-05-04 Alan Modra <amodra@gmail.com>
>
> * config/rs6000/rs6000.c (rs6000_elf_output_toc_section_asm_op):
> Align .toc.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-25 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-23 17:07 [PATCH, rs6000, 5/6] Backport patch to align .toc section Bill Schmidt
2017-07-25 14:54 ` Segher Boessenkool
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).