[PATCH] Avoid YESSTR and NOSTR

Ulf Hermann ulf.hermann@qt.io
Thu Apr 20 13:47:00 GMT 2017


Those are deprecated and apparently some implementations of nl_langinfo
return empty strings for them. The tests even tested for those empty
strings even though the intention of the code was clearly to output
"yes" or "no" there.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 src/ChangeLog                   |  5 +++++
 src/readelf.c                   |  6 +++---
 tests/ChangeLog                 |  6 ++++++
 tests/run-readelf-dwz-multi.sh  | 30 +++++++++++++++---------------
 tests/run-readelf-zdebug-rel.sh |  6 +++---
 5 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index a1bec19..e0a591e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
+
+	* readelf.c: Replace YESSTR and NOSTR with gettext ("yes") and
+	gettext ("no"), respectively.
+
 2017-04-05  Mark Wielaard  <mark@klomp.org>
 
 	* elflint.c (check_elf_header): Decompress all sections.
diff --git a/src/readelf.c b/src/readelf.c
index 97a43b0..6f6095d 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6132,7 +6132,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
 
       printf ("           %*s%-20s (%s) %s\n",
 	      (int) (level * 2), "", dwarf_attr_name (attr),
-	      dwarf_form_name (form), nl_langinfo (flag ? YESSTR : NOSTR));
+	      dwarf_form_name (form), flag ? gettext ("yes") : gettext ("no"));
       break;
 
     case DW_FORM_flag_present:
@@ -6140,7 +6140,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
 	break;
       printf ("           %*s%-20s (%s) %s\n",
 	      (int) (level * 2), "", dwarf_attr_name (attr),
-	      dwarf_form_name (form), nl_langinfo (YESSTR));
+	      dwarf_form_name (form), gettext ("yes"));
       break;
 
     case DW_FORM_exprloc:
@@ -7650,7 +7650,7 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 		      if (readp + 1 > readendp)
 			goto invalid_data;
 		      val = *readp++;
-		      printf (" %s", nl_langinfo (val != 0 ? YESSTR : NOSTR));
+		      printf (" %s", val != 0 ? gettext ("yes") : gettext ("no"));
 		      break;
 
 		    case DW_FORM_string:
diff --git a/tests/ChangeLog b/tests/ChangeLog
index ebcd7bc..c4e76d1 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,11 @@
 2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
 
+	* run-readelf-dwz-multi.sh: Expect readelf to output "yes" for flags
+	that are set.
+	* run-readelf-zdebug-rel.sh: Likewise.
+
+2017-04-20  Ulf Hermann <ulf.hermann@qt.io>
+
 	* backtrace-child.c: Include sys/ptrace.h only on linux.
 	* backtrace-dwarf.c: Likewise.
 
diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh
index 27e0f38..23ca944 100755
--- a/tests/run-readelf-dwz-multi.sh
+++ b/tests/run-readelf-dwz-multi.sh
@@ -98,17 +98,17 @@ DWARF section [28] '.debug_info' at offset 0x1078:
              byte_size            (data1) 8
              type                 (GNU_ref_alt) [    53]
  [    31]    subprogram
-             external             (flag_present) 
+             external             (flag_present) yes
              name                 (strp) "main"
              decl_file            (data1) 1
              decl_line            (data1) 3
-             prototyped           (flag_present) 
+             prototyped           (flag_present) yes
              type                 (GNU_ref_alt) [    3e]
              low_pc               (addr) 0x00000000004006ac <main>
              high_pc              (udata) 44 (0x00000000004006d8)
              frame_base           (exprloc) 
               [   0] call_frame_cfa
-             GNU_all_tail_call_sites (flag_present) 
+             GNU_all_tail_call_sites (flag_present) yes
              sibling              (ref_udata) [    6e]
  [    48]      formal_parameter
                name                 (strp) "argc"
@@ -159,17 +159,17 @@ DWARF section [28] '.debug_info' at offset 0x1078:
              byte_size            (data1) 8
              type                 (GNU_ref_alt) [    53]
  [    31]    subprogram
-             external             (flag_present) 
+             external             (flag_present) yes
              name                 (strp) "main"
              decl_file            (data1) 1
              decl_line            (data1) 3
-             prototyped           (flag_present) 
+             prototyped           (flag_present) yes
              type                 (GNU_ref_alt) [    3e]
              low_pc               (addr) 0x00000000004006ac <main>
              high_pc              (udata) 44 (0x00000000004006d8)
              frame_base           (exprloc) 
               [   0] call_frame_cfa
-             GNU_all_tail_call_sites (flag_present) 
+             GNU_all_tail_call_sites (flag_present) yes
              sibling              (ref_udata) [    6e]
  [    48]      formal_parameter
                name                 (strp) "argc"
@@ -216,17 +216,17 @@ DWARF section [25] '.debug_info' at offset 0x106c:
  [    26]    imported_unit
              import               (GNU_ref_alt) [     b]
  [    2b]    subprogram
-             external             (flag_present) 
+             external             (flag_present) yes
              name                 (strp) "call_foo"
              decl_file            (data1) 1
              decl_line            (data1) 3
-             prototyped           (flag_present) 
+             prototyped           (flag_present) yes
              type                 (GNU_ref_alt) [    3e]
              low_pc               (addr) +0x0000000000000670 <call_foo>
              high_pc              (udata) 23 (+0x0000000000000687)
              frame_base           (exprloc) 
               [   0] call_frame_cfa
-             GNU_all_call_sites   (flag_present) 
+             GNU_all_call_sites   (flag_present) yes
  [    41]      formal_parameter
                name                 (string) "fb"
                decl_file            (data1) 1
@@ -256,17 +256,17 @@ DWARF section [25] '.debug_info' at offset 0x106c:
  [    26]    imported_unit
              import               (GNU_ref_alt) [     b]
  [    2b]    subprogram
-             external             (flag_present) 
+             external             (flag_present) yes
              name                 (strp) "call_foo"
              decl_file            (data1) 1
              decl_line            (data1) 3
-             prototyped           (flag_present) 
+             prototyped           (flag_present) yes
              type                 (GNU_ref_alt) [    3e]
              low_pc               (addr) +0x0000000000000670 <call_foo>
              high_pc              (udata) 23 (+0x0000000000000687)
              frame_base           (exprloc) 
               [   0] call_frame_cfa
-             GNU_all_call_sites   (flag_present) 
+             GNU_all_call_sites   (flag_present) yes
  [    41]      formal_parameter
                name                 (string) "fb"
                decl_file            (data1) 1
@@ -295,17 +295,17 @@ DWARF section [28] '.debug_info' at offset 0x1088:
  [    26]    imported_unit
              import               (GNU_ref_alt) [     b]
  [    2b]    subprogram
-             external             (flag_present) 
+             external             (flag_present) yes
              name                 (GNU_strp_alt) "main"
              decl_file            (data1) 1
              decl_line            (data1) 8
-             prototyped           (flag_present) 
+             prototyped           (flag_present) yes
              type                 (GNU_ref_alt) [    30]
              low_pc               (addr) 0x00000000004004ec <main>
              high_pc              (udata) 18 (0x00000000004004fe)
              frame_base           (exprloc) 
               [   0] call_frame_cfa
-             GNU_all_call_sites   (flag_present) 
+             GNU_all_call_sites   (flag_present) yes
  [    41]      formal_parameter
                name                 (GNU_strp_alt) "argc"
                decl_file            (data1) 1
diff --git a/tests/run-readelf-zdebug-rel.sh b/tests/run-readelf-zdebug-rel.sh
index 88ea5bf..1232d63 100755
--- a/tests/run-readelf-zdebug-rel.sh
+++ b/tests/run-readelf-zdebug-rel.sh
@@ -60,17 +60,17 @@ DWARF section [ 4] '.debug_info' at offset 0x58:
            high_pc              (data8) 24 (0x0000000000000018)
            stmt_list            (sec_offset) 0
  [    2d]    subprogram
-             external             (flag_present) 
+             external             (flag_present) yes
              name                 (strp) "main"
              decl_file            (data1) 1
              decl_line            (data1) 4
-             prototyped           (flag_present) 
+             prototyped           (flag_present) yes
              type                 (ref4) [    80]
              low_pc               (addr) 000000000000000000
              high_pc              (data8) 24 (0x0000000000000018)
              frame_base           (exprloc) 
               [   0] call_frame_cfa
-             GNU_all_call_sites   (flag_present) 
+             GNU_all_call_sites   (flag_present) yes
              sibling              (ref4) [    80]
  [    4e]      formal_parameter
                name                 (strp) "argc"
-- 
2.1.4



More information about the Elfutils-devel mailing list