From c05b575a8dfabab6af5d8586d1a5c0c67f819ac2 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 7 Jan 2015 10:51:35 +0000 Subject: ld: Don't evaluate unneeded PROVIDE expressions. When creating a linker mapfile (using -Map=MAPFILE), we previously would always try to evaluate the expression from a PROVIDE statement. However, this is not always safe, consider: PROVIDE (foo = 0x10); PROVIDE (bar = foo); In this example, if neither 'foo' or 'bar' is needed, then while generating the linker mapfile evaluating the expression for 'foo' is harmless (just the value 0x10). However, evaluating the expression for 'bar' requires the symbol 'foo', which is undefined. This used to cause a fatal error. This patch changes the behaviour, so that when the destination of the PROVIDE is not defined (that is the PROVIDE is not going to provide anything) the expression is not evaluated, and instead a special string is displayed to indicate that the linker is discarding the PROVIDE statement. This change not only fixes the spurious undefined symbol error, but also means that a user can now tell if a PROVIDE statement has provided anything by inspecting the linker mapfile, something that could not be done before. ld/ChangeLog: * ldlang.c (print_assignment): Only evaluate the expression for a PROVIDE'd assignment when the destination is being defined. Display a special message for PROVIDE'd symbols that are not being provided. ld/testsuite/ChangeLog: * ld-scripts/provide-4.d: New file. * ld-scripts/provide-4-map.d: New file. * ld-scripts/provide-4.t: New file. * ld-scripts/provide-5.d: New file. * ld-scripts/provide-5.s: New file. * ld-scripts/provide-5-map.d: New file. * ld-scripts/provide-5.t: New file. * ld-scripts/provide.exp: Run the provide-4.d and provide-5.d tests. --- ld/testsuite/ld-scripts/provide.exp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ld/testsuite/ld-scripts/provide.exp') diff --git a/ld/testsuite/ld-scripts/provide.exp b/ld/testsuite/ld-scripts/provide.exp index 7f45e58..3ddbb22 100644 --- a/ld/testsuite/ld-scripts/provide.exp +++ b/ld/testsuite/ld-scripts/provide.exp @@ -40,5 +40,7 @@ run_dump_test provide-1 run_dump_test provide-2 setup_xfail *-*-* run_dump_test provide-3 +run_dump_test provide-4 +run_dump_test provide-5 set LDFLAGS "$saved_LDFLAGS" -- cgit v1.1