[llvm] d3e13b5 - ELFObjectWriter: Don't de-duplicate STT_FILE symbols
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 7 18:21:44 PST 2021
Author: Fangrui Song
Date: 2021-02-07T18:21:36-08:00
New Revision: d3e13b58cd083bb2c23d8addc4ae3c6238777867
URL: https://github.com/llvm/llvm-project/commit/d3e13b58cd083bb2c23d8addc4ae3c6238777867
DIFF: https://github.com/llvm/llvm-project/commit/d3e13b58cd083bb2c23d8addc4ae3c6238777867.diff
LOG: ELFObjectWriter: Don't de-duplicate STT_FILE symbols
Added:
Modified:
llvm/include/llvm/MC/MCAssembler.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/test/MC/ELF/file.s
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index cbda472d0bb5..63b8c4b63bcf 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -450,9 +450,6 @@ class MCAssembler {
}
void addFileName(StringRef FileName) {
- for (const std::pair<std::string, size_t> &F : FileNames)
- if (F.first == FileName)
- return;
FileNames.emplace_back(std::string(FileName), Symbols.size());
}
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index a21194f52da5..9257e3bff631 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -725,7 +725,6 @@ void ELFWriter::computeSymbolTable(
StrTabBuilder.finalize();
// Symbols are required to be in lexicographic order.
- //array_pod_sort(LocalSymbolData.begin(), LocalSymbolData.end());
array_pod_sort(ExternalSymbolData.begin(), ExternalSymbolData.end());
// Make the first STT_FILE precede previous local symbols.
diff --git a/llvm/test/MC/ELF/file.s b/llvm/test/MC/ELF/file.s
index 9ede62948cfb..e750762c9970 100644
--- a/llvm/test/MC/ELF/file.s
+++ b/llvm/test/MC/ELF/file.s
@@ -10,8 +10,9 @@
# CHECK-NEXT: 7: 0000000000000000 0 NOTYPE LOCAL DEFAULT 6 local1
# CHECK-NEXT: 8: 0000000000000000 0 SECTION LOCAL DEFAULT 8 bar1
# CHECK-NEXT: 9: 0000000000000000 0 NOTYPE LOCAL DEFAULT 8 local2
-# CHECK-NEXT: 10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 6 bar.c
-# CHECK-NEXT: 11: 0000000000000008 0 NOTYPE GLOBAL DEFAULT 2 foo.c
+# CHECK-NEXT: 10: 0000000000000000 0 FILE LOCAL DEFAULT ABS bar.c
+# CHECK-NEXT: 11: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 6 bar.c
+# CHECK-NEXT: 12: 0000000000000008 0 NOTYPE GLOBAL DEFAULT 2 foo.c
.quad .text
@@ -34,3 +35,6 @@ local1:
.section bar1,"a"
local2:
.quad bar1
+
+## STT_FILE symbols of the same name are not de-duplicated.
+.file "bar.c"
More information about the llvm-commits
mailing list