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 3/4] allow targets to call do_alignment () directly


From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>

gas/ChangeLog:

2016-03-05  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* config/tc-epiphany.c (epiphany_elf_section_rtn): Call do_align
							   directly.
	(epiphany_elf_section_text): Likewise.
	* gas/config/tc-ip2k.c (ip2k_elf_section_rtn): Likewise.
	(ip2k_elf_section_text): Likewise.
	* gas/read.c (do_align): Make it not static.
	* gas/read.h (do_align): New prototype.
---
 gas/config/tc-epiphany.c | 24 ++----------------------
 gas/config/tc-ip2k.c     | 21 ++-------------------
 gas/read.c               |  2 +-
 gas/read.h               |  2 ++
 4 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/gas/config/tc-epiphany.c b/gas/config/tc-epiphany.c
index 89b61fa..4edd560 100644
--- a/gas/config/tc-epiphany.c
+++ b/gas/config/tc-epiphany.c
@@ -69,38 +69,18 @@ epiphany_elf_section_rtn (int i)
 
   if (force_code_align)
     {
-      /* The s_align_ptwo function expects that we are just after a .align
-	 directive and it will either try and read the align value or stop
-	 if end of line so we must fake it out so it thinks we are at the
-	 end of the line.  */
-      char *old_input_line_pointer = input_line_pointer;
-
-      input_line_pointer = "\n";
-      s_align_ptwo (1);
+      do_align (1, NULL, 0, 0);
       force_code_align = FALSE;
-
-      /* Restore.  */
-      input_line_pointer = old_input_line_pointer;
     }
 }
 
 static void
 epiphany_elf_section_text (int i)
 {
-  char *old_input_line_pointer;
-
   obj_elf_text (i);
 
-  /* The s_align_ptwo function expects that we are just after a .align
-     directive and it will either try and read the align value or stop if
-     end of line so we must fake it out so it thinks we are at the end of
-     the line.  */
-  old_input_line_pointer = input_line_pointer;
-  input_line_pointer = "\n";
-  s_align_ptwo (1);
+  do_align (1, NULL, 0, 0);
   force_code_align = FALSE;
-  /* Restore.  */
-  input_line_pointer = old_input_line_pointer;
 }
 
 /* The target specific pseudo-ops which we support.  */
diff --git a/gas/config/tc-ip2k.c b/gas/config/tc-ip2k.c
index dfa3ba0..1baac58 100644
--- a/gas/config/tc-ip2k.c
+++ b/gas/config/tc-ip2k.c
@@ -72,35 +72,18 @@ ip2k_elf_section_rtn (int i)
 
   if (force_code_align)
     {
-      /* The s_align_ptwo function expects that we are just after a .align
-	 directive and it will either try and read the align value or stop
-	 if end of line so we must fake it out so it thinks we are at the
-	 end of the line.  */
-      char *old_input_line_pointer = input_line_pointer;
-      input_line_pointer = "\n";
-      s_align_ptwo (1);
+      do_align (1, NULL, 0, 0);
       force_code_align = 0;
-      /* Restore.  */
-      input_line_pointer = old_input_line_pointer;
     }
 }
 
 static void
 ip2k_elf_section_text (int i)
 {
-  char *old_input_line_pointer;
   obj_elf_text(i);
 
-  /* the s_align_ptwo function expects that we are just after a .align
-     directive and it will either try and read the align value or stop if
-     end of line so we must fake it out so it thinks we are at the end of
-     the line.  */
-  old_input_line_pointer = input_line_pointer;
-  input_line_pointer = "\n";
-  s_align_ptwo (1);
+  do_align (1, NULL, 0, 0);
   force_code_align = 0;
-  /* Restore.  */
-  input_line_pointer = old_input_line_pointer;
 }
 
 /* The target specific pseudo-ops which we support.  */
diff --git a/gas/read.c b/gas/read.c
index f308cdc..8f5dfff 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -754,7 +754,7 @@ in_bss (void)
    MAX is the maximum number of characters to skip when doing the alignment,
     or 0 if there is no maximum.  */
 
-static void
+void
 do_align (unsigned int n, char *fill, unsigned int len, unsigned int max)
 {
   if (now_seg == absolute_section || in_bss ())
diff --git a/gas/read.h b/gas/read.h
index 0787eab..e0cb646 100644
--- a/gas/read.h
+++ b/gas/read.h
@@ -153,6 +153,8 @@ extern void generate_lineno_debug (void);
 extern void s_abort (int) ATTRIBUTE_NORETURN;
 extern void s_align_bytes (int arg);
 extern void s_align_ptwo (int);
+extern void do_align (unsigned int align, char *fill, unsigned int length,
+		      unsigned int max);
 extern void bss_alloc (symbolS *, addressT, unsigned);
 extern offsetT parse_align (int);
 extern symbolS *s_comm_internal (int, symbolS *(*) (int, symbolS *, addressT));
-- 
2.1.4


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