You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by 范姜徐霖 <ja...@gmail.com> on 2022/08/24 15:08:48 UTC

srodata section alignment issue in hw/bsp/hifive1/hilive1.ld file

I try to port ble_app program to my board from bsp/hifive1.
I found something wrong at srodata alignment. (see attached file)
the .data section size is 0x94, and the following .srodata section is
alignment at 2**3
so .sordata section start at 0x98. 4-bytes are skipped.
we do not always have this error, it depends.
I guess it happen at ".data section size is not 8-byte alignment"

I modify the hifive1.ld to make sure .data section size is 8-byte alignment.
----------------------
  .data          :
  {
    *(.data .data.*)
    *(.gnu.linkonce.d.*)
    . = ALIGN(8);  <------------------------I add this line
  } >dtcm AT>itcm
--------------------------

dont know is there anything missing?

Jack

Re: srodata section alignment issue in hw/bsp/hifive1/hilive1.ld file

Posted by Jerzy Kasenberg <je...@codecoup.pl>.
Jack,

you can check if solution https://github.com/apache/mynewt-core/pull/2866
works for you
Your way of adding alignment could backfire if other alignment requirement
was introduced in later time
and such variable was fist in .sdata output section.
So you may tray to put ALIGN_WITH_INPUT in all sections that are copied
from flash in one chunk

Jerzy

czw., 25 sie 2022 o 03:09 范姜徐霖 <ja...@gmail.com> napisał(a):

> one more section shall be modified, or be error when srodata section size
> is not 4-bytes alignment.
>
> ------------------------------------
>   .srodata        :
>   {
>     PROVIDE( _gp = . + 0x800 );
>     PROVIDE( __global_pointer$ = _gp);
>     *(.srodata.cst16)
>     *(.srodata.cst8)
>     *(.srodata.cst4)
>     *(.srodata.cst2)
>     *(.srodata .srodata.*)
>     . = ALIGN(4);           --------------------------add this line
>   } >dtcm AT>itcm
> -----------------------------------
>
> Marko Kiiskila <mk...@yahoo.com.invalid> 於 2022年8月25日 週四 凌晨12:02寫道:
>
> > There was no attached file, I assume that would’ve had
> > the error you are seeing.
> >
> > Regardless, what you have there is a reasonable way
> > to get .data padded to 8 byte alignment. Linker script is
> > the right place to make that happen.
> >
> > > On 24. Aug 2022, at 18.08, 范姜徐霖 <ja...@gmail.com> wrote:
> > >
> > > I try to port ble_app program to my board from bsp/hifive1.
> > > I found something wrong at srodata alignment. (see attached file)
> > > the .data section size is 0x94, and the following .srodata section is
> > alignment at 2**3
> > > so .sordata section start at 0x98. 4-bytes are skipped.
> > > we do not always have this error, it depends.
> > > I guess it happen at ".data section size is not 8-byte alignment"
> > >
> > > I modify the hifive1.ld to make sure .data section size is 8-byte
> > alignment.
> > > ----------------------
> > >   .data          :
> > >   {
> > >     *(.data .data.*)
> > >     *(.gnu.linkonce.d.*)
> > >     . = ALIGN(8);  <------------------------I add this line
> > >   } >dtcm AT>itcm
> > > --------------------------
> > >
> > > dont know is there anything missing?
> > >
> > > Jack
> > >
> >
> >
>

Re: srodata section alignment issue in hw/bsp/hifive1/hilive1.ld file

Posted by 范姜徐霖 <ja...@gmail.com>.
one more section shall be modified, or be error when srodata section size
is not 4-bytes alignment.

------------------------------------
  .srodata        :
  {
    PROVIDE( _gp = . + 0x800 );
    PROVIDE( __global_pointer$ = _gp);
    *(.srodata.cst16)
    *(.srodata.cst8)
    *(.srodata.cst4)
    *(.srodata.cst2)
    *(.srodata .srodata.*)
    . = ALIGN(4);           --------------------------add this line
  } >dtcm AT>itcm
-----------------------------------

Marko Kiiskila <mk...@yahoo.com.invalid> 於 2022年8月25日 週四 凌晨12:02寫道:

> There was no attached file, I assume that would’ve had
> the error you are seeing.
>
> Regardless, what you have there is a reasonable way
> to get .data padded to 8 byte alignment. Linker script is
> the right place to make that happen.
>
> > On 24. Aug 2022, at 18.08, 范姜徐霖 <ja...@gmail.com> wrote:
> >
> > I try to port ble_app program to my board from bsp/hifive1.
> > I found something wrong at srodata alignment. (see attached file)
> > the .data section size is 0x94, and the following .srodata section is
> alignment at 2**3
> > so .sordata section start at 0x98. 4-bytes are skipped.
> > we do not always have this error, it depends.
> > I guess it happen at ".data section size is not 8-byte alignment"
> >
> > I modify the hifive1.ld to make sure .data section size is 8-byte
> alignment.
> > ----------------------
> >   .data          :
> >   {
> >     *(.data .data.*)
> >     *(.gnu.linkonce.d.*)
> >     . = ALIGN(8);  <------------------------I add this line
> >   } >dtcm AT>itcm
> > --------------------------
> >
> > dont know is there anything missing?
> >
> > Jack
> >
>
>

Re: srodata section alignment issue in hw/bsp/hifive1/hilive1.ld file

Posted by Marko Kiiskila <mk...@yahoo.com.INVALID>.
There was no attached file, I assume that would’ve had
the error you are seeing.

Regardless, what you have there is a reasonable way
to get .data padded to 8 byte alignment. Linker script is
the right place to make that happen.

> On 24. Aug 2022, at 18.08, 范姜徐霖 <ja...@gmail.com> wrote:
> 
> I try to port ble_app program to my board from bsp/hifive1.
> I found something wrong at srodata alignment. (see attached file)
> the .data section size is 0x94, and the following .srodata section is alignment at 2**3
> so .sordata section start at 0x98. 4-bytes are skipped. 
> we do not always have this error, it depends. 
> I guess it happen at ".data section size is not 8-byte alignment"
> 
> I modify the hifive1.ld to make sure .data section size is 8-byte alignment.
> ----------------------
>   .data          :
>   {
>     *(.data .data.*)
>     *(.gnu.linkonce.d.*)
>     . = ALIGN(8);  <------------------------I add this line
>   } >dtcm AT>itcm 
> --------------------------
>  
> dont know is there anything missing?
> 
> Jack 
>