This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: to exec a shared object


Henry Thor Baldursson <henry@f-prot.com> writes:

> The issue I raised with much humility, mind you, was whether it was
> proper behaviour of the linker to define an entrypoint when the
> programmer never intended for there to be one. And for the sake of
> argument whether it would not be better behaviour for the execve syscall
> to return that unused ELIBEXEC macro on ET_DYN objects without
> entrypoints. The current behaviour that the call results in a segfault
> isn't very descriptive. Though I must admit, I am not sure why the
> dynamic loader tries to execute at address 1.

Thank you for pointing out your humility.

Yes, because GNU/Linux is willing and able to execute shared
libraries, I believe it is correct for the linker to define an entry
point by default.

You can of course set the entry point to whatever you like, using the
-e option.  For example, you can use -e 0 to set the entry point to 0,
or -e -1 to set the entry point to -1.

I think it would be quite reasonable for the kernel to check the entry
point address and return an appropriate error.  I'm not sure that
execve should return ELIBEXEC, since execve is a POSIX.1 call and
should presumably return the error codes mandated by POSIX.  In any
case, that is an issue to raise with the kernel developers, or, if you
want to change the dynamic linker, with the glibc developers.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]