/// absolute symbols
template<class ELFT>
void ELFExecutableWriter<ELFT>::addDefaultAtoms() {
- _runtimeFile.addUndefinedAtom("_start");
+ _runtimeFile.addUndefinedAtom(_targetInfo.getEntry());
_runtimeFile.addAbsoluteAtom("__bss_start");
_runtimeFile.addAbsoluteAtom("__bss_end");
_runtimeFile.addAbsoluteAtom("_end");
_elfHeader->e_shnum(_shdrtab->numHeaders());
_elfHeader->e_shstrndx(_shstrtab->ordinal());
uint64_t virtualAddr = 0;
- _layout->findAtomAddrByName("_start", virtualAddr);
+ _layout->findAtomAddrByName(_targetInfo.getEntry(), virtualAddr);
_elfHeader->e_entry(virtualAddr);
// HACK: We have to write out the header and program header here even though
--- /dev/null
+# Tests entry point handling
+#
+# Test generated using the source file below:
+#
+# int main()
+# {
+# return 0;
+# }
+#
+
+# RUN: lld-core -reader YAML %s -writer ELF --entry=_entrypoint -o %t1
+# RUN: llvm-nm -n %t1 | FileCheck %s
+#
+# CHECK: 000000a0 T main
+# CHECK: 00001000 A _end
+# CHECK: 00001000 A end
+# CHECK: w _entrypoint
+
+defined-atoms:
+ - name: .text
+ alignment: 2^4
+ section-choice: custom-required
+ section-name: .text
+ - name: main
+ scope: global
+ content: [ B8, 00, 00, 00, 00, C7, 44, 24, FC, 00, 00, 00,
+ 00, C3 ]
+ alignment: 2^4
+ section-choice: custom-required
+ section-name: .text
+ - name: .data
+ type: data
+ alignment: 2^2
+ section-choice: custom-required
+ section-name: .data
+ - name: .bss
+ type: zero-fill
+ alignment: 2^2
+ section-choice: custom-required
+ section-name: .bss
+ - name: .note.GNU-stack
+ section-choice: custom-required
+ section-name: .note.GNU-stack
+ permissions: r--
+ - name: .eh_frame
+ content: [ 14, 00, 00, 00, 00, 00, 00, 00, 01, 7A, 52, 00,
+ 01, 78, 10, 01, 1B, 0C, 07, 08, 90, 01, 00, 00,
+ 14, 00, 00, 00, 1C, 00, 00, 00, 00, 00, 00, 00,
+ 0E, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 ]
+ alignment: 2^3
+ section-choice: custom-required
+ section-name: .eh_frame
+ permissions: r--
+ references:
+ - kind: call32
+ offset: 32
+ target: .text
cmdLineGlobalsNotDeadStrip("keep-globals",
llvm::cl::desc("All global symbols are roots for dead-strip"));
+llvm::cl::opt<std::string>
+cmdLineEntryPoint("entry",
+ llvm::cl::desc("Specify entry point symbol"),
+ llvm::cl::value_desc("symbol"));
+
enum WriteChoice {
writeYAML, writeMachO, writePECOFF, writeELF
lo._globalsAreDeadStripRoots = cmdLineGlobalsNotDeadStrip;
lo._forceLoadArchives = cmdLineForceLoad;
lo._outputKind = OutputKind::Executable;
+ lo._entrySymbol = cmdLineEntryPoint;
switch (archSelected) {
case i386: