[PATCH 3/4][MSP430] Remove .either placement code from place_orphan
Jozef Lawrynowicz
jozef.l@somniumtech.com
Wed Jul 19 17:30:00 GMT 2017
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.
-------------- next part --------------
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
More information about the Binutils
mailing list