public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
To: binutils@sourceware.org
Cc: Nick Clifton <nickc@redhat.com>
Subject: [PATCH 3/4][MSP430] Remove .either placement code from place_orphan
Date: Wed, 19 Jul 2017 17:30:00 -0000	[thread overview]
Message-ID: <133f4541-aa5d-f465-2c00-a4ca662dbbd6@somniumtech.com> (raw)
In-Reply-To: <964e03c8-47c5-e312-60a9-2f3ee18933e6@somniumtech.com>

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

This patch removes the existing ".either" placement functionality from
place_orphan. With the addition of the new placement functionality in
Patch 2, this existing code is no longer necessary. place_orphan now
places all orphaned .either sections in the lower memory region.

The tests added in patch 2 pass when built with todays GCC trunk and
binutils master.

[-- Attachment #2: 0003-MSP430-Remove-.either-splitting-code-from-place_orph.patch --]
[-- Type: text/plain, Size: 3093 bytes --]

From 5eb4de4ca70d8488741f43561cb8724db5aceba5 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Mon, 10 Jul 2017 16:42:17 +0000
Subject: [PATCH 3/4] MSP430: Remove .either placement code from place_orphan

---
 ld/emultempl/msp430.em | 56 ++++++++++++++------------------------------------
 1 file changed, 15 insertions(+), 41 deletions(-)

diff --git a/ld/emultempl/msp430.em b/ld/emultempl/msp430.em
index 15c60a7..0b3b12a 100644
--- a/ld/emultempl/msp430.em
+++ b/ld/emultempl/msp430.em
@@ -220,7 +220,6 @@ gld${EMULATION_NAME}_place_orphan (asection * s,
   char * buf = NULL;
   lang_output_section_statement_type * lower;
   lang_output_section_statement_type * upper;
-  lang_output_section_statement_type * os;
 
   if ((s->flags & SEC_ALLOC) == 0)
     return NULL;
@@ -257,57 +256,32 @@ gld${EMULATION_NAME}_place_orphan (asection * s,
   /* Find the corresponding lower and upper sections.  */
   lower = lang_output_section_find (lower_name);
   upper = lang_output_section_find (upper_name);
-  /* If the upper section does not exist, try again without the suffix.  */
-  if (upper == NULL)
-    upper = lang_output_section_find (name);
 
-  if (lower == NULL)
+  if (lower == NULL && upper == NULL)
     {
-      os = upper;
-      if (upper == NULL)
-        {
-          einfo ("%P: error: no section named %s or %s in linker script\n", lower_name, upper_name);
-	  goto end;
-	}
+      einfo ("%P: error: no section named %s or %s in linker script\n",
+	     lower_name, upper_name);
+      goto end;
     }
-  else if (upper == NULL)
-    os = lower;
-  else if (lower->region == NULL)
-    os = lower;
-  /* If the section is too big for the region containing
-     the lower section then do not even try to use it.  */
-  else if (lower->region->length < s->size)
-    os = upper;
-  else
+  else if (lower == NULL)
     {
-      bfd_size_type amount = 0;
-      struct lang_output_section_statement_struct * p;
-
-      amount += scan_children (lower->children.head);
-
-      /* Also check forwards for other statements assigned to the same region.  */
-      for (p = lower->next; p != NULL; p = p->next)
-	if (p->region == lower->region)
-	  amount += scan_children (p->children.head);
-
-      /* Scan backwards as well.  */      
-      for (p = lower->prev; p != NULL; p = p->prev)
-	if (p->region == lower->region)
-	  amount += scan_children (p->children.head);
-
-      if (amount + s->size >= lower->region->length)
-	os = upper;
-      else
-	os = lower;
+      lower = lang_output_section_find (name);
+      if (lower == NULL)
+	{
+	  einfo ("%P: error: no section named %s in linker script\n", name);
+	  goto end;
+	}
     }
 
-  lang_add_section (& os->children, s, NULL, os);
+  /* Always place orphaned sections in lower. Optimal placement of either
+   * sections is performed later, once section sizes have been finalized.  */
+  lang_add_section (& lower->children, s, NULL, lower);
  end:
   free (upper_name);
   free (lower_name);
   if (buf)
     free (buf);
-  return os;
+  return lower;
 }
 EOF
 fi
-- 
1.8.3.1


  reply	other threads:[~2017-07-19 17:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 17:08 [PATCH 0/4][MSP430] Improve behaviour of ".either" section placement Jozef Lawrynowicz
2017-07-19 17:16 ` [PATCH 1/4][MSP430] Add feature to add lower/either/upper prefixes to section names Jozef Lawrynowicz
2017-07-19 17:22   ` [PATCH 2/4][MSP430] Change .either section placement to be performed after allocation Jozef Lawrynowicz
2017-07-19 17:30     ` Jozef Lawrynowicz [this message]
2017-07-19 17:35       ` [PATCH 4/4][MSP430] Define symbols to initialise high data and high bss when the upper data region could be used Jozef Lawrynowicz
2017-07-20 12:36 ` [PATCH 0/4][MSP430] Improve behaviour of ".either" section placement Nick Clifton
2017-08-24 17:17 ` Jozef Lawrynowicz
2017-08-29 16:21   ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=133f4541-aa5d-f465-2c00-a4ca662dbbd6@somniumtech.com \
    --to=jozef.l@somniumtech.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).