This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Tweak region overflow check
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Nathan Sidwell" <nathan at codesourcery dot com>
- Cc: binutils <binutils at sources dot redhat dot com>
- Date: Fri, 2 May 2008 08:01:57 -0700
- Subject: Re: Tweak region overflow check
- References: <4810589B.3000803@codesourcery.com>
Hi Nathan,
This doesn't work on Linux/Intel64:
http://sourceware.org/bugzilla/show_bug.cgi?id=6475
H.J.
On Thu, Apr 24, 2008 at 2:53 AM, Nathan Sidwell <nathan@codesourcery.com> wrote:
> This patch fixes a problem with region overflow checking on bss-style ALLOC
> but !LOAD sections. When such sections have an explicitly set LMA, as one
> might have with:
> .data {...} >ram AT>rom
> .bss {...} >ram AT>rom
> we shouldn't test whether they overflow the LMA region, for they will
> occupy no space there.
>
> One could not override the bss section's LMA region, I suppose, but that
> might be confusing. And I for one find it aesthetically unpleasing to have
> .data and .bss differ in such a manner.
>
> ok?
>
> nathan
> --
> Nathan Sidwell :: http://www.codesourcery.com ::
> CodeSourcery
>
>
> 2008-04-23 Nathan Sidwell <nathan@codesourcery.com>
>
> * ldlang.c (lang_size_sections_1): Don't check LMA overflow on
> non-load sections.
>
> * ld-scripts/rgn-over.exp: Allow -ok file names to pass.
> * ld-scripts/rgn-over8.s: New.
> * ld-scripts/rgn-over8.t: New.
> * ld-scripts/rgn-over8-ok.d: New.
>
> Index: ldlang.c
> ===================================================================
> RCS file: /cvs/src/src/ld/ldlang.c,v
> retrieving revision 1.283
> diff -c -3 -p -r1.283 ldlang.c
> *** ldlang.c 22 Feb 2008 14:19:43 -0000 1.283
> --- ldlang.c 23 Apr 2008 20:56:10 -0000
> *************** lang_size_sections_1
> *** 4699,4705 ****
> os_region_check (os, os->region, os->addr_tree,
> os->bfd_section->vma);
>
> ! if (os->lma_region != NULL && os->lma_region != os->region)
> {
> os->lma_region->current
> = os->bfd_section->lma + TO_ADDR
> (os->bfd_section->size);
> --- 4699,4706 ----
> os_region_check (os, os->region, os->addr_tree,
> os->bfd_section->vma);
>
> ! if (os->lma_region != NULL && os->lma_region != os->region
> ! && (os->bfd_section->flags & SEC_LOAD))
> {
> os->lma_region->current
> = os->bfd_section->lma + TO_ADDR
> (os->bfd_section->size);
> Index: testsuite/ld-scripts/rgn-over.exp
> ===================================================================
> RCS file: /cvs/src/src/ld/testsuite/ld-scripts/rgn-over.exp,v
> retrieving revision 1.2
> diff -c -3 -p -r1.2 rgn-over.exp
> *** testsuite/ld-scripts/rgn-over.exp 14 Dec 2007 21:54:50 -0000 1.2
> --- testsuite/ld-scripts/rgn-over.exp 23 Apr 2008 20:56:13 -0000
> *************** foreach test_file $test_list {
> *** 36,52 ****
> 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
> }
> }
> set LDFLAGS $old_ldflags
> --- 36,54 ----
> verbose $test_name
> run_dump_test $test_name
>
> ! if { ! [regexp ".*-ok.d" $test_file] } {
> ! 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
> }
> }
> }
> set LDFLAGS $old_ldflags
> Index: testsuite/ld-scripts/rgn-over8-ok.d
> ===================================================================
> RCS file: testsuite/ld-scripts/rgn-over8-ok.d
> diff -N testsuite/ld-scripts/rgn-over8-ok.d
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- testsuite/ld-scripts/rgn-over8-ok.d 23 Apr 2008 20:56:13 -0000
> ***************
> *** 0 ****
> --- 1,12 ----
> + # name: rgn-over8
> + # source: rgn-over8.s
> + # ld: -T rgn-over8.t
> + # objdump: -w -h
> +
> + .*: file format .*
> +
> + Sections:
> + Idx +Name +Size +VMA +LMA +File off +Algn +Flags
> + 0 .text 0+0000400 0+0000000 0+0000000 [0-9a-f]+ 2\*\*0
> CONTENTS, ALLOC, LOAD, READONLY, CODE
> + 1 .data 0+0000400 0+0001000 0+0000400 [0-9a-f]+ 2\*\*0
> CONTENTS, ALLOC, LOAD, DATA
> + 2 .bss 0+0000400 0+0001400 0+0000800 [0-9a-f]+ 2\*\*0
> ALLOC
> Index: testsuite/ld-scripts/rgn-over8.s
> ===================================================================
> RCS file: testsuite/ld-scripts/rgn-over8.s
> diff -N testsuite/ld-scripts/rgn-over8.s
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- testsuite/ld-scripts/rgn-over8.s 23 Apr 2008 20:56:13 -0000
> ***************
> *** 0 ****
> --- 1,7 ----
> + .text
> + .globl main
> + .zero 1024
> + .data
> + .zero 1024
> + .bss
> + .zero 1024
> Index: testsuite/ld-scripts/rgn-over8.t
> ===================================================================
> RCS file: testsuite/ld-scripts/rgn-over8.t
> diff -N testsuite/ld-scripts/rgn-over8.t
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- testsuite/ld-scripts/rgn-over8.t 23 Apr 2008 20:56:13 -0000
> ***************
> *** 0 ****
> --- 1,13 ----
> + /* Memory region overflow tests: bss to LMA doesn't cause overflow. */
> +
> + MEMORY {
> + rom (rwx) : ORIGIN = 0, LENGTH = 2048
> + ram (rwx) : ORIGIN = 0x1000, LENGTH = 2048
> + }
> + _start = 0x0;
> + SECTIONS {
> + .text : { *(.text) } >rom AT>rom
> + .data : { *(.data) } >ram AT>rom
> + .bss : { *(.bss) } >ram AT>rom
> + /DISCARD/ : { *(*) }
> + }
>
>