Re: [U-Boot] IP_t should be a "packed" struct

2009-01-29 Thread Alessandro Rubini
> Now study the data structures used for netwrking - they are all > carefully crafted that the natural aligment "just fits", i. e. there > are no gaps between variables if they are aligned naturally. Actually, a packed structure not only doesn't have gaps, but can live at any address. So th

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-29 Thread Wolfgang Denk
Dear Luigi Mantellini, In message you wrote: > > > We (i. e. all of us except you) do not have a problem. > > my question is: how can you be sure on this? I haven't used strange Because I read the documentation? > compilers or strange CFLAGS.. I just do "make" on a supported target > (qemu_m

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Luigi Mantellini
Dear Wolfgang, 2009/1/28 Wolfgang Denk : > Dear Luigi Mantellini, > > In message you > wrote: >> >> I think that an audit of the code is important to understand if we >> have a problem (or not) and how large is the problem. > > We (i. e. all of us except you) do not have a problem. my question

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Wolfgang Denk
Dear Luigi Mantellini, In message you wrote: > > I think that an audit of the code is important to understand if we > have a problem (or not) and how large is the problem. We (i. e. all of us except you) do not have a problem. > My compiler is not broken... Well, YMMV... > cassini linux # f

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Wolfgang Denk
Dear Ben, In message <4980d38f.4020...@gmail.com> you wrote: > > > Here is for example a copy of /usr/include/netinet/ip.h : ... > > struct iphdr ... > Yeah, I made the same observation, but am not fluent enough in the black > magic of Linux header files to know if packing was being enforced > s

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Luigi Mantellini
Dear All, 2009/1/28 Wolfgang Denk : > Dear Ben Warren, > > In message <4980cc59.1070...@gmail.com> you wrote: >> >> > My idea should be to declare a define like this >> > >> > #define PKT_HEADER __attribute__((__packed__)) >> > >> > my 2EuroCents. >> > >> > best regards, >> > >> > luigi >> > >> >

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Ben Warren
Wolfgang Denk wrote: > Dear Ben Warren, > > In message <4980cc59.1070...@gmail.com> you wrote: > >>> My idea should be to declare a define like this >>> >>> #define PKT_HEADER __attribute__((__packed__)) >>> >>> my 2EuroCents. >>> >>> best regards, >>> >>> luigi >>> >>> >>> >> OK, soun

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Wolfgang Denk
Dear Ben Warren, In message <4980cc59.1070...@gmail.com> you wrote: > > > My idea should be to declare a define like this > > > > #define PKT_HEADER __attribute__((__packed__)) > > > > my 2EuroCents. > > > > best regards, > > > > luigi > > > > > OK, sounds good. Send a patch please. Hm... and

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Wolfgang Denk
Dear Luigi Mantellini, In message you wrote: > > > I'd focus on fixing your toolchain. Your problem will not be confined to > > protocol headers. > > my toolchain works fine ;) Except that it adds padding where it doesn't make sense. I think you want to fix it. Best regards, Wolfgang Denk

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Ben Warren
Luigi Mantellini wrote: > Dear All > > From my point of view, when packing is formally required (ie packets > headers), the structs should be declared explicitly as __packed__. The > correctness of the object code should be independent from the compiler > optimizations and we should always remember

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Luigi Mantellini
2009/1/28 Ben Warren : .. > I'd focus on fixing your toolchain. Your problem will not be confined to > protocol headers. my toolchain works fine ;) -- Luigi 'Comio' Mantellini R&D - Software Industrie Dial Face S.p.A. Via Canzo, 4 20068 Peschiera Borromeo (MI), Italy Tel.: +39 02 5167 2813

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Luigi Mantellini
Dear All >From my point of view, when packing is formally required (ie packets headers), the structs should be declared explicitly as __packed__. The correctness of the object code should be independent from the compiler optimizations and we should always remember that the offset of a struct field

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Ben Warren
Jerry Van Baren wrote: > Ben Warren wrote: >> Luigi 'Comio' Mantellini wrote: >>> Hi ML, >>> >>> I'm working on a mips target and I used qemu_mips target to simulate >>> my target (that I hope to have in the next week...) >>> >>> Following my activities I noticed that IP_t structure is no defined

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Jerry Van Baren
Ben Warren wrote: > Luigi 'Comio' Mantellini wrote: >> Hi ML, >> >> I'm working on a mips target and I used qemu_mips target to simulate my >> target >> (that I hope to have in the next week...) >> >> Following my activities I noticed that IP_t structure is no defined with >> attribute "packed".

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Ben Warren
Luigi 'Comio' Mantellini wrote: > Hi ML, > > I'm working on a mips target and I used qemu_mips target to simulate my > target > (that I hope to have in the next week...) > > Following my activities I noticed that IP_t structure is no defined with > attribute "packed". I noticed this issue becaus

Re: [U-Boot] IP_t should be a "packed" struct

2009-01-28 Thread Luigi 'Comio' Mantellini
Hi ML, I noticed that also the others headers structs have the same potential problem. I attached the patch to fix the net.h header file. best regards, luigi On Tuesday 27 January 2009 19:32:10 Luigi 'Comio' Mantellini wrote: > Hi ML, > > I'm working on a mips target and I used qemu_mips targe

[U-Boot] IP_t should be a "packed" struct

2009-01-27 Thread Luigi 'Comio' Mantellini
Hi ML, I'm working on a mips target and I used qemu_mips target to simulate my target (that I hope to have in the next week...) Following my activities I noticed that IP_t structure is no defined with attribute "packed". I noticed this issue because using a self-made toolchain (gcc4.2.4+binuti