This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Overlay load address symbols


__load_start_* and __load_stop_* symbols marking overlay load
addresses are currently defined whether or not the symbols are used.
I reckon we should reduce useless symbol table clutter and make them
PROVIDE()'d.  Does anyone object to the following?

ld/
	* ldlang.c (lang_insert_orphan): Provide start/stop loadaddr syms
	rather than defining unconditionally.
	(lang_leave_overlay_section): Likewise.
	* ld.texinfo (Overlay Description): Update description and examples
	for start/stop syms.
ld/testsuite/
	* ld-elf/overlay.d: -u symbols we want to see in the output.

Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.189
diff -u -p -r1.189 ld.texinfo
--- ld/ld.texinfo	22 Mar 2007 21:18:34 -0000	1.189
+++ ld/ld.texinfo	23 Mar 2007 06:24:48 -0000
@@ -4030,7 +4030,7 @@ section to refer directly to another.  @
 NOCROSSREFS}.
 
 For each section within the @code{OVERLAY}, the linker automatically
-defines two symbols.  The symbol @code{__load_start_@var{secname}} is
+provides two symbols.  The symbol @code{__load_start_@var{secname}} is
 defined as the starting load address of the section.  The symbol
 @code{__load_stop_@var{secname}} is defined as the final load address of
 the section.  Any characters within @var{secname} which are not legal
@@ -4055,7 +4055,7 @@ Here is an example.  Remember that this 
 This will define both @samp{.text0} and @samp{.text1} to start at
 address 0x1000.  @samp{.text0} will be loaded at address 0x4000, and
 @samp{.text1} will be loaded immediately after @samp{.text0}.  The
-following symbols will be defined: @code{__load_start_text0},
+following symbols will be defined if referenced: @code{__load_start_text0},
 @code{__load_stop_text0}, @code{__load_start_text1},
 @code{__load_stop_text1}.
 
@@ -4077,11 +4077,11 @@ example could have been written identica
 @smallexample
 @group
   .text0 0x1000 : AT (0x4000) @{ o1/*.o(.text) @}
-  __load_start_text0 = LOADADDR (.text0);
-  __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
+  PROVIDE (__load_start_text0 = LOADADDR (.text0));
+  PROVIDE (__load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0));
   .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) @{ o2/*.o(.text) @}
-  __load_start_text1 = LOADADDR (.text1);
-  __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
+  PROVIDE (__load_start_text1 = LOADADDR (.text1));
+  PROVIDE (__load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1));
   . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
 @end group
 @end smallexample
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.253
diff -u -p -r1.253 ldlang.c
--- ld/ldlang.c	16 Mar 2007 15:13:21 -0000	1.253
+++ ld/ldlang.c	22 Mar 2007 22:04:17 -0000
@@ -1490,8 +1490,9 @@ lang_insert_orphan (asection *s,
 	  e_align = exp_unop (ALIGN_K,
 			      exp_intop ((bfd_vma) 1 << s->alignment_power));
 	  lang_add_assignment (exp_assop ('=', ".", e_align));
-	  lang_add_assignment (exp_assop ('=', symname,
-					  exp_nameop (NAME, ".")));
+	  lang_add_assignment (exp_provide (symname,
+					    exp_nameop (NAME, "."),
+					    FALSE));
 	}
     }
 
@@ -1521,8 +1522,9 @@ lang_insert_orphan (asection *s,
       symname = (char *) xmalloc (ps - secname + sizeof "__stop_" + 1);
       symname[0] = bfd_get_symbol_leading_char (output_bfd);
       sprintf (symname + (symname[0] != 0), "__stop_%s", secname);
-      lang_add_assignment (exp_assop ('=', symname,
-				      exp_nameop (NAME, ".")));
+      lang_add_assignment (exp_provide (symname,
+					exp_nameop (NAME, "."),
+					FALSE));
     }
 
   /* Restore the global list pointer.  */
@@ -6436,15 +6438,17 @@ lang_leave_overlay_section (fill_type *f
 
   buf = xmalloc (strlen (clean) + sizeof "__load_start_");
   sprintf (buf, "__load_start_%s", clean);
-  lang_add_assignment (exp_assop ('=', buf,
-				  exp_nameop (LOADADDR, name)));
+  lang_add_assignment (exp_provide (buf,
+				    exp_nameop (LOADADDR, name),
+				    FALSE));
 
   buf = xmalloc (strlen (clean) + sizeof "__load_stop_");
   sprintf (buf, "__load_stop_%s", clean);
-  lang_add_assignment (exp_assop ('=', buf,
-				  exp_binop ('+',
-					     exp_nameop (LOADADDR, name),
-					     exp_nameop (SIZEOF, name))));
+  lang_add_assignment (exp_provide (buf,
+				    exp_binop ('+',
+					       exp_nameop (LOADADDR, name),
+					       exp_nameop (SIZEOF, name)),
+				    FALSE));
 
   free (clean);
 }
Index: ld/testsuite/ld-elf/overlay.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/overlay.d,v
retrieving revision 1.1
diff -u -p -r1.1 overlay.d
--- ld/testsuite/ld-elf/overlay.d	23 Aug 2006 14:43:56 -0000	1.1
+++ ld/testsuite/ld-elf/overlay.d	22 Mar 2007 22:04:18 -0000
@@ -1,4 +1,4 @@
-# ld: -T overlay.t
+# ld: -T overlay.t -u __load_start_text1 -u __load_start_text2 -u __load_stop_text1 -u __load_stop_text2
 #readelf: -s
 
 #...

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]