public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] coff-go32: consistent 16-byte section alignment
@ 2021-11-24 13:17 J.W. Jagersma
  2021-11-25 12:52 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: J.W. Jagersma @ 2021-11-24 13:17 UTC (permalink / raw)
  To: binutils; +Cc: dj, J.W. Jagersma

Section alignment for coff-go32 is inconsistent - The '.text' and
'.data' sections are 16-byte aligned, but named sections '.text.*' and
'.data.*' are only 4-byte aligned.  '.gnu.linkonce.r.*' is aligned to
16 bytes, yet '.rodata' and '.rodata.*' are aligned to 4 bytes.  For
'.bss' all input sections are only aligned to 4 bytes.

This primarily can cause trouble when using SSE instructions, which
require their memory operands to be aligned to 16-byte boundaries.

This patch solves the issue simply by setting the section alignment
to 16 bytes, for all code and data sections referenced in the default
linker script.

bfd/
2021-11-24  Jan W. Jagersma <jwjagersma@gmail.com>
	* coff-go32.c (COFF_SECTION_ALIGNMENT_ENTRIES):  Use partial
	name match for .text, .data.  Add entries for .const, .rodata,
	.bss, .gnu.linkonce.b.
---
 bfd/coff-go32.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/bfd/coff-go32.c b/bfd/coff-go32.c
index d73c32b215d..3139ce07ac7 100644
--- a/bfd/coff-go32.c
+++ b/bfd/coff-go32.c
@@ -28,9 +28,15 @@
 #define COFF_LONG_FILENAMES
 
 #define COFF_SECTION_ALIGNMENT_ENTRIES \
-{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".data"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
-{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".text"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".const"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".rodata"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".bss"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.d"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
@@ -38,6 +44,8 @@
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.r"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.b"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] coff-go32: consistent 16-byte section alignment
  2021-11-24 13:17 [PATCH] coff-go32: consistent 16-byte section alignment J.W. Jagersma
@ 2021-11-25 12:52 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2021-11-25 12:52 UTC (permalink / raw)
  To: J.W. Jagersma; +Cc: binutils, dj

On Wed, Nov 24, 2021 at 02:17:21PM +0100, J.W. Jagersma via Binutils wrote:
> 	* coff-go32.c (COFF_SECTION_ALIGNMENT_ENTRIES):  Use partial
> 	name match for .text, .data.  Add entries for .const, .rodata,
> 	.bss, .gnu.linkonce.b.

Applied.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-25 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 13:17 [PATCH] coff-go32: consistent 16-byte section alignment J.W. Jagersma
2021-11-25 12:52 ` Alan Modra

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).