Remove i386_elf_emit_arch_note
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 1 May 2015 15:29:16 +0000 (08:29 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 1 May 2015 15:29:16 +0000 (08:29 -0700)
This x86 assembler patch:

https://sourceware.org/ml/binutils/2001-11/msg00344.html

generates a .note section for .arch directive so that GDB can tell which
architecture an i386 binary belongs:

https://sourceware.org/ml/binutils/2001-11/msg00271.html

However, x86 assembly code can have any instructions.  A .note section
doesn't help.  This patch removes it.

gas/

* config/tc-i386.c (i386_elf_emit_arch_note): Removed.
* config/tc-i386.h (md_end): Likewise.
(i386_elf_emit_arch_note): Likewise.

gas/testsuite/

* gas/i386/i386.exp: Run note.
* gas/i386/note.d: New file.
* gas/i386/note.s: Likewise.

gas/ChangeLog
gas/config/tc-i386.c
gas/config/tc-i386.h
gas/testsuite/ChangeLog
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/note.d [new file with mode: 0644]
gas/testsuite/gas/i386/note.s [new file with mode: 0644]

index e494ab1..8259f05 100644 (file)
@@ -1,5 +1,11 @@
 2015-05-01  H.J. Lu  <hongjiu.lu@intel.com>
 
+       * config/tc-i386.c (i386_elf_emit_arch_note): Removed.
+       * config/tc-i386.h (md_end): Likewise.
+       (i386_elf_emit_arch_note): Likewise.
+
+2015-05-01  H.J. Lu  <hongjiu.lu@intel.com>
+
        * configure.tgt: Support i386-*-elf*.
 
 2015-04-30  DJ Delorie  <dj@redhat.com>
index 4bcf416..50f9cb4 100644 (file)
@@ -10077,48 +10077,6 @@ i386_target_format (void)
 }
 
 #endif /* OBJ_MAYBE_ more than one  */
-
-#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF))
-void
-i386_elf_emit_arch_note (void)
-{
-  if (IS_ELF && cpu_arch_name != NULL)
-    {
-      char *p;
-      asection *seg = now_seg;
-      subsegT subseg = now_subseg;
-      Elf_Internal_Note i_note;
-      Elf_External_Note e_note;
-      asection *note_secp;
-      int len;
-
-      /* Create the .note section.  */
-      note_secp = subseg_new (".note", 0);
-      bfd_set_section_flags (stdoutput,
-                            note_secp,
-                            SEC_HAS_CONTENTS | SEC_READONLY);
-
-      /* Process the arch string.  */
-      len = strlen (cpu_arch_name);
-
-      i_note.namesz = len + 1;
-      i_note.descsz = 0;
-      i_note.type = NT_ARCH;
-      p = frag_more (sizeof (e_note.namesz));
-      md_number_to_chars (p, (valueT) i_note.namesz, sizeof (e_note.namesz));
-      p = frag_more (sizeof (e_note.descsz));
-      md_number_to_chars (p, (valueT) i_note.descsz, sizeof (e_note.descsz));
-      p = frag_more (sizeof (e_note.type));
-      md_number_to_chars (p, (valueT) i_note.type, sizeof (e_note.type));
-      p = frag_more (len + 1);
-      strcpy (p, cpu_arch_name);
-
-      frag_align (2, 0, 0);
-
-      subseg_set (seg, subseg);
-    }
-}
-#endif
 \f
 symbolS *
 md_undefined_symbol (char *name)
index f645754..deea9c2 100644 (file)
@@ -104,11 +104,6 @@ extern const char *i386_target_format (void);
 #endif
 #endif
 
-#if (defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF))
-#define md_end i386_elf_emit_arch_note
-extern void i386_elf_emit_arch_note (void);
-#endif
-
 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
 
 /* '$' may be used as immediate prefix.  */
index 6608a80..e1fda77 100644 (file)
@@ -1,3 +1,9 @@
+2015-05-01  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * gas/i386/i386.exp: Run note.
+       * gas/i386/note.d: New file.
+       * gas/i386/note.s: Likewise.
+
 2015-04-30  Nick Clifton  <nickc@redhat.com>
 
        PR gas/18347
index 26cb7ac..e1fdd18 100644 (file)
@@ -392,6 +392,8 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
        run_dump_test "size-2"
        run_dump_test "size-3"
        run_dump_test "size-4"
+
+       run_dump_test "note"
     }
 
     # This is a PE specific test.
diff --git a/gas/testsuite/gas/i386/note.d b/gas/testsuite/gas/i386/note.d
new file mode 100644 (file)
index 0000000..e7ad71d
--- /dev/null
@@ -0,0 +1,7 @@
+#as: -march=i686
+#readelf: -SW
+
+#failif
+#...
+[      ]*\[.*\][       ]+\.note[       ]+NOTE.*
+#...
diff --git a/gas/testsuite/gas/i386/note.s b/gas/testsuite/gas/i386/note.s
new file mode 100644 (file)
index 0000000..1ff7c29
--- /dev/null
@@ -0,0 +1,2 @@
+       .text
+       nop