From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 748 invoked by alias); 17 Oct 2007 19:28:43 -0000 Received: (qmail 729 invoked by uid 22791); 17 Oct 2007 19:28:41 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 17 Oct 2007 19:28:36 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 0A0AB981F1 for ; Wed, 17 Oct 2007 19:28:35 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id A4C07980A5 for ; Wed, 17 Oct 2007 19:28:34 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1IiEZF-0001xh-QO for binutils@sourceware.org; Wed, 17 Oct 2007 15:28:33 -0400 Date: Thu, 18 Oct 2007 05:37:00 -0000 From: Daniel Jacobowitz To: binutils@sourceware.org Subject: Re: PATCH: Improved diagnosis of overflowed memory regions Message-ID: <20071017192833.GA7387@caradoc.them.org> Mail-Followup-To: binutils@sourceware.org References: <469E8EDC.7000504@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <469E8EDC.7000504@codesourcery.com> User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00259.txt.bz2 On Wed, Jul 18, 2007 at 03:06:20PM -0700, Zack Weinberg wrote: > ld: > * ldlang.c (lang_check_section_addresses): Also report size of > overflow for any overflowed memory regions. > (os_region_check): Diagnose an overflowed region only once per > region. Do not reset region->current on overflow. > ld/testsuite: > * ld-scripts/rgn-over.exp: New driver. > * ld-scripts/rgn-over.s: New file. > * ld-scripts/rgn-over1.d, ld-scripts/rgn-over1.t > * ld-scripts/rgn-over2.d, ld-scripts/rgn-over2.t > * ld-scripts/rgn-over3.d, ld-scripts/rgn-over3.t > * ld-scripts/rgn-over4.d, ld-scripts/rgn-over4.t > * ld-scripts/rgn-over5.d, ld-scripts/rgn-over5.t > * ld-scripts/rgn-over6.d, ld-scripts/rgn-over6.t > * ld-scripts/rgn-over7.d, ld-scripts/rgn-over7.t: > New test cases. Nick approved this, but it never got checked in; Zack asked me to take care of it. So I just checked in this updated version, based on our internal tree; the ldlang bits are unchanged but the testcases are updated to avoid problems on Windows, MIPS, and possibly other platforms. If they fail somewhere new, please let me know and we'll look into it. Cross-platform ld tests are always such fun. -- Daniel Jacobowitz CodeSourcery 2007-10-17 Zack Weinberg * ldlang.c (lang_check_section_addresses): Also report size of overflow for any overflowed memory regions. (os_region_check): Diagnose an overflowed region only once per region. Do not reset region->current on overflow. 2007-10-17 Zack Weinberg Daniel Jacobowitz Mark Shinwell Joseph Myers * ld-scripts/rgn-over.exp: New driver. * ld-scripts/rgn-over.s: New file. * ld-scripts/rgn-over1.d, ld-scripts/rgn-over1.t, ld-scripts/rgn-over2.d, ld-scripts/rgn-over2.t, ld-scripts/rgn-over3.d, ld-scripts/rgn-over3.t, ld-scripts/rgn-over4.d, ld-scripts/rgn-over4.t, ld-scripts/rgn-over5.d, ld-scripts/rgn-over5.t, ld-scripts/rgn-over6.d, ld-scripts/rgn-over6.t, ld-scripts/rgn-over7.d, ld-scripts/rgn-over7.t: New test cases. Index: ld/ldlang.c =================================================================== RCS file: /cvs/src/src/ld/ldlang.c,v retrieving revision 1.272 diff -u -p -r1.272 ldlang.c --- ld/ldlang.c 18 Sep 2007 00:25:06 -0000 1.272 +++ ld/ldlang.c 17 Oct 2007 19:21:48 -0000 @@ -4120,7 +4120,8 @@ sort_sections_by_lma (const void *arg1, /* Check to see if any allocated sections overlap with other allocated sections. This can happen if a linker script specifies the output - section addresses of the two sections. */ + section addresses of the two sections. Also check whether any memory + region has overflowed. */ static void lang_check_section_addresses (void) @@ -4133,6 +4134,7 @@ lang_check_section_addresses (void) bfd_vma os_start; bfd_vma os_end; bfd_size_type amt; + lang_memory_region_type *m; if (bfd_count_sections (output_bfd) <= 1) return; @@ -4181,6 +4183,20 @@ lang_check_section_addresses (void) } free (sections); + + /* If any memory region has overflowed, report by how much. + We do not issue this diagnostic for regions that had sections + explicitly placed outside their bounds; os_region_check's + diagnostics are adequate for that case. + + FIXME: It is conceivable that m->current - (m->origin + m->length) + might overflow a 32-bit integer. There is, alas, no way to print + 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))); + } /* Make sure the new address is within the region. We explicitly permit the @@ -4208,15 +4224,15 @@ os_region_check (lang_output_section_sta os->bfd_section->name, region->name); } - else + else if (!region->had_full_message) { - einfo (_("%X%P: region %s is full (%B section %s)\n"), - region->name, + region->had_full_message = TRUE; + + einfo (_("%X%P: %B section %s will not fit in region %s\n"), os->bfd_section->owner, - os->bfd_section->name); + os->bfd_section->name, + region->name); } - /* Reset the region pointer. */ - region->current = region->origin; } } Index: ld/testsuite/ld-scripts/rgn-over.exp =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over.exp diff -N ld/testsuite/ld-scripts/rgn-over.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over.exp 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,46 @@ +# Test for proper diagnosis of overflowed memory regions. +# Copyright 2007 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +if ![is_elf_format] { + return +} + +load_lib ld-lib.exp + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/rgn-over*.d]] +foreach test_file $test_list { + set test_name [file rootname $test_file] + set map_file "tmpdir/[file tail $test_name].map" + verbose $test_name + run_dump_test $test_name + + set testname "[file tail $test_name] (map check)" + if [file exists $map_file] { + # compare the map file to the expectations in the .d file + # (run_dump_test can't do that). + if [regexp_diff $map_file $test_file] { + fail $testname + } else { + pass $testname + } + } else { + untested $testname + } +} Index: ld/testsuite/ld-scripts/rgn-over.s =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over.s diff -N ld/testsuite/ld-scripts/rgn-over.s --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over.s 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,9 @@ + .section .txt, "ax", "progbits" + .4byte 0x11223344 + .4byte 0x55667788 + .4byte 0x99aabbcc + + .section .dat, "aw", "progbits" + .4byte 0x01020304 + .4byte 0x05060708 + .4byte 0x090a0b0c Index: ld/testsuite/ld-scripts/rgn-over1.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over1.d diff -N ld/testsuite/ld-scripts/rgn-over1.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over1.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,34 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over1.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over1.t diff -N ld/testsuite/ld-scripts/rgn-over1.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over1.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,13 @@ +/* Memory region overflow tests: one region, first output sect doesn't fit. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r1 + /DISCARD/ : { *(*) } +} Index: ld/testsuite/ld-scripts/rgn-over2.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over2.d diff -N ld/testsuite/ld-scripts/rgn-over2.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over2.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,34 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0014\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over2.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over2.t diff -N ld/testsuite/ld-scripts/rgn-over2.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over2.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,14 @@ +/* Memory region overflow tests: one region, first output sect fits, + second doesn't. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 20 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r1 + /DISCARD/ : { *(*) } +} Index: ld/testsuite/ld-scripts/rgn-over3.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over3.d diff -N ld/testsuite/ld-scripts/rgn-over3.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over3.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,35 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +r2\s+0x0+2000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+2000\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+2000\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over3.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over3.t diff -N ld/testsuite/ld-scripts/rgn-over3.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over3.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,15 @@ +/* Memory region overflow tests: two regions, each too small for the single + section placed there. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + r2 (rwx) : ORIGIN = 0x2000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r2 + /DISCARD/ : { *(*) } +} Index: ld/testsuite/ld-scripts/rgn-over4.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over4.d diff -N ld/testsuite/ld-scripts/rgn-over4.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over4.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,35 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +v1\s+0x0+2000\s+0x0+0018\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc\s+load\s+address\s+0x0+2000 +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc\s+load\s+address\s+0x0+200c +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over4.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over4.t diff -N ld/testsuite/ld-scripts/rgn-over4.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over4.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow VMA but not LMA. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + v1 (rwx) : ORIGIN = 0x2000, LENGTH = 24 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 AT> v1 + .data : { *(.dat) } > r1 AT> v1 + /DISCARD/ : { *(*) } +} Index: ld/testsuite/ld-scripts/rgn-over5.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over5.d diff -N ld/testsuite/ld-scripts/rgn-over5.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over5.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,35 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0018\s+xrw +v1\s+0x0+2000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc\s+load\s+address\s+0x0+2000 +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc\s+load\s+address\s+0x0+200c +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over5.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over5.t diff -N ld/testsuite/ld-scripts/rgn-over5.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over5.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow LMA but not VMA. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 24 + v1 (rwx) : ORIGIN = 0x2000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 AT> v1 + .data : { *(.dat) } > r1 AT> v1 + /DISCARD/ : { *(*) } +} Index: ld/testsuite/ld-scripts/rgn-over6.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over6.d diff -N ld/testsuite/ld-scripts/rgn-over6.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over6.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,35 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +v1\s+0x0+2000\s+0x0+0008\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc\s+load\s+address\s+0x0+2000 +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+100c\s+0xc\s+load\s+address\s+0x0+200c +\s*\*\(\.dat\) +\s*\.dat\s+0x0+100c\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over6.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over6.t diff -N ld/testsuite/ld-scripts/rgn-over6.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over6.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow LMA and VMA. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + v1 (rwx) : ORIGIN = 0x2000, LENGTH = 8 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 AT> v1 + .data : { *(.dat) } > r1 AT> v1 + /DISCARD/ : { *(*) } +} Index: ld/testsuite/ld-scripts/rgn-over7.d =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over7.d diff -N ld/testsuite/ld-scripts/rgn-over7.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over7.d 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,35 @@ +# 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 + +Discarded input sections +#... +Memory\s+Configuration + +Name\s+Origin\s+Length\s+Attributes +bss\s+0x0+0000\s+0x0+0000\s+xrw +r1\s+0x0+1000\s+0x0+0008\s+xrw +r2\s+0x0+1008\s+0x0+000c\s+xrw +\*default\*\s+0x0+0000\s+0xf+ffff + +Linker\s+script\s+and\s+memory\s+map + +\s*0x0+1000\s+_start\s+=\s+0x1000 + +\s*\.bss\s+0x0+0000\s+0x0 +\s*\*\(\.bss\) +\s*\.bss\s+0x0+0000\s+0x0\s+.*? + +\s*\.text\s+0x0+1000\s+0xc +\s*\*\(\.txt\) +\s*\.txt\s+0x0+1000\s+0xc\s+.*? + +\s*\.data\s+0x0+1008\s+0xc +\s*\*\(\.dat\) +\s*\.dat\s+0x0+1008\s+0xc\s+.*? + +/DISCARD/ + \*\(\*\) +LOAD\s+.*? +OUTPUT\(.*?\) Index: ld/testsuite/ld-scripts/rgn-over7.t =================================================================== RCS file: ld/testsuite/ld-scripts/rgn-over7.t diff -N ld/testsuite/ld-scripts/rgn-over7.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld/testsuite/ld-scripts/rgn-over7.t 17 Oct 2007 19:21:48 -0000 @@ -0,0 +1,14 @@ +/* Memory region overflow tests: overflow r1 plus text/data collision. */ + +MEMORY { + bss (rwx) : ORIGIN = 0, LENGTH = 0 + r1 (rwx) : ORIGIN = 0x1000, LENGTH = 8 + r2 (rwx) : ORIGIN = 0x1008, LENGTH = 12 +} +_start = 0x1000; +SECTIONS { + .bss : { *(.bss) } > bss + .text : { *(.txt) } > r1 + .data : { *(.dat) } > r2 + /DISCARD/ : { *(*) } +}