another question

mdf at FreeBSD.org mdf at FreeBSD.org
Tue Jul 2 03:25:47 UTC 2013


On Mon, Jul 1, 2013 at 5:42 PM, David Sanford
<david.lee.tn at programmer.net>wrote:

> Hi,
>
> Thanks for your responses to my first question. They were very helpful.
>
> In looking at the code, I ran across the functions setprogname and
> getprogname. According to the man page:
> In FreeBSD, the name of the program is set by the start-up code that is
> run before  *main*(); thus, running  *setprogname*() is not necessary.
> I'm confused by how this is done. Where is this "start-up code" defined?
> Is this included in all executables compiled on FreeBSD? Even the programs
> released under the GNU GPL?


I believe the code that does this is in lib/csu/common/ignore_init.c; see
handle_argv() and the use of __progname[].

This will run for anything that links against csu, which is anything
compiled on FreeBSD.  The same csu library sets the ABI note.tag, which
tells the kernel which syscall table to use when the binary is executed.

Cheers,
matthew


More information about the freebsd-hackers mailing list