-e entry --entry=entry Use entry as the explicit symbol for beginning execution of your program, rather than the default entry point. If there is no symbol named entry, the linker will try to parse entry as a number, and use that as the entry address (the number will be interpreted in base 10; you may use a leading 0x for base 16, or a leading 0 for base 8). If the option is specified, and there is no symbol with the given name, and it is not a hex value, ld should issue an error. Instead it defaults to the first instruction without any message. If you forget ".globl" on _start, for instance, the program will start somewhere unexpected.
Hi Daniel, Do you have a test case that reproduces this problem ? I tried the following: % cat fred.s .global foo .global bar foo: nop bar: nop % as fred.s -o fred.o % ld -e does-not-exist fred.o ld: warning: cannot find entry symbol does-not-exist; defaulting to 0000000000008000 ie a warning message *was* produced. This was with an arm-eabi toolchain built from today's sources on a 64-bit host, so maybe one of these factors is connected with the generation of the warning message. Cheers Nick
Oops, the message is only suppressed for -shared. I was building an executable shared library. Does entry_symbol.name get set from both the default linker script and the command line? Not warning with -shared and ENTRY is probably appropriate, since all the existing -shared linker scripts have an ENTRY and most shared libraries are executable.
Hi Daniel, > Does entry_symbol.name get set from both the default linker script and the > command line? Yes. See ld/ldlang.c:lang_add_entry(). It has a parameter which tells it whether the symbol is being set from a linker script (default or otherwise) or from the command line. The command line takes precedence. > Not warning with -shared and ENTRY is probably appropriate, since > all the existing -shared linker scripts have an ENTRY and most shared > libraries are executable. Agreed. Cheers Nick
Sorry, that's not what I meant. -shared, ENTRY, and not found is valid not to warn. -shared, -e, and not found is different. What do you think of this? if (link_info.relocatable || link_info.shared) - warn = FALSE; + warn = entry_from_cmdline; else
Hi Daniel, Sorry for being so dense! Yes your patch will work and I have checked it in along with this ChangeLog entry. OK to close this PR now ? :-) Cheers Nick ld/ChangeLog 2008-01-10 Daniel Jacobowitz <drow@sources.redhat.com> PR ld/5533 * ldlang.c (lang_end): Issue a warning for a missing start symbol of a shared library if the symbol was specified on the command line.
Thanks!