From 611a1450e60cc3c3eb2d4b344ec6b5d4e1d0f17b Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Mon, 10 Jul 2017 16:42:17 +0000 Subject: [PATCH 3/4] MSP430: Remove .either placement code from place_orphan 2017-08-XX Jozef Lawrynowicz * ld/emultempl/msp430.em (gld${EMULATION_NAME}_place_orphan): Always place sections in the lower region. --- 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 814897b..f1d7205 100644 --- a/ld/emultempl/msp430.em +++ b/ld/emultempl/msp430.em @@ -229,7 +229,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; @@ -266,57 +265,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