Skip to content

Commit aabcdc9

Browse files
committed
Don't provide a default _start symbol for entry point
This was a nonstandard experiment, to get rid of: warning: cannot find entry symbol _start; defaulting to 000000a0 when gcc -nostartfiles was used. Traditionally, when no entry point is specified, the .text section of the first object on the ld command-line is used as entry. This is generally what is expected. But this behaviour is defeated on ELF targets, where the linker script is more complex. For example, the .text.startup sections are linked before .text sections. If a C source file contains a function named main() and is compiled with -O2, gcc automatically puts it into the .text.startup section. If the user provided a custom startup code and put it first on the ld command-line, that will be defeated because main() will actually be linked first, before the startup code. This is what happened with the gemma sample programs. They crashed on exit, at the end of main() as there was no actual startup code. This explains why that situation is dangerous, and why that standard warning is useful. So I enabled it again, like standard ELF. The easy fix to get rid of that warning is simply to add a global _start label at the beginning of the custom startup code. That will work in any case, whereever the startup code will actually be located.
1 parent ce49a63 commit aabcdc9

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

ld/scripttempl/m68kmintelf.sc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ SECTIONS
4343
/* Program code. */
4444
.text :
4545
{
46-
PROVIDE(_start = .); /* Default entry point if _start isn't defined. */
4746
*crt0.o(.text .text.*)
4847
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
4948
*(.text.exit .text.exit.*)

0 commit comments

Comments
 (0)