> Does it work if you add PACKED here in dnsd.c?
> struct type_and_class {
> uint16_t type PACKED;
> uint16_t class PACKED;
> };
No, but it does work with:
struct type_and_class {
uint16_t type;
uint16_t class;
}PACKED;
Then the disassembler also shows some calls to memcpy with a length of 2.
Denys Vlasenko schrieb:
> On Wed, Apr 14, 2010 at 6:02 AM, Lars Reemts <[email protected]> wrote:
>
>> Hello,
>>
>> I'm using busybox on a AT91SAM9261 (arm920t) processor with gcc 4.3.4.
>> Yesterday I ran into some problems using dnsd. DNS queries from a
>> windows host were not properly decoded and hence not answered. Digging
>> into the code the problem turned out to be two different problems, both
>> related to halfword alignment.
>>
>> The first one (in dnsd_main()) is related to the alignment of buffer
>> where the incoming network packets are stored. It was declared and
>> allocated as uint8_t buf[] in dnsd.c:462. This tells the compiler that
>> the buffer is containing byte data and gives it the freedom to allocate
>> the buffer at any address. In my setup it starts at an odd address. When
>> processing an incoming packet later on in process_packet() the buffer is
>> accessed as containing 2 byte data, which leads to alignment problems.
>> Allocating the buffer as uint16_t buf[] solves the problem for me.
>>
>> The second one (in process_packet()) was particularly hard to track
>> down. It boils down to move_from_unaligned16(), which is #defined as 2
>> byte memcpy() in platform.h not working correctly for 16 bit source
>> pointer types. For these the compiler assumes the pointer to already be
>> aligned and replaces the 2 byte memcpy() by a half word load and a half
>> word store assembler instruction. The solution is to ensure the source
>> pointer is pointing to a single byte data type.
>>
>
> Unfortunately that will uglify code a lot.
>
> Does it work if you add PACKED here in dnsd.c?
>
> struct type_and_class {
> uint16_t type PACKED;
> uint16_t class PACKED;
> };
>
>
--
Lars Reemts, Lange Wieke 1, 26817 Rhauderfehn, Germany
Tel: +49 4952 942290, Fax: +49 4952 942291
mailto: [email protected]
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox