Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Nov 2017 01:09:57 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-toolchain@FreeBSD.org
Subject:   [Bug 223752] clang __attribute__((constructor)) gets wrong input parameters
Message-ID:  <bug-223752-29464-SpmQ9oefrE@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-223752-29464@https.bugs.freebsd.org/bugzilla/>
References:  <bug-223752-29464@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D223752

--- Comment #13 from Mark Millard <markmi@dsl-only.net> ---
(In reply to dstaesse from comment #10)

The materials that you have referenced
indicate that __attribute__ ((constructor))
gets no arguments. Details follow.

>From the materials you referenced:

QUOTE
The .preinit_array and .init_array sections must contain function pointers =
(NOT
code!) The prototype of these functions must be
void func(int argc,char** argv,char** envp)
__libc_csu_init execute them in the following order:
Function pointers in .preinit_array section
Functions marked as __attribute__ ((constructor)), via _init
Function pointers in .init_array section
END QUOTE

Note that __attribute__ ((constructor)) is not for the
*init_array usage, just for usage inside _init .

And from the elf-init.c that you listed:

#ifndef NO_INITFINI
  _init ();
#endif

has no arguments.

So, __attribute__ ((constructor)) routines are called
form a context not explicitly having the erguments
available.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-223752-29464-SpmQ9oefrE>