1

I want to specify the entry point to my ELF file using the linker script. I already defined some sections in my ELF, so want to set an entry point also withit. Can anyone tell me how to do it?

vimal prathap
  • 371
  • 4
  • 16

3 Answers3

3

There's a special (GNU) linker script command that sets entry point to given symbol's address ENTRY(symbol). Refer to official documentation.

Werkov
  • 586
  • 4
  • 12
0

First get the current linker script to a file with:

ld --verbose a.o | sed '/======/,/======/!d;//d' > myscript

Here we filtered the lines between =====, as mentioned at: How to select lines between two marker patterns which may occur multiple times with awk/sed

Then edit the ENTRY(_start) line to your desired symbol.

Finally use -T to select the custom script:

ld --verbose -T myscript a.o
Community
  • 1
  • 1
0

Looks like the command line argument -e entryName is the way to go about it. A man ld should give you a heads up as well.

CTS_AE
  • 10,343
  • 7
  • 50
  • 55