[PATCH] Allow overriding of symbols in libgloss/arm/crt0.S.

Carlos O'Donell carlos@codesourcery.com
Fri Aug 10 20:09:00 GMT 2007

A bug in crt0.S prevents overriding the values of __stack,
hardware_init_hook, and software_init_hook by linker scripts or program

In the libgloss/arm/crt0.S startup the symbols __stack,
hardware_init_hook, software_init_hook are set with '.set <symbol>,0'.
Using '.set' causes the linker to emit a relocation against *ABS*, and
therefore the value cannot be overriden in a linker script or program.

A weak reference that remains unresolved will be given a value of zero,
giving the desired behaviour.

This patch removes the '.set' for __stack, hardware_init_hook, and
software_init_hook, allowing the linker script to override the value if

Tested on arm-none-eabi without regressions.

Please apply.

Carlos O'Donell
(650) 331-3385 x716

2007-08-10  Carlos O'Donell  <carlos@codesourcery.com>

	* arm/crt0.S: Remove '.set' for __stack, hardware_init_hook,
	and software_init_hook.

Index: libgloss/arm/crt0.S
RCS file: /cvs/src/src/libgloss/arm/crt0.S,v
retrieving revision 1.5
diff -u -p -r1.5 crt0.S
--- libgloss/arm/crt0.S	7 Feb 2006 18:46:23 -0000	1.5
+++ libgloss/arm/crt0.S	10 Aug 2007 19:58:59 -0000
@@ -352,10 +352,6 @@ change_back:
 	   and only if, a normal version of the same symbol isn't provided
 	   e.g. by a linker script or another object file.) */	
-	.set __stack, 0
-	.set FUNCTION (hardware_init_hook), 0
-	.set FUNCTION (software_init_hook), 0
 	.weak __stack
 	.weak FUNCTION (hardware_init_hook) 
 	.weak FUNCTION (software_init_hook)

More information about the Newlib mailing list