This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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] ld/ldlang.h: use 'etree_base' instead of 'base' to avoid cross-compiling warning


It is not recommend to use a simple name to express a global variable,
for it is easy to get '-Wshadow'. So use 'etree_base' instead of.

The related warning (for aarch64 cross-compiling):

  gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/ld  -I. -I../../binutils-gdb/ld -I../bfd -I../../binutils-gdb/ld/../bfd -I../../binutils-gdb/ld/../include  -g -O2 -DENABLE_PLUGINS -DLOCALEDIR="\"/usr/local/share/locale\""  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT ldlex-wrapper.o -MD -MP -MF .deps/ldlex-wrapper.Tpo -c -o ldlex-wrapper.o ../../binutils-gdb/ld/ldlex-wrapper.c -Wno-error
  In file included from ../../binutils-gdb/ld/ldlex-wrapper.c:26:0:
  ldlex.c: In function ‘yy_scan_buffer’:
  ldlex.c:3821:41: warning: declaration of ‘base’ shadows a global declaration [-Wshadow]
  In file included from ldlex.l:31:0,
                   from ../../binutils-gdb/ld/ldlex-wrapper.c:26:
  ../../binutils-gdb/ld/ldlang.h:478:20: warning: shadowed declaration is here [-Wshadow]


Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 ld/ldlang.c |  2 +-
 ld/ldlang.h |  2 +-
 ld/mri.c    | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ld/ldlang.c b/ld/ldlang.c
index ba7f493..d441bc7 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -111,7 +111,7 @@ struct lang_nocrossrefs *nocrossref_list;
     DEFINED() need to increment this.  */
 int lang_statement_iteration = 0;
 
-etree_type *base; /* Relocation base - or null */
+etree_type *etree_base; /* Relocation base - or null */
 
 /* Return TRUE if the PATTERN argument is a wildcard pattern.
    Although backslashes are treated specially if a pattern contains
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 2dbec5a..355ef25 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -475,7 +475,7 @@ extern lang_output_section_statement_type *abs_output_section;
 extern lang_statement_list_type lang_output_section_statement;
 extern struct lang_input_statement_flags input_flags;
 extern bfd_boolean lang_has_input_file;
-extern etree_type *base;
+extern etree_type *etree_base;
 extern lang_statement_list_type *stat_ptr;
 extern bfd_boolean delete_output_file_on_failure;
 
diff --git a/ld/mri.c b/ld/mri.c
index 450cdf7..07e26a4 100644
--- a/ld/mri.c
+++ b/ld/mri.c
@@ -110,7 +110,7 @@ mri_only_load (const char *name)
 void
 mri_base (etree_type *exp)
 {
-  base = exp;
+  etree_base = exp;
 }
 
 static int done_tree = 0;
@@ -203,13 +203,13 @@ mri_draw_tree (void)
 	    if (strcmp (aptr->name, p->name) == 0)
 	      subalign = aptr->subalign;
 
-	  if (base == 0)
-	    base = p->vma ? p->vma : exp_nameop (NAME, ".");
+	  if (etree_base == 0)
+	    etree_base = p->vma ? p->vma : exp_nameop (NAME, ".");
 
-	  lang_enter_output_section_statement (p->name, base,
+	  lang_enter_output_section_statement (p->name, etree_base,
 					       p->ok_to_load ? normal_section : noload_section,
 					       align, subalign, NULL, 0, 0);
-	  base = 0;
+	  etree_base = 0;
 	  tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
 	  tmp->next = NULL;
 	  tmp->spec.name = p->name;
@@ -243,7 +243,7 @@ mri_draw_tree (void)
 void
 mri_load (const char *name)
 {
-  base = 0;
+  etree_base = 0;
   lang_add_input_file (name, lang_input_file_is_file_enum, NULL);
 }
 
-- 
1.7.11.7


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