Map .data.rel.ro correctly.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 19 Sep 2016 19:59:21 +0000 (19:59 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 19 Sep 2016 19:59:21 +0000 (19:59 +0000)
An input section named .data.rel.ro now maps to an output section
named .data.rel.ro. Before we were mapping it to .data.

llvm-svn: 281931

lld/ELF/Writer.cpp
lld/test/ELF/section-name.s

index f17f106..f8b6323 100644 (file)
@@ -90,11 +90,14 @@ private:
 template <class ELFT>
 StringRef elf::getOutputSectionName(InputSectionBase<ELFT> *S) {
   StringRef Name = S->Name;
-  for (StringRef V : {".text.", ".rodata.", ".data.rel.ro.", ".data.", ".bss.",
-                      ".init_array.", ".fini_array.", ".ctors.", ".dtors.",
-                      ".tbss.", ".gcc_except_table.", ".tdata.", ".ARM.exidx."})
-    if (Name.startswith(V))
-      return V.drop_back();
+  for (StringRef V :
+       {".text.", ".rodata.", ".data.rel.ro.", ".data.", ".bss.",
+        ".init_array.", ".fini_array.", ".ctors.", ".dtors.", ".tbss.",
+        ".gcc_except_table.", ".tdata.", ".ARM.exidx."}) {
+    StringRef Prefix = V.drop_back();
+    if (Name.startswith(V) || Name == Prefix)
+      return Prefix;
+  }
   return Name;
 }
 
index 93cab7e..8274dc6 100644 (file)
@@ -47,8 +47,8 @@ _start:
 // CHECK:  3 .text         00000002
 // CHECK:  4 .tdata        00000001
 // CHECK:  5 .tbss         00000001
-// CHECK:  6 .data.rel.ro  00000003
-// CHECK:  7 .data         00000003
+// CHECK:  6 .data.rel.ro  00000004
+// CHECK:  7 .data         00000002
 // CHECK:  8 .foo.a        00000001
 // CHECK:  9 .foo          00000001
 // CHECK: 10 .bss          00000001