avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Align attribute in gcc requiring alignment of 2 for X


From: Thomas, George
Subject: Re: [avr-gcc-list] Align attribute in gcc requiring alignment of 2 for Xmegas with USB.
Date: Wed, 21 Nov 2012 20:02:59 +0000

Hi,

I checked the patches of the fix in PR53448

Even when the requested alignment in greater than the BIGGEST_ALIGNMENT 
(considering it to be 2 for Xmega and 1 for other devices), we are not 
producing a warning to the user that he is trying to align more than the 
required. Is this behavior right ? Should the warning be there in this case ? 

One way to get this warning done is 
in the call to

sect->noswitch.callback (decl, name, size, rounded)
returning false in 

assemble_noswitch_variable(..)  function in gcc/varasm.c

For that to be possible 

ASM_OUTPUT_ALIGNED_BSS macro in avr.h should return false after doing the 
actual alignment if the requested alignment is greater than 2 for Xmegas and 
greater than 1 for other devices.

If a patch with the change is provided would that be acceptable ? 
  
Regards,
George

________________________________________
From: Thomas, George
Sent: Tuesday, November 20, 2012 12:40 AM
To: Georg-Johann Lay; Weddington, Eric
Cc: address@hidden
Subject: RE: [avr-gcc-list] Align attribute in gcc requiring alignment of 2 for 
Xmegas with USB.

I made a mistake with the patch.

I had a version of 3.4.1 release of toolchain in path which was of version 
4.6.2 on which I was trying the changes.
The 4.6.2 version was giving a warning saying
"requested alignment for 'a' is greater than implemented alignment of 1"
and the alignment was not happening properly.

I tried changing the BIGGEST_ALIGNMENT to 16 but applied the patch to the trunk 
version which already had the fix.

Sorry for the mistake.

-George-

PS :- Changing the BIGGEST_ALIGNMENT to 16 removed the warning when tried in 
the 4.6.2 toolchain but it did not change the alignment in the output elf when 
the disassembly was checked.


________________________________________
From: Georg-Johann Lay address@hidden
Sent: Monday, November 19, 2012 11:34 PM
To: Weddington, Eric
Cc: Thomas, George; address@hidden
Subject: Re: [avr-gcc-list] Align attribute in gcc requiring alignment of 2 for 
Xmegas with USB.

Weddington, Eric wrote:
>
>>
>>> Section 20.13.7 of the Xmega manual speaks about the requirement of 16
>>> bit alignment.
>>>
>>> http://www.atmel.com/images/doc8331.pdf
>>>
>>> As the MAXIMUM_ALIGNMENT in avr.h is set to 1,  it throws an error when
>>> trying to compile.
>>>
>>> I have attached a patch which sets it to 2 by default in the compiler. I
>>> have also attached a case which fails.
>>>
>>> Would this be an acceptable change ?
>> Hi George,
>>
>> No, this would not be an acceptable change, because it is changing the
>> data alignment for the whole compiler, when there is only a restriction on
>> a data structure for a single peripheral for a small subset of the AVR
>> processors.
>>
>> This is why the data attribute "aligned" exists. Just do this for your
>> data structure: __attribute__ ((aligned (2)))
>
> Excuse me, perhaps I have this wrong... (It's still early for me).
>
> Does changing MAXIMUM_ALIGNMENT allow the aligned attribute to work? If we
> don't change MAXIMUM_ALIGNMENT, are you saying that the aligned attribute
> fails?

See PR53448.  In general, that is no issue in < 4.7 because only xmega needs
align(2) and these versions don't support xmega.

Besides that, 4.7 had quite some clean-up of w.r.t. ELF, e.g. avr/elf.h.

Even if it works with changing MAXIMUM_ALIGNMENT, that's not the purpose of
MAXIMUM_ALIGNMENT.

Johann




reply via email to

[Prev in Thread] Current Thread [Next in Thread]