From: Nick Clifton Date: Mon, 2 Mar 2009 17:27:36 +0000 (+0000) Subject: * ldgram.y: Add support for REGION_ALIAS operator. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a93e18003bc8a90c03a26a27c368fbc5a4e0e84;p=binutils-gdb.git * ldgram.y: Add support for REGION_ALIAS operator. * ldlang.c: Likewise. * ldlang.h: Likewise. * ldlex.l: Likewise. * NEWS: Mention the new feature. * ld.texinfo: Document the new feature. * ld-scripts/regions-alias-1.t: New file. * ld-scripts/regions-alias-2.t: New file. * ld-scripts/regions-alias-3.t: New file. * ld-scripts/regions-alias-4.t: New file. * ld-scripts/script.exp: Run region alias tests. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index de067e4ed16..1d0fea9015c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2009-03-02 Sebastian Huber + + * ldgram.y: Add support for REGION_ALIAS operator. + * ldlang.c: Likewise. + * ldlang.h: Likewise. + * ldlex.l: Likewise. + * NEWS: Mention the new feature. + * ld.texinfo: Document the new feature. + 2009-03-02 Qinwei * Makefile.am: Replace score elf emulation with score3 and score7 diff --git a/ld/NEWS b/ld/NEWS index 1789c8b49d5..e4951572d80 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,5 +1,7 @@ -*- text -*- +* New script function REGION_ALIAS to add alias names to memory regions. + * PE targets no longer make use of the long section names PE extension to the COFF format when generating executable images, by default. The old (slightly non-conformant) behaviour can still be invoked by using the diff --git a/ld/ld.texinfo b/ld/ld.texinfo index fc5f1daaf93..167df2838f9 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -2785,6 +2785,7 @@ In this section we describe the simple linker script commands. * Format Commands:: Commands dealing with object file formats @end ifclear +* REGION_ALIAS:: Assign alias names to memory regions * Miscellaneous Commands:: Other linker script commands @end menu @@ -2969,6 +2970,162 @@ command is also used to set the format for the output file. @xref{BFD}. @end table @end ifclear +@node REGION_ALIAS +@subsection Assign alias names to memory regions +@kindex REGION_ALIAS(@var{alias}, @var{region}) +@cindex region alias +@cindex region names + +Alias names can be added to existing memory regions created with the +@ref{MEMORY} command. Each name corresponds to at most one memory region. + +@smallexample +REGION_ALIAS(@var{alias}, @var{region}) +@end smallexample + +The @code{REGION_ALIAS} function creates an alias name @var{alias} for the +memory region @var{region}. This allows a flexible mapping of output sections +to memory regions. An example follows. + +Suppose we have an application for embedded systems which come with various +memory storage devices. All have a general purpose, volatile memory @code{RAM} +that allows code execution or data storage. Some may have a read-only, +non-volatile memory @code{ROM} that allows code execution and read-only data +access. The last variant is a read-only, non-volatile memory @code{ROM2} with +read-only data access and no code execution capability. We have four output +sections: + +@itemize @bullet +@item +@code{.text} program code; +@item +@code{.rodata} read-only data; +@item +@code{.data} read-write initialized data; +@item +@code{.bss} read-write zero initialized data. +@end itemize + +The goal is to provide a linker command file that contains a system independent +part defining the output sections and a system dependent part mapping the +output sections to the memory regions available on the system. Our embedded +systems come with three different memory setups @code{A}, @code{B} and +@code{C}: +@multitable @columnfractions .25 .25 .25 .25 +@item Section @tab Variant A @tab Variant B @tab Variant C +@item .text @tab RAM @tab ROM @tab ROM +@item .rodata @tab RAM @tab ROM @tab ROM2 +@item .data @tab RAM @tab RAM/ROM @tab RAM/ROM2 +@item .bss @tab RAM @tab RAM @tab RAM +@end multitable +The notation @code{RAM/ROM} or @code{RAM/ROM2} means that this section is +loaded into region @code{ROM} or @code{ROM2} respectively. Please note that +the load address of the @code{.data} section starts in all three variants at +the end of the @code{.rodata} section. + +The base linker script that deals with the output sections follows. It +includes the system dependent @code{linkcmds.memory} file that describes the +memory layout: +@smallexample +INCLUDE linkcmds.memory + +SECTIONS + @{ + .text : + @{ + *(.text) + @} > REGION_TEXT + .rodata : + @{ + *(.rodata) + rodata_end = .; + @} > REGION_RODATA + .data : AT (rodata_end) + @{ + data_start = .; + *(.data) + @} > REGION_DATA + data_size = SIZEOF(.data); + data_load_start = LOADADDR(.data); + .bss : + @{ + *(.bss) + @} > REGION_BSS + @} +@end smallexample + +Now we need three different @code{linkcmds.memory} files to define memory +regions and alias names. The content of @code{linkcmds.memory} for the three +variants @code{A}, @code{B} and @code{C}: +@table @code +@item A +Here everything goes into the @code{RAM}. +@smallexample +MEMORY + @{ + RAM : ORIGIN = 0, LENGTH = 4M + @} + +REGION_ALIAS("REGION_TEXT", RAM); +REGION_ALIAS("REGION_RODATA", RAM); +REGION_ALIAS("REGION_DATA", RAM); +REGION_ALIAS("REGION_BSS", RAM); +@end smallexample +@item B +Program code and read-only data go into the @code{ROM}. Read-write data goes +into the @code{RAM}. An image of the initialized data is loaded into the +@code{ROM} and will be copied during system start into the @code{RAM}. +@smallexample +MEMORY + @{ + ROM : ORIGIN = 0, LENGTH = 3M + RAM : ORIGIN = 0x10000000, LENGTH = 1M + @} + +REGION_ALIAS("REGION_TEXT", ROM); +REGION_ALIAS("REGION_RODATA", ROM); +REGION_ALIAS("REGION_DATA", RAM); +REGION_ALIAS("REGION_BSS", RAM); +@end smallexample +@item C +Program code goes into the @code{ROM}. Read-only data goes into the +@code{ROM2}. Read-write data goes into the @code{RAM}. An image of the +initialized data is loaded into the @code{ROM2} and will be copied during +system start into the @code{RAM}. +@smallexample +MEMORY + @{ + ROM : ORIGIN = 0, LENGTH = 2M + ROM2 : ORIGIN = 0x10000000, LENGTH = 1M + RAM : ORIGIN = 0x20000000, LENGTH = 1M + @} + +REGION_ALIAS("REGION_TEXT", ROM); +REGION_ALIAS("REGION_RODATA", ROM2); +REGION_ALIAS("REGION_DATA", RAM); +REGION_ALIAS("REGION_BSS", RAM); +@end smallexample +@end table + +It is possible to write a common system initialization routine to copy the +@code{.data} section from @code{ROM} or @code{ROM2} into the @code{RAM} if +necessary: +@smallexample +#include + +extern char data_start []; +extern char data_size []; +extern char data_load_start []; + +void copy_data(void) +@{ + if (data_start != data_load_start) + @{ + memcpy(data_start, data_load_start, (size_t) data_size); + @} +@} +@end smallexample + @node Miscellaneous Commands @subsection Other Linker Script Commands There are a few other linker scripts commands. @@ -4310,7 +4467,9 @@ The @var{name} is a name used in the linker script to refer to the region. The region name has no meaning outside of the linker script. Region names are stored in a separate name space, and will not conflict with symbol names, file names, or section names. Each memory region -must have a distinct name. +must have a distinct name within the @code{MEMORY} command. However you can +add later alias names to existing memory regions with the @ref{REGION_ALIAS} +command. @cindex memory region attributes The @var{attr} string is an optional list of attributes that specify diff --git a/ld/ldgram.y b/ld/ldgram.y index 1149e6b29c4..4d06725e467 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -1,6 +1,6 @@ /* A YACC grammar to parse a superset of the AT&T linker scripting language. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com). This file is part of the GNU Binutils. @@ -131,6 +131,7 @@ static int error_index; %token SEGMENT_START %token INCLUDE %token MEMORY +%token REGION_ALIAS %token NOLOAD DSECT COPY INFO OVERLAY %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY %token NEXT @@ -352,6 +353,8 @@ ifile_p1: { lang_add_insert ($3, 0); } | INSERT_K BEFORE NAME { lang_add_insert ($3, 1); } + | REGION_ALIAS '(' NAME ',' NAME ')' + { lang_memory_region_alias ($3, $5); } ; input_list: diff --git a/ld/ldlang.c b/ld/ldlang.c index cc390b0b411..9f62e9f02cc 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1205,7 +1205,13 @@ lang_finish (void) In this case it is probably an error to create a region that has already been created. If we are not inside a MEMORY block it is dubious to use an undeclared region name (except DEFAULT_MEMORY_REGION) - and so we issue a warning. */ + and so we issue a warning. + + Each region has at least one name. The first name is either + DEFAULT_MEMORY_REGION or the name given in the MEMORY block. You can add + alias names to an existing region within a script with + REGION_ALIAS (alias, region_name). Each name corresponds to at most one + region. */ static lang_memory_region_type *lang_memory_region_list; static lang_memory_region_type **lang_memory_region_list_tail @@ -1214,28 +1220,31 @@ static lang_memory_region_type **lang_memory_region_list_tail lang_memory_region_type * lang_memory_region_lookup (const char *const name, bfd_boolean create) { - lang_memory_region_type *p; + lang_memory_region_name *n; + lang_memory_region_type *r; lang_memory_region_type *new; /* NAME is NULL for LMA memspecs if no region was specified. */ if (name == NULL) return NULL; - for (p = lang_memory_region_list; p != NULL; p = p->next) - if (strcmp (p->name, name) == 0) - { - if (create) - einfo (_("%P:%S: warning: redeclaration of memory region '%s'\n"), - name); - return p; - } + for (r = lang_memory_region_list; r != NULL; r = r->next) + for (n = &r->name_list; n != NULL; n = n->next) + if (strcmp (n->name, name) == 0) + { + if (create) + einfo (_("%P:%S: warning: redeclaration of memory region `%s'\n"), + name); + return r; + } if (!create && strcmp (name, DEFAULT_MEMORY_REGION)) - einfo (_("%P:%S: warning: memory region %s not declared\n"), name); + einfo (_("%P:%S: warning: memory region `%s' not declared\n"), name); new = stat_alloc (sizeof (lang_memory_region_type)); - new->name = xstrdup (name); + new->name_list.name = xstrdup (name); + new->name_list.next = NULL; new->next = NULL; new->origin = 0; new->length = ~(bfd_size_type) 0; @@ -1251,8 +1260,50 @@ lang_memory_region_lookup (const char *const name, bfd_boolean create) return new; } +void +lang_memory_region_alias (const char * alias, const char * region_name) +{ + lang_memory_region_name * n; + lang_memory_region_type * r; + lang_memory_region_type * region; + + /* The default region must be unique. This ensures that it is not necessary + to iterate through the name list if someone wants the check if a region is + the default memory region. */ + if (strcmp (region_name, DEFAULT_MEMORY_REGION) == 0 + || strcmp (alias, DEFAULT_MEMORY_REGION) == 0) + einfo (_("%F%P:%S: error: alias for default memory region\n")); + + /* Look for the target region and check if the alias is not already + in use. */ + region = NULL; + for (r = lang_memory_region_list; r != NULL; r = r->next) + for (n = &r->name_list; n != NULL; n = n->next) + { + if (region == NULL && strcmp (n->name, region_name) == 0) + region = r; + if (strcmp (n->name, alias) == 0) + einfo (_("%F%P:%S: error: redefinition of memory region " + "alias `%s'\n"), + alias); + } + + /* Check if the target region exists. */ + if (region == NULL) + einfo (_("%F%P:%S: error: memory region `%s' " + "for alias `%s' does not exist\n"), + region_name, + alias); + + /* Add alias to region name list. */ + n = stat_alloc (sizeof (lang_memory_region_name)); + n->name = xstrdup (alias); + n->next = region->name_list.next; + region->name_list.next = n; +} + static lang_memory_region_type * -lang_memory_default (asection *section) +lang_memory_default (asection * section) { lang_memory_region_type *p; @@ -1847,7 +1898,7 @@ lang_map (void) char buf[100]; int len; - fprintf (config.map_file, "%-16s ", m->name); + fprintf (config.map_file, "%-16s ", m->name_list.name); sprintf_vma (buf, m->origin); minfo ("0x%s ", buf); @@ -4462,8 +4513,8 @@ lang_check_section_addresses (void) a bfd_vma quantity in decimal. */ for (m = lang_memory_region_list; m; m = m->next) if (m->had_full_message) - einfo (_("%X%P: region %s overflowed by %ld bytes\n"), - m->name, (long)(m->current - (m->origin + m->length))); + einfo (_("%X%P: region `%s' overflowed by %ld bytes\n"), + m->name_list.name, (long)(m->current - (m->origin + m->length))); } @@ -4485,21 +4536,21 @@ os_region_check (lang_output_section_statement_type *os, { if (tree != NULL) { - einfo (_("%X%P: address 0x%v of %B section %s" - " is not within region %s\n"), + einfo (_("%X%P: address 0x%v of %B section `%s'" + " is not within region `%s'\n"), region->current, os->bfd_section->owner, os->bfd_section->name, - region->name); + region->name_list.name); } else if (!region->had_full_message) { region->had_full_message = TRUE; - einfo (_("%X%P: %B section %s will not fit in region %s\n"), + einfo (_("%X%P: %B section `%s' will not fit in region `%s'\n"), os->bfd_section->owner, os->bfd_section->name, - region->name); + region->name_list.name); } } } @@ -4588,8 +4639,8 @@ lang_size_sections_1 from the region specification. */ if (os->region == NULL || ((os->bfd_section->flags & (SEC_ALLOC | SEC_LOAD)) - && os->region->name[0] == '*' - && strcmp (os->region->name, + && os->region->name_list.name[0] == '*' + && strcmp (os->region->name_list.name, DEFAULT_MEMORY_REGION) == 0)) { os->region = lang_memory_default (os->bfd_section); @@ -4602,10 +4653,10 @@ lang_size_sections_1 && !IGNORE_SECTION (os->bfd_section) && ! link_info.relocatable && check_regions - && strcmp (os->region->name, + && strcmp (os->region->name_list.name, DEFAULT_MEMORY_REGION) == 0 && lang_memory_region_list != NULL - && (strcmp (lang_memory_region_list->name, + && (strcmp (lang_memory_region_list->name_list.name, DEFAULT_MEMORY_REGION) != 0 || lang_memory_region_list->next != NULL) && expld.phase != lang_mark_phase_enum) diff --git a/ld/ldlang.h b/ld/ldlang.h index daf125583e6..0b57b857ba3 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -43,13 +43,19 @@ struct _fill_type typedef struct statement_list { - union lang_statement_union *head; - union lang_statement_union **tail; + union lang_statement_union * head; + union lang_statement_union ** tail; } lang_statement_list_type; +typedef struct memory_region_name_struct +{ + const char * name; + struct memory_region_name_struct * next; +} lang_memory_region_name; + typedef struct memory_region_struct { - char *name; + lang_memory_region_name name_list; struct memory_region_struct *next; bfd_vma origin; bfd_size_type length; @@ -429,7 +435,8 @@ struct lang_definedness_hash_entry /* Used by place_orphan to keep track of orphan sections and statements. */ -struct orphan_save { +struct orphan_save +{ const char *name; flagword flags; lang_output_section_statement_type *os; @@ -457,10 +464,10 @@ extern void lang_init (void); extern void lang_finish (void); -extern lang_memory_region_type *lang_memory_region_lookup - (const char *const, bfd_boolean); -extern lang_memory_region_type *lang_memory_region_default - (asection *); +extern lang_memory_region_type * lang_memory_region_lookup + (const char * const, bfd_boolean); +extern void lang_memory_region_alias + (const char *, const char *); extern void lang_map (void); extern void lang_set_flags diff --git a/ld/ldlex.l b/ld/ldlex.l index aa06d5460d9..48309027dbd 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -1,7 +1,7 @@ %{ /* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2007 + 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. @@ -239,6 +239,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* ":" { RTOKEN(':'); } ";" { RTOKEN(';');} "MEMORY" { RTOKEN(MEMORY);} +"REGION_ALIAS" { RTOKEN(REGION_ALIAS);} "ORIGIN" { RTOKEN(ORIGIN);} "VERSION" { RTOKEN(VERSIONK);} "BLOCK" { RTOKEN(BLOCK);} diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 88fb12bed7e..c338bb48d46 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-03-02 Sebastian Huber + + * ld-scripts/regions-alias-1.t: New file. + * ld-scripts/regions-alias-2.t: New file. + * ld-scripts/regions-alias-3.t: New file. + * ld-scripts/regions-alias-4.t: New file. + * ld-scripts/script.exp: Run region alias tests. + 2009-02-27 Dave Korn * ld-pe/pe.exp: Disable auto-import when linking on Cygwin. diff --git a/ld/testsuite/ld-elf/group8a.d b/ld/testsuite/ld-elf/group8a.d index b55715148ec..455e02ff87a 100644 --- a/ld/testsuite/ld-elf/group8a.d +++ b/ld/testsuite/ld-elf/group8a.d @@ -2,6 +2,7 @@ #ld: -r --gc-sections --entry foo #readelf: -g --wide #notarget: ia64-*-* mep-*-* +#xfail: dlx-*-* openrisc-*-* or32-*-* alpha-*-* arc-*-* hppa64-*-* COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 1 sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/group8b.d b/ld/testsuite/ld-elf/group8b.d index 0a78173a21b..6e88454c088 100644 --- a/ld/testsuite/ld-elf/group8b.d +++ b/ld/testsuite/ld-elf/group8b.d @@ -2,6 +2,7 @@ #ld: -r --gc-sections --entry bar #readelf: -g --wide #notarget: ia64-*-* mep-*-* +#xfail: dlx-*-* openrisc-*-* or32-*-* alpha-*-* arc-*-* hppa64-*-* COMDAT group section \[[ 0-9]+\] `.group' \[bar\] contains 1 sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/group9a.d b/ld/testsuite/ld-elf/group9a.d index a20e24f70a9..1410ea5daef 100644 --- a/ld/testsuite/ld-elf/group9a.d +++ b/ld/testsuite/ld-elf/group9a.d @@ -2,6 +2,7 @@ #ld: -r --gc-sections --entry foo #readelf: -g --wide #notarget: ia64-*-* mep-*-* +#xfail: dlx-*-* openrisc-*-* or32-*-* alpha-*-* arc-*-* COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 2 sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/group9b.d b/ld/testsuite/ld-elf/group9b.d index a28d6703264..89418dd71f3 100644 --- a/ld/testsuite/ld-elf/group9b.d +++ b/ld/testsuite/ld-elf/group9b.d @@ -2,6 +2,7 @@ #ld: -r --gc-sections --entry bar #readelf: -g --wide #notarget: ia64-*-* mep-*-* +#xfail: dlx-*-* openrisc-*-* or32-*-* alpha-*-* hppa64-*-* arc-*-* COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains 2 sections: \[Index\] Name diff --git a/ld/testsuite/ld-scripts/memory.t b/ld/testsuite/ld-scripts/memory.t index 8a73c58801b..6623b289392 100644 --- a/ld/testsuite/ld-scripts/memory.t +++ b/ld/testsuite/ld-scripts/memory.t @@ -1,9 +1,15 @@ MEMORY { - TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 32K - DATAMEM (AW) : org = 0x1000, l = (64 * 1024) + R_TEXTMEM (ARX) : ORIGIN = 0x100, LENGTH = 32K + R_DATAMEM (AW) : org = 0x1000, l = (64 * 1024) } +REGION_ALIAS ("A_TEXTMEM", R_TEXTMEM); +REGION_ALIAS ("A_DATAMEM", R_DATAMEM); + +REGION_ALIAS ("TEXTMEM", A_TEXTMEM); +REGION_ALIAS ("DATAMEM", A_DATAMEM); + SECTIONS { . = 0; diff --git a/ld/testsuite/ld-scripts/region-alias-1.t b/ld/testsuite/ld-scripts/region-alias-1.t new file mode 100644 index 00000000000..91f81005e1d --- /dev/null +++ b/ld/testsuite/ld-scripts/region-alias-1.t @@ -0,0 +1,7 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("MY_ALIAS", MY_REGION); +REGION_ALIAS ("MY_ALIAS", MY_REGION); diff --git a/ld/testsuite/ld-scripts/region-alias-2.t b/ld/testsuite/ld-scripts/region-alias-2.t new file mode 100644 index 00000000000..a6b1514882c --- /dev/null +++ b/ld/testsuite/ld-scripts/region-alias-2.t @@ -0,0 +1,6 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("MY_ALIAS", "NIL"); diff --git a/ld/testsuite/ld-scripts/region-alias-3.t b/ld/testsuite/ld-scripts/region-alias-3.t new file mode 100644 index 00000000000..667879b7d25 --- /dev/null +++ b/ld/testsuite/ld-scripts/region-alias-3.t @@ -0,0 +1,6 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("MY_ALIAS", "*default*"); diff --git a/ld/testsuite/ld-scripts/region-alias-4.t b/ld/testsuite/ld-scripts/region-alias-4.t new file mode 100644 index 00000000000..da9dff50f0f --- /dev/null +++ b/ld/testsuite/ld-scripts/region-alias-4.t @@ -0,0 +1,6 @@ +MEMORY +{ + MY_REGION (ARX) : ORIGIN = 0, LENGTH = 32K +} + +REGION_ALIAS ("*default*", MY_REGION); diff --git a/ld/testsuite/ld-scripts/rgn-over1.d b/ld/testsuite/ld-scripts/rgn-over1.d index 2ce7ffc90c4..54892be41d8 100644 --- a/ld/testsuite/ld-scripts/rgn-over1.d +++ b/ld/testsuite/ld-scripts/rgn-over1.d @@ -1,7 +1,7 @@ # name: rgn-over1 # source: rgn-over.s # ld: -T rgn-over1.t -Map tmpdir/rgn-over1.map -# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \.text will not fit in region r1\n[^ \n]*?ld[^:\n]*?: region r1 overflowed by 16 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \`.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 16 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/rgn-over2.d b/ld/testsuite/ld-scripts/rgn-over2.d index ace01178985..1a5afea8d5f 100644 --- a/ld/testsuite/ld-scripts/rgn-over2.d +++ b/ld/testsuite/ld-scripts/rgn-over2.d @@ -1,7 +1,7 @@ # name: rgn-over2 # source: rgn-over.s # ld: -T rgn-over2.t -Map tmpdir/rgn-over2.map -# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \.data will not fit in region r1\n[^ \n]*?ld[^:\n]*?: region r1 overflowed by 4 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.data' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 4 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/rgn-over3.d b/ld/testsuite/ld-scripts/rgn-over3.d index 91504177692..76fa7c53b3b 100644 --- a/ld/testsuite/ld-scripts/rgn-over3.d +++ b/ld/testsuite/ld-scripts/rgn-over3.d @@ -1,7 +1,7 @@ # name: rgn-over3 # source: rgn-over.s # ld: -T rgn-over3.t -Map tmpdir/rgn-over3.map -# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \.text will not fit in region r1\n[^ \n]*?ld[^:\n]*?: [^\n]*?section \.data will not fit in region r2\n[^ \n]*?ld[^:\n]*?: region r1 overflowed by 4 bytes\n[^ \n]*?ld[^:\n]*?: region r2 overflowed by 4 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.data' will not fit in region `r2'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 4 bytes\n[^ \n]*?ld[^:\n]*?: region `r2' overflowed by 4 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/rgn-over4.d b/ld/testsuite/ld-scripts/rgn-over4.d index e4e98c56c85..1087aec58c4 100644 --- a/ld/testsuite/ld-scripts/rgn-over4.d +++ b/ld/testsuite/ld-scripts/rgn-over4.d @@ -1,7 +1,7 @@ # name: rgn-over4 # source: rgn-over.s # ld: -T rgn-over4.t -Map tmpdir/rgn-over4.map -# error: \A[^ \n]*?ld[^:\n]*?: [^:\n]*?section \.text will not fit in region r1\n[^ \n]*?ld[^:\n]*?: region r1 overflowed by 16 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^:\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 16 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/rgn-over5.d b/ld/testsuite/ld-scripts/rgn-over5.d index abce4e180a5..734d9feed67 100644 --- a/ld/testsuite/ld-scripts/rgn-over5.d +++ b/ld/testsuite/ld-scripts/rgn-over5.d @@ -1,7 +1,7 @@ # name: rgn-over5 # source: rgn-over.s # ld: -T rgn-over5.t -Map tmpdir/rgn-over5.map -# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \.text will not fit in region v1\n[^ \n]*?ld[^:\n]*?: region v1 overflowed by 16 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `v1'\n[^ \n]*?ld[^:\n]*?: region `v1' overflowed by 16 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/rgn-over6.d b/ld/testsuite/ld-scripts/rgn-over6.d index d7088a0166c..00b41d05630 100644 --- a/ld/testsuite/ld-scripts/rgn-over6.d +++ b/ld/testsuite/ld-scripts/rgn-over6.d @@ -1,7 +1,7 @@ # name: rgn-over6 # source: rgn-over.s # ld: -T rgn-over6.t -Map tmpdir/rgn-over6.map -# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \.text will not fit in region r1\n[^ \n]*?ld[^:\n]*?: [^\n]*?section \.text will not fit in region v1\n[^ \n]*?ld[^:\n]*?: region r1 overflowed by 16 bytes\n[^ \n]*?ld[^:\n]*?: region v1 overflowed by 16 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `v1'\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 16 bytes\n[^ \n]*?ld[^:\n]*?: region `v1' overflowed by 16 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/rgn-over7.d b/ld/testsuite/ld-scripts/rgn-over7.d index 52442ba87df..82cfea43ee7 100644 --- a/ld/testsuite/ld-scripts/rgn-over7.d +++ b/ld/testsuite/ld-scripts/rgn-over7.d @@ -1,7 +1,7 @@ # name: rgn-over7 # source: rgn-over.s # ld: -T rgn-over7.t -Map tmpdir/rgn-over7.map -# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section \.text will not fit in region r1\n[^ \n]*?ld[^:\n]*?: section \.data \[0+1008 -> 0+1013\] overlaps section \.text \[0+1000 -> 0+100b\]\n[^ \n]*?ld[^:\n]*?: region r1 overflowed by 4 bytes\Z +# error: \A[^ \n]*?ld[^:\n]*?: [^\n]*?section `\.text' will not fit in region `r1'\n[^ \n]*?ld[^:\n]*?: section \.data \[0+1008 -> 0+1013\] overlaps section \.text \[0+1000 -> 0+100b\]\n[^ \n]*?ld[^:\n]*?: region `r1' overflowed by 4 bytes\Z Discarded input sections #... diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp index 62c98bede4a..88d4b4fb298 100644 --- a/ld/testsuite/ld-scripts/script.exp +++ b/ld/testsuite/ld-scripts/script.exp @@ -126,3 +126,13 @@ if ![ld_simple_link $ld tmpdir/script "$flags -T $srcdir/$subdir/memory.t tmpdir } else { check_script } + +set test_script_list [glob $srcdir/$subdir/region-alias-*.t] + +foreach test_script $test_script_list { + if ![ld_simple_link $ld tmpdir/script "$flags -T $test_script tmpdir/script.o"] { + xfail "REGION_ALIAS: $test_script" + } else { + xpass "REGION_ALIAS: $test_script" + } +}