From 612d7b83dd2280df7aa167e104fc809983efe16c Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 2 May 2003 02:46:36 +0000
Subject: [PATCH] gas/

2003-05-01  H.J. Lu <hjl@gnu.org>

	* config/tc-ia64.h (tc_canonicalize_section_name): New.

	* config/obj-elf.c (obj_elf_section_name): Call
	tc_canonicalize_section_name if it is defined.

gas/testsuite/

2003-05-01  H.J. Lu <hjl@gnu.org>

	* gas/ia64/ia64.exp: Add secname.

	* gas/ia64/secname.s: New. Test the trailing '#' in section
	name.
	* gas/ia64/secname.d: Likewise.
---
 gas/ChangeLog                    |  7 +++++++
 gas/config/obj-elf.c             |  3 +++
 gas/config/tc-ia64.h             |  1 +
 gas/testsuite/ChangeLog          |  8 ++++++++
 gas/testsuite/gas/ia64/ia64.exp  |  1 +
 gas/testsuite/gas/ia64/secname.d | 28 ++++++++++++++++++++++++++++
 gas/testsuite/gas/ia64/secname.s |  2 ++
 7 files changed, 50 insertions(+)
 create mode 100644 gas/testsuite/gas/ia64/secname.d
 create mode 100644 gas/testsuite/gas/ia64/secname.s

diff --git a/gas/ChangeLog b/gas/ChangeLog
index c868802c9c2..c609b0e4d00 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2003-05-01  H.J. Lu <hjl@gnu.org>
+
+	* config/tc-ia64.h (tc_canonicalize_section_name): New.
+
+	* config/obj-elf.c (obj_elf_section_name): Call
+	tc_canonicalize_section_name if it is defined.
+
 2003-05-01  H.J. Lu <hjl@gnu.org>
 
 	* config/tc-ia64.c (ia64_check_label): New.
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 7c2423c11bd..f61285aa417 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -940,6 +940,9 @@ obj_elf_section_name ()
       name = xmalloc (end - input_line_pointer + 1);
       memcpy (name, input_line_pointer, end - input_line_pointer);
       name[end - input_line_pointer] = '\0';
+#ifdef tc_canonicalize_section_name
+      name = tc_canonicalize_section_name (name);
+#endif
       input_line_pointer = end;
     }
   SKIP_WHITESPACE ();
diff --git a/gas/config/tc-ia64.h b/gas/config/tc-ia64.h
index b79cfcc899a..20940c08afe 100644
--- a/gas/config/tc-ia64.h
+++ b/gas/config/tc-ia64.h
@@ -114,6 +114,7 @@ extern void ia64_check_label PARAMS ((symbolS *));
 #define md_flush_pending_output()	ia64_flush_pending_output ()
 #define md_parse_name(s,e,c)		ia64_parse_name (s, e)
 #define tc_canonicalize_symbol_name(s)	ia64_canonicalize_symbol_name (s)
+#define tc_canonicalize_section_name(s)	ia64_canonicalize_symbol_name (s)
 #define md_optimize_expr(l,o,r)		ia64_optimize_expr (l, o, r)
 #define md_cons_align(n)		ia64_cons_align (n)
 #define TC_FORCE_RELOCATION(f)		ia64_force_relocation (f)
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 6399b505dd7..348d243106b 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2003-05-01  H.J. Lu <hjl@gnu.org>
+
+	* gas/ia64/ia64.exp: Add secname.
+
+	* gas/ia64/secname.s: New. Test the trailing '#' in section
+	name.
+	* gas/ia64/secname.d: Likewise.
+
 2003-05-01  H.J. Lu <hjl@gnu.org>
 
 	* gas/ia64/ia64.exp: Add "global".
diff --git a/gas/testsuite/gas/ia64/ia64.exp b/gas/testsuite/gas/ia64/ia64.exp
index 60e6a8e33f7..57c0e381cb1 100644
--- a/gas/testsuite/gas/ia64/ia64.exp
+++ b/gas/testsuite/gas/ia64/ia64.exp
@@ -46,4 +46,5 @@ if [istarget "ia64-*"] then {
     run_dump_test "align"
     run_dump_test "order"
     run_dump_test "global"
+    run_dump_test "secname"
 }
diff --git a/gas/testsuite/gas/ia64/secname.d b/gas/testsuite/gas/ia64/secname.d
new file mode 100644
index 00000000000..227a2ea8304
--- /dev/null
+++ b/gas/testsuite/gas/ia64/secname.d
@@ -0,0 +1,28 @@
+#readelf: -S
+#name: ia64 section name
+
+There are 8 section headers, starting at offset 0x80:
+
+Section Headers:
+  \[Nr\] Name              Type             Address           Offset
+       Size              EntSize          Flags  Link  Info  Align
+  \[ 0\]                   NULL             0000000000000000  00000000
+       0000000000000000  0000000000000000           0     0     0
+  \[ 1\] \.text             PROGBITS         0000000000000000  00000040
+       0000000000000000  0000000000000000  AX       0     0     16
+  \[ 2\] \.data             PROGBITS         0000000000000000  00000040
+       0000000000000000  0000000000000000  WA       0     0     1
+  \[ 3\] \.bss              NOBITS           0000000000000000  00000040
+       0000000000000000  0000000000000000  WA       0     0     1
+  \[ 4\] \.foo              PROGBITS         0000000000000000  00000040
+       0000000000000008  0000000000000000  WA       0     0     8
+  \[ 5\] \.shstrtab         STRTAB           0000000000000000  00000048
+       0000000000000031  0000000000000000           0     0     1
+  \[ 6\] \.symtab           SYMTAB           0000000000000000  00000280
+       0000000000000078  0000000000000018           7     5     8
+  \[ 7\] \.strtab           STRTAB           0000000000000000  000002f8
+       0000000000000001  0000000000000000           0     0     1
+Key to Flags:
+  W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\)
+  I \(info\), L \(link order\), G \(group\), x \(unknown\)
+  O \(extra OS processing required\) o \(OS specific\), p \(processor specific\)
diff --git a/gas/testsuite/gas/ia64/secname.s b/gas/testsuite/gas/ia64/secname.s
new file mode 100644
index 00000000000..42e21b6205a
--- /dev/null
+++ b/gas/testsuite/gas/ia64/secname.s
@@ -0,0 +1,2 @@
+	.section .foo#,"aw","progbits"
+	data8 1234