This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/5] addr2line: Always parse addresses as hex numbers.


We would sometimes interpret input addresses as decimal or octal.
That could be confusing and isn't what binutils addr2line does.
Be consistent and always treat input addresses as hex.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog              | 5 +++++
 src/addr2line.c            | 4 ++--
 tests/ChangeLog            | 4 ++++
 tests/run-addrname-test.sh | 2 +-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index f4ff1fb..284b886 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2015-05-20  Mark Wielaard  <mjw@redhat.com>
 
+	* addr2line.c (handle_address): Call strtoumax with base 16. Make
+	sure all input has been processed.
+
+2015-05-20  Mark Wielaard  <mjw@redhat.com>
+
 	* addr2line (argp_option): Group 'section' under "Input format
 	options".
 
diff --git a/src/addr2line.c b/src/addr2line.c
index c7ff7f7..b1ff368 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -532,8 +532,8 @@ static int
 handle_address (const char *string, Dwfl *dwfl)
 {
   char *endp;
-  uintmax_t addr = strtoumax (string, &endp, 0);
-  if (endp == string)
+  uintmax_t addr = strtoumax (string, &endp, 16);
+  if (endp == string || *endp != '\0')
     {
       bool parsed = false;
       int i, j;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index a899947..0e31012 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-20  Mark Wielaard  <mjw@redhat.com>
+
+	* run-addrname-test.sh: Make sure all input addresses are hex.
+
 2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
 
 	* backtrace-child.c (stdarg, main): Replace assert_perror with assert.
diff --git a/tests/run-addrname-test.sh b/tests/run-addrname-test.sh
index f954ee4..90e19df 100755
--- a/tests/run-addrname-test.sh
+++ b/tests/run-addrname-test.sh
@@ -277,7 +277,7 @@ EOF
 #	local l0local2, 0
 #	offset 12
 testfiles testfile64
-testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 12 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 c <<\EOF
 gglobal2
 ??:0
 g0global2
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]