Hello, someone came into a programming support channel with the classic
cannot find _start defaulting to blah warning, so we assumed the obvious,
but after looking, the .o he's providing as input does infact have a _start
symbol, ld just can't "see" it.
I inspected it with a hex editor, the elf looks fine, I made a quick linker
script
ENTRY(_start)
SECTIONS
{
. = 100000;
.data : { * (.data); }
.text : { * (.text); }
}
_start has offset 0xA into .text, data is 0x10 long, so _start should be at
0x10001A.
This produces the warning: ld: warning: cannot find entry symbol _start;
defaulting to 0000000000100010.
I figured this was ld failing and doing something weird, but readelf on the
produced output is even more weird:
5: 000000000010001a 0 NOTYPE GLOBAL DEFAULT 2 _start
This is the correct address afterall (so why the warning?), but then:
6: 0000000000000000 NOTYPE GLOBAL DEFAULT UND _start
ld injected another broken _start, because of the warning being triggered?
Example elf files:
https://coldplace.net/basm.o
https://coldplace.net/basm_start_moved.o
https://coldplace.net/basm_text_moved.o
(I had him move the things around incase ld was exploding from all the 0
fields everywhere).