ELF: don't re-order SHF_FILE symbols
authorJan Beulich <jbeulich@novell.com>
Tue, 8 Dec 2015 09:11:58 +0000 (10:11 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 8 Dec 2015 09:11:58 +0000 (10:11 +0100)
.file directives may be used to identify the scope of local symbols,
the purpose of which gets subverted when re-ordering them. Only allow
the first of them to be moved to the first position.

gas/ChangeLog
gas/config/obj-elf.c
gas/testsuite/ChangeLog
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/file-2.d [new file with mode: 0644]
gas/testsuite/gas/elf/file-2.s [new file with mode: 0644]
gas/testsuite/gas/elf/file.d
gas/testsuite/gas/i386/ilp32/elf/file.d

index 6fb81a1acaf94a5988d20e9ba731f16dee805132..53a618d503593fb8f6343be9c353c86711ad2a18 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-08  Jan Beulich  <jbeulich@suse.com>
+
+       * config/obj-elf.c (elf_file_symbol): Tighten condition for
+       moving BSF_FILE symbols.
+
 2015-12-08  DJ Delorie  <dj@redhat.com>
 
        * config/rl78-parse.y: Make all branches relaxable via
index 031fafb91b406872c83da9041721b627b35f7032..f930dc607beec6369a5c4f1eefc87cb21730d357 100644 (file)
@@ -282,14 +282,17 @@ elf_file_symbol (const char *s, int appfile)
 
       symbol_get_bfdsym (sym)->flags |= BSF_FILE;
 
-      if (symbol_rootP != sym)
+      if (symbol_rootP != sym
+         && (symbol_rootP->bsym == NULL
+             || !(symbol_rootP->bsym->flags & BSF_FILE)))
        {
          symbol_remove (sym, &symbol_rootP, &symbol_lastP);
          symbol_insert (sym, symbol_rootP, &symbol_rootP, &symbol_lastP);
+       }
+
 #ifdef DEBUG
-         verify_symbol_chain (symbol_rootP, symbol_lastP);
+      verify_symbol_chain (symbol_rootP, symbol_lastP);
 #endif
-       }
     }
 
 #ifdef NEED_ECOFF_DEBUG
index c514be7bb51942508971475ebe8cdfbb5e769cf0..bc524e94a27e7fa2536321e3724241f57e058ea0 100644 (file)
@@ -1,3 +1,10 @@
+2015-12-08  Jan Beulich  <jbeulich@suse.com>
+
+       * gas/elf/file-2.s, gas/elf/file-2.d: New.
+       * gas/elf/elf.exp: Run new test.
+       * gas/elf/file.d: Adjust expectations.
+       * gas/i386/ilp32/elf/file.d: Likewise.
+
 2015-12-04  Nick Clifton  <nickc@redhat.com>
 
        PR gas/19276
index fc81da1e4f3109f044cae16ff868129d5313c088..99292d72eb3b2de2b3eb19f5ee42d5b84a3c3031 100644 (file)
@@ -111,6 +111,7 @@ if { [is_elf_format] } then {
            run_dump_test "file"
        }
     }
+    run_dump_test "file-2"
     setup_xfail "nds32*-*-*"
     run_dump_test "group0a"
     run_dump_test "group0b"
diff --git a/gas/testsuite/gas/elf/file-2.d b/gas/testsuite/gas/elf/file-2.d
new file mode 100644 (file)
index 0000000..5da114c
--- /dev/null
@@ -0,0 +1,14 @@
+#objdump: -t
+#name: .file file names ordering
+
+.*: .*
+
+SYMBOL TABLE:
+0+ l[ ]*df \*ABS\*[    ]+0+ file-2\.s
+#...
+0+ l[ ]*\.text[        ]+0+ local1
+0+ l[ ]*df \*ABS\*[    ]+0+ aux-1\.s
+0+ l[ ]*\.text[        ]+0+ local2
+0+ l[ ]*df \*ABS\*[    ]+0+ aux-2\.s
+0+ l[ ]*\.text[        ]+0+ local3
+#pass
diff --git a/gas/testsuite/gas/elf/file-2.s b/gas/testsuite/gas/elf/file-2.s
new file mode 100644 (file)
index 0000000..4080034
--- /dev/null
@@ -0,0 +1,7 @@
+       .file "file-2.s"
+       .text
+local1:
+       .file "aux-1.s"
+local2:
+       .file "aux-2.s"
+local3:
index 1e981863549f91e62d010dd48fd31a1941fc7b8f..9b7bb4f1184c5227e625f8f4b9126c7537ac03a7 100644 (file)
@@ -4,15 +4,15 @@
 .*: .*
 
 SYMBOL TABLE:
+0+ l[ ]*df \*ABS\*[    ]+0+ ~tilde
 #...
-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
+0+ l[ ]*df \*ABS\*[    ]+0+ lower
+0+ l[ ]*df \*ABS\*[    ]+0+ UPPER
+0+ l[ ]*df \*ABS\*[    ]+0+ :colon
+0+ l[ ]*df \*ABS\*[    ]+0+ /dir/file\.s
+0+ l[ ]*df \*ABS\*[    ]+0+ \[brackets\]
+0+ l[ ]*df \*ABS\*[    ]+0+ \{braces\}
+0+ l[ ]*df \*ABS\*[    ]+0+ slash/data
+0+ l[ ]*df \*ABS\*[    ]+0+ file\.s
 #pass
index 9394c0c1759bd4fc9cfb50d16cdb88e45eb828e4..57c45d725990e7415f065977ee47dfb3bb3f90c1 100644 (file)
@@ -5,15 +5,15 @@
 .*: .*
 
 SYMBOL TABLE:
+0+ l[ ]*df \*ABS\*[    ]+0+ ~tilde
 #...
-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
+0+ l[ ]*df \*ABS\*[    ]+0+ lower
+0+ l[ ]*df \*ABS\*[    ]+0+ UPPER
+0+ l[ ]*df \*ABS\*[    ]+0+ :colon
+0+ l[ ]*df \*ABS\*[    ]+0+ /dir/file\.s
+0+ l[ ]*df \*ABS\*[    ]+0+ \[brackets\]
+0+ l[ ]*df \*ABS\*[    ]+0+ \{braces\}
+0+ l[ ]*df \*ABS\*[    ]+0+ slash/data
+0+ l[ ]*df \*ABS\*[    ]+0+ file\.s
 #pass