-
Notifications
You must be signed in to change notification settings - Fork 15
cannot find entry symbol _start #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
lld/ELF/Writer.cpp: // The entry point address is chosen in the following ways.
//
// 1. the '-e' entry command-line option;
// 2. the ENTRY(symbol) command in a linker control script;
// 3. the value of the symbol _start, if present;
// 4. the number represented by the entry symbol, if it is a number;
// 5. the address of the first byte of the .text section, if present;
// 6. the address 0.
static uint64_t getEntryAddr() {
// Case 1, 2 or 3
if (Symbol *B = Symtab->find(Config->Entry))
return B->getVA();
// Case 4
uint64_t Addr;
if (to_integer(Config->Entry, Addr))
return Addr;
// Case 5
if (OutputSection *Sec = findSection(".text")) {
if (Config->WarnMissingEntry)
warn("cannot find entry symbol " + Config->Entry + "; defaulting to 0x" +
utohexstr(Sec->Addr));
return Sec->Addr;
}
// Case 6
if (Config->WarnMissingEntry)
warn("cannot find entry symbol " + Config->Entry +
"; not setting start address");
return 0;
} So I assume the kernel does one of the above for arm64, which is why we don't see this warning there. Maybe we just need to do that for x86_64 as well? Or just disable the warning if the resulting code is still correct. |
$ nm vmlinux | grep 'T _start$'
$ readelf -t vmlinux | grep text
[ 1] .text
PROGBITS PROGBITS ffffffff81000000 0000000000200000 0
0000000000e01941 0000000000000000 0 4096
[0000000000000006]: ALLOC, EXEC So maybe just best to disable the warning? lld/ELF/Driver.cpp has: Config->WarnMissingEntry =
(!Config->Entry.empty() || (!Config->Shared && !Config->Relocatable)); but I'm not sure how to set
cc @rui314 @GeorgiiR |
Is it possible to get the LLD --reproduce file for this? (Actually, we use the getEntryAddr() value for ELF file header: |
I guess this needs an addition of UPDATE: This did not work. |
By the way, I can still reproduce this warning with -O2, linux-next-next-20190730, clang version 10.0.0 (366783) and lld. For the config and buildlog see #623 |
Still occurs with kernel 5.3.1 and LLVM/clang-9.0.0 on x86_64
|
arch/x86/realmode/rm/Makefile:
Sounds like maybe an $ make CC=clang -j71 defconfig
$ make CC=clang -j71
$ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry
Entry point address: 0x1000 |
Linking with ld.lld via $ make LD=ld.lld produces the warning: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x1000 Linking with ld.bfd shows the default entry is 0x1000: $ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry Entry point address: 0x1000 While ld.lld is being pedantic, just set the entry point explicitly, instead of depending on the implicit default. Link: ClangBuiltLinux#216 Signed-off-by: Nick Desaulniers <[email protected]>
Linking with ld.lld via $ make LD=ld.lld produces the warning: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x1000 Linking with ld.bfd shows the default entry is 0x1000: $ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry Entry point address: 0x1000 While ld.lld is being pedantic, just set the entry point explicitly, instead of depending on the implicit default. The symbol pa_text_start refers to the start of the .text section, which may not be at 0x1000 if the preceding sections listed in arch/x86/realmode/rm/realmode.lds.S were large enough. This matches behavior in arch/x86/boot/setup.ld. Reported-by: Sedat Dilek <[email protected]> Suggested-by: Borislav Petkov <[email protected]> Suggested-by: Peter Smith <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux/linux#216 (cherry picked from commit 6a181e3) Signed-off-by: Nathan Chancellor <[email protected]>
Linking with ld.lld via $ make LD=ld.lld produces the warning: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x1000 Linking with ld.bfd shows the default entry is 0x1000: $ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry Entry point address: 0x1000 While ld.lld is being pedantic, just set the entry point explicitly, instead of depending on the implicit default. The symbol pa_text_start refers to the start of the .text section, which may not be at 0x1000 if the preceding sections listed in arch/x86/realmode/rm/realmode.lds.S were large enough. This matches behavior in arch/x86/boot/setup.ld. Reported-by: Sedat Dilek <[email protected]> Suggested-by: Borislav Petkov <[email protected]> Suggested-by: Peter Smith <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux/linux#216 (cherry picked from commit 6a181e3) Signed-off-by: Nathan Chancellor <[email protected]>
Linking with ld.lld via $ make LD=ld.lld produces the warning: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x1000 Linking with ld.bfd shows the default entry is 0x1000: $ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry Entry point address: 0x1000 While ld.lld is being pedantic, just set the entry point explicitly, instead of depending on the implicit default. The symbol pa_text_start refers to the start of the .text section, which may not be at 0x1000 if the preceding sections listed in arch/x86/realmode/rm/realmode.lds.S were large enough. This matches behavior in arch/x86/boot/setup.ld. Reported-by: Sedat Dilek <[email protected]> Suggested-by: Borislav Petkov <[email protected]> Suggested-by: Peter Smith <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux/linux#216 (cherry picked from commit 6a181e333954a26f46596b36f82abd14743570fd) Signed-off-by: Nathan Chancellor <[email protected]>
Linking with ld.lld via $ make LD=ld.lld produces the warning: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x1000 Linking with ld.bfd shows the default entry is 0x1000: $ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry Entry point address: 0x1000 While ld.lld is being pedantic, just set the entry point explicitly, instead of depending on the implicit default. The symbol pa_text_start refers to the start of the .text section, which may not be at 0x1000 if the preceding sections listed in arch/x86/realmode/rm/realmode.lds.S were large enough. This matches behavior in arch/x86/boot/setup.ld. Reported-by: Sedat Dilek <[email protected]> Suggested-by: Borislav Petkov <[email protected]> Suggested-by: Peter Smith <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux/linux#216 (cherry picked from commit 6a181e333954a26f46596b36f82abd14743570fd) Signed-off-by: Nathan Chancellor <[email protected]>
Linking with ld.lld via $ make LD=ld.lld produces the warning: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x1000 Linking with ld.bfd shows the default entry is 0x1000: $ readelf -h arch/x86/realmode/rm/realmode.elf | grep Entry Entry point address: 0x1000 While ld.lld is being pedantic, just set the entry point explicitly, instead of depending on the implicit default. The symbol pa_text_start refers to the start of the .text section, which may not be at 0x1000 if the preceding sections listed in arch/x86/realmode/rm/realmode.lds.S were large enough. This matches behavior in arch/x86/boot/setup.ld. Reported-by: Sedat Dilek <[email protected]> Suggested-by: Borislav Petkov <[email protected]> Suggested-by: Peter Smith <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: ClangBuiltLinux/linux#216 (cherry picked from commit 6a181e3) Signed-off-by: Nathan Chancellor <[email protected]>
I suspect this needs to be backported to 5.4, and 4.19 at least. |
This is with a few workarounds in place to link with LLD, so I wouldn't be surprise if once they're fixed, this quickly becomes unreproducible.
The text was updated successfully, but these errors were encountered: