PATCH: Add -n option to i386 assembler

H. J. Lu hjl@lucon.org
Mon Jun 9 17:10:00 GMT 2003


I should attach my patch.


H.J.
On Mon, Jun 09, 2003 at 10:07:39AM -0700, H. J. Lu wrote:
> The i386 assembler will always optimize code alignment. This patch
> adds a -n option to turn it off. I will check it in if there is no
> objection by tomorrow.
> 
> 
> H.J.
-------------- next part --------------
2003-06-09  H.J. Lu <hongjiu.lu@intel.com>

	* NEWS: Updated for the new -n option for the i386 assembler.

	* config/tc-i386.c (optimize_align_code): New.
	(md_shortopts): Add 'n'.
	(md_parse_option): Handle 'n'.
	(md_show_usage): Add '-n'.

	* config/tc-i386.h (optimize_align_code): Declared.
	(md_do_align): Optimize code alignment only if optimize_align_code
	is not 0.

	* doc/as.texinfo: Add the new -n option.

	* doc/c-i386.texi: Document the new -n option.

--- gas/NEWS.nop	2003-04-28 07:48:50.000000000 -0700
+++ gas/NEWS	2003-06-09 09:50:06.000000000 -0700
@@ -1,5 +1,8 @@
 -*- text -*-
 
+* A new command line option for the i386 assembler, -n,  will turn off
+  code alignment optimization.
+
 * Added support for MIPS32 Release 2.
 
 * Added support for Xtensa architecture.
--- gas/config/tc-i386.c.nop	2003-06-08 17:42:05.000000000 -0700
+++ gas/config/tc-i386.c	2003-06-09 09:46:45.000000000 -0700
@@ -303,6 +303,9 @@ static int allow_naked_reg = 0;
    frame as in 32 bit mode.  */
 static char stackop_size = '\0';
 
+/* Non-zero to optimize code alignment.  */
+int optimize_align_code = 1;
+
 /* Non-zero to quieten some warnings.  */
 static int quiet_warnings = 0;
 
@@ -4904,9 +4907,9 @@ parse_register (reg_string, end_op)
 }
 
 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-const char *md_shortopts = "kVQ:sq";
+const char *md_shortopts = "kVQ:sqn";
 #else
-const char *md_shortopts = "q";
+const char *md_shortopts = "qn";
 #endif
 
 struct option md_longopts[] = {
@@ -4927,6 +4930,10 @@ md_parse_option (c, arg)
 {
   switch (c)
     {
+    case 'n':
+      optimize_align_code = 0;
+      break;
+
     case 'q':
       quiet_warnings = 1;
       break;
@@ -4988,10 +4995,12 @@ md_show_usage (stream)
   -Q                      ignored\n\
   -V                      print assembler version number\n\
   -k                      ignored\n\
+  -n                      Do not optimize code alignment\n\
   -q                      quieten some warnings\n\
   -s                      ignored\n"));
 #else
   fprintf (stream, _("\
+  -n                      Do not optimize code alignment\n\
   -q                      quieten some warnings\n"));
 #endif
 }
--- gas/config/tc-i386.h.nop	2003-06-08 17:42:05.000000000 -0700
+++ gas/config/tc-i386.h	2003-06-09 09:46:14.000000000 -0700
@@ -517,9 +517,14 @@ extern int tc_i386_fix_adjustable PARAMS
 extern const struct relax_type md_relax_table[];
 #define TC_GENERIC_RELAX_TABLE md_relax_table
 
+extern int optimize_align_code;
+
 #define md_do_align(n, fill, len, max, around)				\
 if ((n) && !need_pass_2							\
-    && (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1))		\
+    && (!(fill)								\
+	|| (optimize_align_code						\
+	    && (char)*(fill) == (char)0x90				\
+	    && (len) == 1))						\
     && subseg_text_p (now_seg))						\
   {									\
     frag_align_code ((n), (max));					\
--- gas/doc/as.texinfo.nop	2003-06-08 17:41:37.000000000 -0700
+++ gas/doc/as.texinfo	2003-06-09 10:00:20.000000000 -0700
@@ -332,7 +332,7 @@ gcc(1), ld(1), and the Info entries for 
 @ifset I80386
 
 @emph{Target i386 options:}
-   [@b{--32}|@b{--64}]
+   [@b{--32}|@b{--64}] [@b{-n}]
 @end ifset
 @ifset I960
 
--- gas/doc/c-i386.texi.nop	2001-03-09 11:17:14.000000000 -0800
+++ gas/doc/c-i386.texi	2003-06-09 09:55:10.000000000 -0700
@@ -61,6 +61,10 @@ These options are only available with th
 require that the necessary BFD support has been included (on a 32-bit
 platform you have to add --enable-64-bit-bfd to configure enable 64-bit
 usage and use x86-64 as target platform).
+
+@item -n
+When this option is used, code alignment optimization will be turned
+off.
 @end table
 
 @node i386-Syntax


More information about the Binutils mailing list