[committed] hppa: Provide 8-byte minimum alignment for .plt section

Message ID f00bed2c-6348-31e9-af85-d480737cdfa0@bell.net
State New
Headers show
Series
  • [committed] hppa: Provide 8-byte minimum alignment for .plt section
Related show

Commit Message

John David Anglin Oct. 20, 2019, 4:09 p.m.
This change increases the default alignment for the .plt section from 4 bytes to 8 bytes.
When function descriptors are 8-byte aligned, they can be updated atomically on 32-bit hppa.
This helps with ordering issues on SMP machines.  It also ensures that descriptors reside
on the same cache line.  This reduces the probability of a double TLB miss in a call.

Dave
--

2019-10-19  John David Anglin  <danglin@gcc.gnu.org>

	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Provide 8-byte
	minimum alignment for .plt section.

Patch

diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 8a19c19370..35564dd2b0 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -2280,10 +2280,11 @@  elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 		 against the .got section.  */
 	      int gotalign = bfd_section_alignment (htab->etab.sgot);
 	      int pltalign = bfd_section_alignment (sec);
+	      int align = gotalign > 3 ? gotalign : 3;
 	      bfd_size_type mask;

-	      if (gotalign > pltalign)
-		bfd_set_section_alignment (sec, gotalign);
+	      if (align > pltalign)
+		bfd_set_section_alignment (sec, align);
 	      mask = ((bfd_size_type) 1 << gotalign) - 1;
 	      sec->size = (sec->size + sizeof (plt_stub) + mask) & ~mask;
 	    }