[Patch] ld: DEFINED builtin is not correctly computed in map file

Tristan Gingold gingold@adacore.com
Mon Aug 27 18:23:00 GMT 2007


Hi,

this patch fixed a small bug during map file generation.  Because  
lang_statement_iteration was not incremented,
all defined symbols appear to be defined from the beginning.  This is  
not correct according to the
documentation.

Reg-tested on x86-linux, test included.

Tristan.

d/ChangeLog:
2007-08-27  Tristan Gingold  <gingold@adacore.com>

         * ldlang.c (lang_map): Increment lang_statement_iteration so  
that
         DEFINED() expressions are correctly computed.

ld/testsuite/ChangeLog
2007-08-27  Tristan Gingold  <gingold@adacore.com>

         * ld-script/map-address.d,
         * ld-script/map-address.t: Add a test for testing DEFINED in  
map
         output.

--- ld/ldlang.c 29 Jul 2007 12:33:37 -0000      1.268
+++ ld/ldlang.c 27 Aug 2007 14:56:32 -0000
@@ -1811,6 +1811,7 @@
         bfd_map_over_sections (p, init_map_userdata, 0);
        bfd_link_hash_traverse (link_info.hash, sort_def_symbol, 0);
      }
+  lang_statement_iteration++;
    print_statements ();
}
@@ -3539,8 +3540,8 @@
               value = h->u.def.value;
               if (expld.result.section)
-             value += expld.result.section->vma;
+               value += expld.result.section->vma;
               minfo ("[0x%V]", value);
             }
--- ld/testsuite/ld-scripts/map-address.d       28 Aug 2002 00:11:40  
-0000      1.2
+++ ld/testsuite/ld-scripts/map-address.d       27 Aug 2007 14:56:35  
-0000
@@ -1,7 +1,9 @@
#...
Linker script and memory map
#...
+ *0x0*000020 *def1 = .*
+ *0x0*000020 *def2 = def1
   *0x0*010001 *\. = 0x10001
   *0x0*010001 *foo = \.
   *0x0*010201 *\. = \(\. \+ 0x200\)
--- ld/testsuite/ld-scripts/map-address.t       30 Apr 2002 09:23:14  
-0000      1.1
+++ ld/testsuite/ld-scripts/map-address.t       27 Aug 2007 14:56:35  
-0000
@@ -1,5 +1,7 @@
SECTIONS
{
+  def1 = DEFINED(foo) ? 0x10 : 0x20;
+  def2 = def1;
    . = 0x10001;
    foo = .;
    . += 0x200;



More information about the Binutils mailing list