[Bug 223752] clang __attribute__((constructor)) gets wrong input parameters
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sun Nov 19 15:52:44 UTC 2017
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223752
dstaesse <dimitri.staessens at ugent.be> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dimitri.staessens at ugent.be
--- Comment #1 from dstaesse <dimitri.staessens at ugent.be> ---
Created attachment 188120
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=188120&action=edit
main program code
Sorry, pushed submit too early.
I find that the argc and argv values that are passed to a shared library
constructor for a library that is compiled using clang fails. I get the same
result using FreeBSD 11.0-RELEASE, 11.1-RELEASE and 12-CURRENT
When compiling the attached code using
$clang -c -fPIC attrconst.c
$clang -shared -o libattrconst.so attrconst.o
$clang -L . main.c -lattrconst -o test
and executing (bash)
$LD_LIBRARY_PATH=. ./test
I get:
Initializing library.
Got 3 params.
argv[0] is (null).
Running the test.
Finalizing library.
Which is not what I was expecting.
Compiling the library using gcc, gives the correct result:
$gcc -c -fPIC attrconst.c
$gcc -shared -o libattrconst.so attrconst.o
$gcc -L . main.c -lattrconst -o test
$LD_LIBRARY_PATH=. ./test
Initializing library.
Got 1 params.
argv[0] is ./test.
Running the test.
Finalizing library.
Could this be a bug in clang?
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list