summaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-05-10 10:29:52 +0100
committerNick Clifton <nickc@redhat.com>2023-05-10 10:29:52 +0100
commit496917ce466c703c1ae3bf1cbbe753de1c091445 (patch)
tree0c4992f98acf35f1965238bb7163a7d8cab0ee78 /ld/testsuite
parent2093c2af3c58da1fe63807dfea07d56afc6e7a8a (diff)
Add linker option to include local symbols in the linker map.
PR 16566 * ldlang.c (ld_is_local_symbol): New function. (print_input_section): Add code to display local symbols in the section. * ldlex.h (enum option_values): Add OPTION_PRINT_MAP_LOCALS and OPTION_PRINT_MAP_LOCALS. * lexsup.c (ld_options[]): Add entries for --print-map-locals and --no-print-map-locals. * NEWS: Mention the new feature. * ld.h (struct ld_config_type): Add print_map_locals field. * ld.texi: Document the new command line option. * testsuite/ld-scripts/sizeof.s: Add a local symbol. * testsuite/ld-scripts/map-locals.d: New test control file. * testsuite/ld-scripts/map-address.exp: Run the new test.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-scripts/map-address.exp27
-rw-r--r--ld/testsuite/ld-scripts/map-locals.d5
-rw-r--r--ld/testsuite/ld-scripts/sizeof.s1
3 files changed, 33 insertions, 0 deletions
diff --git a/ld/testsuite/ld-scripts/map-address.exp b/ld/testsuite/ld-scripts/map-address.exp
index 0eeca10fdd8..fbea9064265 100644
--- a/ld/testsuite/ld-scripts/map-address.exp
+++ b/ld/testsuite/ld-scripts/map-address.exp
@@ -120,3 +120,30 @@ if {[regexp_diff \
} else {
pass $testname
}
+
+if { [is_elf_format] } {
+ set testname "map with locals"
+
+ if {![ld_link $ld tmpdir/map-address \
+ "$LDFLAGS -T $srcdir/$subdir/map-address.t \
+ $IMAGE_BASE tmpdir/map-address.o \
+ -Map=tmpdir/map-locals.map --print-map-locals"]} {
+ fail $testname
+ return
+ }
+
+ if [is_remote host] then {
+ remote_upload host "tmpdir/map-locals.map"
+ }
+
+ # Some ELF targets do not preserve their local symbols.
+ setup_xfail "d30v-*-*" "dlx-*-*" "pj-*-*" "s12z-*-*" "xgate-*-*"
+
+ if {[regexp_diff \
+ "tmpdir/map-locals.map" \
+ "$srcdir/$subdir/map-locals.d"]} {
+ fail $testname
+ } else {
+ pass $testname
+ }
+}
diff --git a/ld/testsuite/ld-scripts/map-locals.d b/ld/testsuite/ld-scripts/map-locals.d
new file mode 100644
index 00000000000..f3137f13814
--- /dev/null
+++ b/ld/testsuite/ld-scripts/map-locals.d
@@ -0,0 +1,5 @@
+#...
+Linker script and memory map
+#...
+.*\(local\)[ ]+local_sym
+#pass
diff --git a/ld/testsuite/ld-scripts/sizeof.s b/ld/testsuite/ld-scripts/sizeof.s
index e221ca3c0b3..7cd1677bc85 100644
--- a/ld/testsuite/ld-scripts/sizeof.s
+++ b/ld/testsuite/ld-scripts/sizeof.s
@@ -1 +1,2 @@
+local_sym:
.space 16