This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: passing argument to __attribute__((constructor))
- From: Nick Clifton <nickc at redhat dot com>
- To: Yubin Ruan <ablacktshirt at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 1 Aug 2017 09:59:10 +0100
- Subject: Re: passing argument to __attribute__((constructor))
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=nickc at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 65F1D14F4DC
- References: <CAJYFCiNgDCt20+tyMpA_eYLxoMmYM-1vwJkQQiW48Va=pWHmAg@mail.gmail.com>
Hi Yubin,
> I am wondering whether one can pass arguments to
> __attribute__((constructor)).
Short answer: no.
Long answer: Not via the parameters to the function. But you
could store the arguments in global variables and access them
from inside the function.
Cheers
Nick
PS. This is really a GCC question, not a binutils question...