+2015-01-20 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ld-scripts/overlay-size.d: Add 'map' option.
+ * ld-scripts/overlay-size.exp: Remove manual check of mapfile.
+ * lib/ld-lib.exp (run_dump_test): Add support for new 'map'
+ option, checking linker mapfile output.
+
2015-01-20 Alan Modra <amodra@gmail.com>
* ld-powerpc/ambiguousv1.d,
# both "error" and "warning". Multiple "warning" directives
# append to the expected linker warning message.
#
+# map: FILE
+# Adding this option will cause the linker to generate a linker
+# map file, using the -Map=MAPFILE command line option. If
+# there is no -Map=MAPFILE in the 'ld: FLAGS' then one will be
+# added to the linker command line. The contents of the
+# generated MAPFILE are then compared against the regexp lines
+# in FILE using `regexp_diff' (see below for details).
+#
# Each option may occur at most once unless otherwise mentioned.
#
# After the option lines come regexp lines. `run_dump_test' calls
set opts(warning) {}
set opts(objcopy_linked_file) {}
set opts(objcopy_objects) {}
+ set opts(map) {}
foreach i $opt_array {
set opt_name [lindex $i 0]
set cmd "$LD $LDFLAGS -L$srcdir/$subdir \
$opts(ld) -o $objfile $objfiles $opts(ld_after_inputfiles)"
+ # If needed then check for, or add a -Map option.
+ set mapfile ""
+ if { $opts(map) != "" } then {
+ if { [regexp -- "-Map=(\[^ \]+)" $cmd all mapfile] } then {
+ # Found existing mapfile option
+ verbose -log "Existing mapfile '$mapfile' found"
+ } else {
+ # No mapfile option.
+ set mapfile "tmpdir/dump.map"
+ verbose -log "Adding mapfile '$mapfile'"
+ set cmd "$cmd -Map=$mapfile"
+ }
+ }
+
send_log "$cmd\n"
set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "ld.tmp"]
remote_upload host "ld.tmp"
return
}
}
+
+ if { $opts(map) != "" } then {
+ # Check the map file matches.
+ set map_pattern_file $srcdir/$subdir/$opts(map)
+ verbose -log "Compare '$mapfile' against '$map_pattern_file'"
+ if { [regexp_diff $mapfile $map_pattern_file] } then {
+ fail "$testname (map file check)"
+ } else {
+ pass "$testname (map file check)"
+ }
+ }
} else {
set objfile "tmpdir/dump0.o"
}