From owner-freebsd-toolchain@freebsd.org Mon Nov 20 01:09:56 2017 Return-Path: Delivered-To: freebsd-toolchain@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBF17DDC3E3 for ; Mon, 20 Nov 2017 01:09:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DA3F66A17E for ; Mon, 20 Nov 2017 01:09:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id vAK19uTe005035 for ; Mon, 20 Nov 2017 01:09:56 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-toolchain@FreeBSD.org Subject: [Bug 223752] clang __attribute__((constructor)) gets wrong input parameters Date: Mon, 20 Nov 2017 01:09:57 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: markmi@dsl-only.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-toolchain@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Nov 2017 01:09:57 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D223752 --- Comment #13 from Mark Millard --- (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.=