This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
linker script data statements
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils at sources dot redhat dot com
- Cc: Nick Clifton <nickc at redhat dot com>
- Date: Thu, 19 Feb 2004 11:51:00 +0000
- Subject: linker script data statements
- Organization: Codesourcery LLC
Hi,
data statements don't take account of a value's VMA. This patch fixes
that.
tested on mips-unknown-elf, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-02-19 Nathan Sidwell <nathan@codesourcery.com>
* ldlang.c (map_input_to_output_sections): Initialize sections
mentioned in a data statement expression.
(lang_do_assignments_1): Add data statement's expression's
section's vma.
2004-02-19 Nathan Sidwell <nathan@codesourcery.com>
* ld-scripts/data.{s,t,d,exp}: New.
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.136
diff -c -3 -p -r1.136 ldlang.c
*** ld/ldlang.c 18 Feb 2004 16:37:20 -0000 1.136
--- ld/ldlang.c 19 Feb 2004 11:45:57 -0000
*************** map_input_to_output_sections
*** 2098,2107 ****
target,
output_section_statement);
break;
case lang_fill_statement_enum:
case lang_input_section_enum:
case lang_object_symbols_statement_enum:
- case lang_data_statement_enum:
case lang_reloc_statement_enum:
case lang_padding_statement_enum:
case lang_input_statement_enum:
--- 2098,2111 ----
target,
output_section_statement);
break;
+ case lang_data_statement_enum:
+ /* Make sure that any sections mentioned in the expression
+ are initialized. */
+ exp_init_os (s->data_statement.exp);
+ /* FALLTHROUGH */
case lang_fill_statement_enum:
case lang_input_section_enum:
case lang_object_symbols_statement_enum:
case lang_reloc_statement_enum:
case lang_padding_statement_enum:
case lang_input_statement_enum:
*************** lang_do_assignments_1
*** 3375,3381 ****
value = exp_fold_tree (s->data_statement.exp,
abs_output_section,
lang_final_phase_enum, dot, &dot);
! s->data_statement.value = value.value;
if (!value.valid_p)
einfo (_("%F%P: invalid data statement\n"));
}
--- 3379,3386 ----
value = exp_fold_tree (s->data_statement.exp,
abs_output_section,
lang_final_phase_enum, dot, &dot);
! s->data_statement.value
! = value.value + value.section->bfd_section->vma;
if (!value.valid_p)
einfo (_("%F%P: invalid data statement\n"));
}
Index: ld/testsuite/ld-scripts/data.d
===================================================================
RCS file: ld/testsuite/ld-scripts/data.d
diff -N ld/testsuite/ld-scripts/data.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/data.d 19 Feb 2004 11:45:57 -0000
***************
*** 0 ****
--- 1,9 ----
+ #source: data.s
+ #ld: -T data.t
+ #objdump: -s -j .text
+
+ .*: file format .*
+
+ Contents of section .text:
+ 1000 (0410)?0000(1004)? (0810)?0000(1008)? +........ *
+ #pass
Index: ld/testsuite/ld-scripts/data.exp
===================================================================
RCS file: ld/testsuite/ld-scripts/data.exp
diff -N ld/testsuite/ld-scripts/data.exp
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/data.exp 19 Feb 2004 11:45:57 -0000
***************
*** 0 ****
--- 1,20 ----
+ # Test DATA STATEMENT in a linker script.
+ # By Nathan Sidwell, CodeSourcery LLC
+ # Copyright 2004
+ # Free Software Foundation, Inc.
+ #
+ # This file 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ run_dump_test data
Index: ld/testsuite/ld-scripts/data.s
===================================================================
RCS file: ld/testsuite/ld-scripts/data.s
diff -N ld/testsuite/ld-scripts/data.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/data.s 19 Feb 2004 11:45:57 -0000
***************
*** 0 ****
--- 1 ----
+ #nothing here
Index: ld/testsuite/ld-scripts/data.t
===================================================================
RCS file: ld/testsuite/ld-scripts/data.t
diff -N ld/testsuite/ld-scripts/data.t
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-scripts/data.t 19 Feb 2004 11:45:57 -0000
***************
*** 0 ****
--- 1,10 ----
+ SECTIONS
+ {
+ .text 0x1000 :
+ {
+ LONG (label)
+ label = .;
+ LONG (ADDR (.other))
+ }
+ .other : {}
+ }