aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2013-08-19 15:08:52 +0000
committerTristan Gingold <gingold@adacore.com>2013-08-19 15:08:52 +0000
commit8b64b65e23fee758d9a81c9f5c940e23e48a2fea (patch)
treec52f03ec41daa3bc917b8a40002bdcd65c044503 /binutils
parent12696c10906026672f17a551ae1fa5d62878751c (diff)
downloadgdb-8b64b65e23fee758d9a81c9f5c940e23e48a2fea.zip
gdb-8b64b65e23fee758d9a81c9f5c940e23e48a2fea.tar.gz
gdb-8b64b65e23fee758d9a81c9f5c940e23e48a2fea.tar.bz2
binutils/
2013-08-19 Tristan Gingold <gingold@adacore.com> * nm.c (print_size_symbols): Directly get symbol size. binutils/testsuite/ 2013-08-19 Tristan Gingold <gingold@adacore.com> * binutils-all/nm.exp: Add a test for nm --size-sort * binutils-all/nm-elf-1.s: New file. * binutils-all/nm-1.s: New file.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog4
-rw-r--r--binutils/nm.c9
-rw-r--r--binutils/testsuite/ChangeLog6
-rw-r--r--binutils/testsuite/binutils-all/nm-1.s13
-rw-r--r--binutils/testsuite/binutils-all/nm-elf-1.s16
-rw-r--r--binutils/testsuite/binutils-all/nm.exp34
6 files changed, 74 insertions, 8 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ffb0300..f3bda63 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2013-08-19 Tristan Gingold <gingold@adacore.com>
+
+ * nm.c (print_size_symbols): Directly get symbol size.
+
2013-08-12 Andreas Schwab <schwab@suse.de>
PR binutils/15818
diff --git a/binutils/nm.c b/binutils/nm.c
index ad38e27..5c32520 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -951,19 +951,12 @@ print_size_symbols (bfd *abfd, bfd_boolean is_dynamic,
for (; from < fromend; from++)
{
asymbol *sym;
- bfd_vma ssize;
sym = bfd_minisymbol_to_symbol (abfd, is_dynamic, from->minisym, store);
if (sym == NULL)
bfd_fatal (bfd_get_filename (abfd));
- /* For elf we have already computed the correct symbol size. */
- if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
- ssize = from->size;
- else
- ssize = from->size - bfd_section_vma (abfd, bfd_get_section (sym));
-
- print_symbol (abfd, sym, ssize, archive_bfd);
+ print_symbol (abfd, sym, from->size, archive_bfd);
}
}
diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog
index ac10932..d2d2f7d 100644
--- a/binutils/testsuite/ChangeLog
+++ b/binutils/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2013-08-19 Tristan Gingold <gingold@adacore.com>
+
+ * binutils-all/nm.exp: Add a test for nm --size-sort
+ * binutils-all/nm-elf-1.s: New file.
+ * binutils-all/nm-1.s: New file.
+
2013-05-31 H.J. Lu <hongjiu.lu@intel.com>
* binutils-all/i386/compressed-1b.d: Updated for text/data/bss
diff --git a/binutils/testsuite/binutils-all/nm-1.s b/binutils/testsuite/binutils-all/nm-1.s
new file mode 100644
index 0000000..5fe4cd7
--- /dev/null
+++ b/binutils/testsuite/binutils-all/nm-1.s
@@ -0,0 +1,13 @@
+ .globl text_symbol1
+ .globl text_symbol2
+ .globl text_symbol3
+ .text
+text_symbol1:
+ .long 0
+ .long 0
+ .long 0
+text_symbol2:
+ .long 0
+ .long 0
+text_symbol3:
+ .long 0
diff --git a/binutils/testsuite/binutils-all/nm-elf-1.s b/binutils/testsuite/binutils-all/nm-elf-1.s
new file mode 100644
index 0000000..8e2f1f4
--- /dev/null
+++ b/binutils/testsuite/binutils-all/nm-elf-1.s
@@ -0,0 +1,16 @@
+ .globl text_symbol1
+ .globl text_symbol2
+ .globl text_symbol3
+ .text
+text_symbol1:
+ .long 0
+ .long 0
+ .long 0
+ .size text_symbol1, . - text_symbol1
+text_symbol2:
+ .long 0
+ .long 0
+ .size text_symbol2, . - text_symbol2
+text_symbol3:
+ .long 0
+ .size text_symbol3, . - text_symbol3
diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp
index 685794d..226704b 100644
--- a/binutils/testsuite/binutils-all/nm.exp
+++ b/binutils/testsuite/binutils-all/nm.exp
@@ -155,4 +155,38 @@ if [regexp $want $got] then {
fail "nm -P"
}
+# Test nm --size-sort
+
+if [is_elf_format] {
+ set nm_1_src "nm-elf-1.s"
+} else {
+ set nm_1_src "nm-1.s"
+}
+
+if {![binutils_assemble $srcdir/$subdir/$nm_1_src tmpdir/nm-1.o]} then {
+ return
+}
+
+if [is_remote host] {
+ set tempfile [remote_download host tmpdir/nm-1.o]
+} else {
+ set tempfile tmpdir/nm-1.o
+}
+
+# This test does not work correctly on ECOFF targets, because ECOFF
+# stores most symbols twice, which messes up the nm output.
+setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
+setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
+setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
+
+set got [binutils_run $NM "$NMFLAGS --size-sort $tempfile"]
+
+set want "0*4 T text_symbol3.*0*8 T text_symbol2.*0*c T text_symbol1"
+
+if [regexp $want $got] then {
+ pass "nm --size-sort"
+} else {
+ fail "nm --size-sort"
+}
+
# There are certainly other tests that could be run.