Skip to content

Commit

Permalink
[ELF] Set file for synthesized _binary_ symbols
Browse files Browse the repository at this point in the history
Ensure the property that non-null `section` implies non-null `file`.
  • Loading branch information
MaskRay committed Nov 6, 2023
1 parent f2d8a0a commit 339f5f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lld/ELF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,15 +1769,15 @@ void BinaryFile::parse() {

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

symtab.addAndCheckDuplicate(Defined{nullptr, saver.save(s + "_start"),
symtab.addAndCheckDuplicate(Defined{this, saver.save(s + "_start"),
STB_GLOBAL, STV_DEFAULT, STT_OBJECT, 0, 0,
section});
symtab.addAndCheckDuplicate(Defined{nullptr, saver.save(s + "_end"),
STB_GLOBAL, STV_DEFAULT, STT_OBJECT,
data.size(), 0, section});
symtab.addAndCheckDuplicate(Defined{nullptr, saver.save(s + "_size"),
STB_GLOBAL, STV_DEFAULT, STT_OBJECT,
data.size(), 0, nullptr});
symtab.addAndCheckDuplicate(Defined{this, saver.save(s + "_end"), STB_GLOBAL,
STV_DEFAULT, STT_OBJECT, data.size(), 0,
section});
symtab.addAndCheckDuplicate(Defined{this, saver.save(s + "_size"), STB_GLOBAL,
STV_DEFAULT, STT_OBJECT, data.size(), 0,
nullptr});
}

ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/duplicated-synthetic-sym.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

.globl _binary_file_bin_start
_binary_file_bin_start:
Expand Down

0 comments on commit 339f5f7

Please sign in to comment.