[Bug 5870] New: argv and argc not passed to C constructor

bugzilla at busybox.net bugzilla at busybox.net
Tue Jan 15 08:30:54 UTC 2013


https://bugs.busybox.net/show_bug.cgi?id=5870

           Summary: argv and argc not passed to C constructor
           Product: uClibc
           Version: 0.9.33
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
        AssignedTo: unassigned at uclibc.org
        ReportedBy: martin.assarsson at tiunda.com
                CC: uclibc-cvs at uclibc.org
   Estimated Hours: 0.0


When using constructor methods they do not get argv and argc.
Following code extract is working on standard glibc, but gives coredump on
uClibc.
Untill fixed I will use /proc/self/cmdline.

Example:
static void program_environment(int argc, char **argv, char **envp)
__attribute__ ((constructor (100)));

static void program_environment(int argc, char **argv, char **envp) 
{
    int c;
    static struct option long_options[] = {
        {"help", 0, 0, 'h'},
        {"version", 0, 0, 'v'},
        {0, 0, 0, 0}
    };

    opterr = 0;
    optind = 0;

    while (1)
    {
        int option_index = 0;

        c = getopt_long(argc, argv, arguments, long_options, &option_index);

        if (c == -1) break;

        switch (c) {
        case 'h':
            program_help = true;
            break;
        case 'v':
            program_version = true;
            exit ( 0 );
        default:
            break;
        }
    }
}

int main(int argc, char **argv, char **envp) 
{
    program_help = false;
    while (1)
    {
        sleep(10);
    }
}

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the uClibc-cvs mailing list