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] elf: don't modify file names used with .file/.appfile


Dating back to a discussion in late 2005, this patch stops ELF STT_FILE
symbols to get their symbol name (which is actually a file name)
screwed up by tc_canonicalize_symbol_name().

gas/
2009-07-24  Jan Beulich  <jbeulich@novell.com>

	* obj-elf.c (elf_file_symbol): Replace symbol name set up by
	symbol_new() with the passed in, unmodified one.

gas/testsuite/
2009-07-24  Jan Beulich  <jbeulich@novell.com>

	* gas/elf/file.[ds]: New.
	* gas/elf/elf.exp: Run new test.

--- 2009-07-24/gas/config/obj-elf.c	2009-07-23 15:06:32.000000000 +0200
+++ 2009-07-24/gas/config/obj-elf.c	2009-07-24 10:18:46.000000000 +0200
@@ -260,9 +260,20 @@ elf_file_symbol (const char *s, int appf
       || (symbol_rootP->bsym->flags & BSF_FILE) == 0)
     {
       symbolS *sym;
+      unsigned int name_length;
 
       sym = symbol_new (s, absolute_section, 0, NULL);
       symbol_set_frag (sym, &zero_address_frag);
+
+      name_length = strlen (s);
+      if (name_length > strlen (S_GET_NAME (sym)))
+	{
+	  obstack_grow (&notes, s, name_length + 1);
+	  S_SET_NAME (sym, obstack_finish (&notes));
+	}
+      else
+	strcpy ((char *)S_GET_NAME (sym), s);
+
       symbol_get_bfdsym (sym)->flags |= BSF_FILE;
 
       if (symbol_rootP != sym)
--- 2009-07-24/gas/testsuite/gas/elf/elf.exp	2009-07-03 10:05:27.000000000 +0200
+++ 2009-07-24/gas/testsuite/gas/elf/elf.exp	2009-07-24 10:18:46.000000000 +0200
@@ -82,6 +82,20 @@ if { ([istarget "*-*-*elf*"]		
 	&& ![istarget "am3*-*-*"]} then {    
       run_dump_test "ehopt0"
     }
+    case $target_triplet in {
+	{ m68k-*-* m68[03]??-*-* } {
+	    run_dump_test "file" { { as "--defsym m68k=1" } }
+	}
+	{ mmix-*-* } {
+	    run_dump_test "file" { { as "--defsym mmix=1" } }
+	}
+	{ xtensa*-*-* } {
+	    run_dump_test "file" { { as "--rename-section file.s=file.c" } }
+	}
+	default {
+	    run_dump_test "file"
+	}
+    }
     run_dump_test "group0a" 
     run_dump_test "group0b" 
     run_dump_test "group1a" 
--- 2009-07-24/gas/testsuite/gas/elf/file.d	1970-01-01 01:00:00.000000000 +0100
+++ 2009-07-24/gas/testsuite/gas/elf/file.d	2009-07-24 13:32:06.000000000 +0200
@@ -0,0 +1,18 @@
+#objdump: -t
+#name: .file file names
+
+.*: .*
+
+SYMBOL TABLE:
+#...
+0+ l[ ]*df \*ABS\*[ 	]+0+ file\.s
+0+ l[ ]*df \*ABS\*[ 	]+0+ slash/data
+0+ l[ ]*df \*ABS\*[ 	]+0+ \{braces\}
+0+ l[ ]*df \*ABS\*[ 	]+0+ \[brackets\]
+0+ l[ ]*df \*ABS\*[ 	]+0+ /dir/file\.s
+0+ l[ ]*df \*ABS\*[ 	]+0+ :colon
+0+ l[ ]*df \*ABS\*[ 	]+0+ UPPER
+0+ l[ ]*df \*ABS\*[ 	]+0+ lower
+0+ l[ ]*df \*ABS\*[ 	]+0+ hash\#
+0+ l[ ]*df \*ABS\*[ 	]+0+ ~tilde
+#pass
--- 2009-07-24/gas/testsuite/gas/elf/file.s	1970-01-01 01:00:00.000000000 +0100
+++ 2009-07-24/gas/testsuite/gas/elf/file.s	2009-07-21 11:00:44.000000000 +0200
@@ -0,0 +1,29 @@
+	# delta (m68k sub-target)
+	.file "~tilde"
+
+	# ia64
+	.file "hash#"
+
+	# m68k
+	.ifdef m86k
+	.opt nocase
+	.endif
+	.file "lower"
+	.file "UPPER"
+
+	# mmix
+	.file ":colon"
+	.ifdef mmix
+	.prefix prefix
+	.endif
+	.file "/dir/file.s"
+
+	# ppc/xcoff
+	.file "[brackets]"
+	.file "{braces}"
+
+	# thumb (arm sub-target)
+	.file "slash/data"
+
+	# xtensa (through --rename-section file.s=file.c)
+	.file "file.s"




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