Skip to content

Commit 339f5f7

Browse files
committed
[ELF] Set file for synthesized _binary_ symbols
Ensure the property that non-null `section` implies non-null `file`.
1 parent f2d8a0a commit 339f5f7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,15 +1769,15 @@ void BinaryFile::parse() {
17691769

17701770
llvm::StringSaver &saver = lld::saver();
17711771

1772-
symtab.addAndCheckDuplicate(Defined{nullptr, saver.save(s + "_start"),
1772+
symtab.addAndCheckDuplicate(Defined{this, saver.save(s + "_start"),
17731773
STB_GLOBAL, STV_DEFAULT, STT_OBJECT, 0, 0,
17741774
section});
1775-
symtab.addAndCheckDuplicate(Defined{nullptr, saver.save(s + "_end"),
1776-
STB_GLOBAL, STV_DEFAULT, STT_OBJECT,
1777-
data.size(), 0, section});
1778-
symtab.addAndCheckDuplicate(Defined{nullptr, saver.save(s + "_size"),
1779-
STB_GLOBAL, STV_DEFAULT, STT_OBJECT,
1780-
data.size(), 0, nullptr});
1775+
symtab.addAndCheckDuplicate(Defined{this, saver.save(s + "_end"), STB_GLOBAL,
1776+
STV_DEFAULT, STT_OBJECT, data.size(), 0,
1777+
section});
1778+
symtab.addAndCheckDuplicate(Defined{this, saver.save(s + "_size"), STB_GLOBAL,
1779+
STV_DEFAULT, STT_OBJECT, data.size(), 0,
1780+
nullptr});
17811781
}
17821782

17831783
ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,

lld/test/ELF/duplicated-synthetic-sym.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// CHECK: duplicate symbol: _binary_file_bin_start
1212
// CHECK-NEXT: defined in {{.*}}.o
13-
// CHECK-NEXT: defined in <internal>
13+
// CHECK-NEXT: defined in file.bin
1414

1515
.globl _binary_file_bin_start
1616
_binary_file_bin_start:

0 commit comments

Comments
 (0)