EmbDev.net

Forum: ARM programming with GCC/GNU tools Linker jargon queries


Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 useful
not useful
Hello ,

I was just going through some linker scripts and could do with some 
clarifications.
.bss (NOLOAD) :
  {
  __bss_start = . ;
  __bss_start__ = . ;
  *(.bss)
  *(.bss.*)
  *(.gnu.linkonce.b*)
  *(COMMON)
  . = ALIGN(4);
  } > RAM

  . = ALIGN(4);
  __bss_end__ = . ;
  PROVIDE (__bss_end = .);

1).bss (NOLOAD) : is this strictly necessary ? I think just tells the 
linker not to place this in ROM ? But if there is no >AT ROM , the 
linker would not do it anyway.Is this redundant ,or is it required by 
the gcc linker ?

2) __bss_start = . ;
   _bss_start_ = . ;
Why are there 2 "labels" for the same location ? _bss_start_  is used 
in the startup asm to zero the contents of .bss ,but I could not find 
__bss_start used anywhere.

.arm
.section .STACK, "w"
.align 3
Stack_Mem:
.space Stack_Size
.equ Stack_Top, Stack_Mem + Stack_Size

4).align 3
Should it be .align 4 ? Align on a word boundary ?

TIA
Thomas

Author: Jörg Wunsch (dl8dtl) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Thomas Fernando wrote:

> 1).bss (NOLOAD) : is this strictly necessary ?

I didn't look up it in the linker reference, but I think it's
just telling the linker which section flags to place in the
output file.  An ELF file section can be either LOAD or NOLOAD.

> Why are there 2 "labels" for the same location ?

My guess is that it's for historical reasons, "just in case".

> 4).align 3
> Should it be .align 4 ? Align on a word boundary ?

I think this means to align on an 8-byte boundary, 2^3.

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 useful
not useful
Thanks much for your reply Jorg.

Jörg Wunsch wrote:
>I didn't look up it in the linker reference, but I think it's
>just telling the linker which section flags to place in the
>output file.
Ok,is this the same as "which section flags to place in the
ROM".Since the output file (.ihex i.e. not ELF) will be be finally 
flashed in the ROM.Sorry to sound a bit pedantic,but I am just trying to 
clear my doubts.
>
> My guess is that it's for historical reasons, "just in case".
>
Ok,so I did not miss anything much.

> I think this means to align on an 8-byte boundary, 2^3.
Yes, I just read it in the assembler directives,now it is clear.

Thanks
Thomas

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.