public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: amckay@iders.ca (Andrew)
To: linux-arm-kernel@lists.infradead.org
Subject: Compiler for Atmel AT91SAMG20
Date: Fri, 05 Feb 2010 10:49:58 -0600	[thread overview]
Message-ID: <4B6C4C36.9030800@iders.ca> (raw)

Hello,

I'm having an issue with the compiler that I'm using for building a 
Kernel for my Atmel AT91SAM9G20 processor.  I had a problem with 
iptables.  When I run the command it reports an error of "getsockopt 
failed strangely: Invalid argument".  I traced the problem to Kernel 
space and it not being happy with the size of the struct passed to 
kernel space.  In this case userspace thinks that the ipt_get_revision 
struct is 32 bytes, and the Kernel thinks it is 30 bytes. 

 From net/ipv4/netfilter/ip_tables.c:

static int
do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
{
        int ret;

        if (!capable(CAP_NET_ADMIN))
                return -EPERM;

        switch (cmd) {
        case IPT_SO_GET_INFO:
                ret = get_info(sock_net(sk), user, len, 0);
                break;

        case IPT_SO_GET_ENTRIES:
                ret = get_entries(sock_net(sk), user, len);
                break;

        case IPT_SO_GET_REVISION_MATCH:
        case IPT_SO_GET_REVISION_TARGET: {
                struct ipt_get_revision rev;
                int target;

                if (*len != sizeof(rev)) {
                        printk("%d != %d\n", *len, sizeof(rev));
                        printk("ipt_get_revision is different sizes\n");
                        ret = -EINVAL;
                        break;
                }
                if (copy_from_user(&rev, user, sizeof(rev)) != 0) {
                        ret = -EFAULT;
                        break;
                }

                if (cmd == IPT_SO_GET_REVISION_TARGET)
                        target = 1;
                else
                        target = 0;

                try_then_request_module(xt_find_revision(AF_INET, rev.name,
                                                         rev.revision,
                                                         target, &ret),
                                        "ipt_%s", rev.name);
                break;
        }

        default:
                duprintf("do_ipt_get_ctl: unknown request %i\n", cmd);
                ret = -EINVAL;
        }

        return ret;
}


The compiler I'm using for the Kernel (Code Sourcery's GNU 
cross-toolchain arm-2008q3-66-arm-none-eabi) is set to pack structs by 
default, and the compilers that I use for userspace applications do not 
pack structs.

I would prefer to have the compiler I use for the Kernel to not pack 
structs as all of our other toolchains don't do this.  Can anyone 
recommend another compiler for building Kernels for the AT91SAM9G20 
processor?  Or is there a way to tell the compiler to not pack structs 
when building the Kernel?  I tried adding -fpack-struct=4 to the 
KBUILD_CFLAGS but it didn't seem to make a difference on how bit the 
Kernel thinks the struct is.

My other option is to compile a glibc library for the Code Sourcery 
toolchain so I can build userspace applications with pack structs, but I 
would prefer not to do this.

Andrew McKay
Iders Inc.

             reply	other threads:[~2010-02-05 16:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-05 16:49 Andrew [this message]
2010-02-05 18:00 ` Compiler for Atmel AT91SAMG20 Daniel Jacobowitz
2010-02-11 20:40   ` Andrew
2010-02-18 21:03     ` Andrew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B6C4C36.9030800@iders.ca \
    --to=amckay@iders.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox