ELFObjectWriter: Don't de-duplicate STT_FILE symbols

This commit is contained in:
Fangrui Song 2021-02-07 18:21:36 -08:00
parent 09294642be
commit d3e13b58cd
3 changed files with 6 additions and 6 deletions

View File

@ -450,9 +450,6 @@ public:
}
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());
}

View File

@ -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.

View File

@ -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"