EmbDev.net

Forum: ARM programming with GCC/GNU tools Link order of objects / Linker script


Author: Joe Dupre (jdupre)
Posted on:

Rate this post
0 useful
not useful
Is it "normal" to have to specify the order of .o files when linking?

I have just encountered some sample code where the ARM startup assembly
code object file must be first in the list of files to be linked.  (If
not, the code will not run.)  Other sample code doesn't seem to care
what order the files are linked.

Is is a function if the linker script to tell the linker where to put
certain object files?

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Joe Dupre wrote:
> Is it "normal" to have to specify the order of .o files when linking?
The order has an impact but it's usually not a good idea to create code
that depends on the order. Usage of libraries (.a-files) might be
excpetion in certain scenarios. Are there any weak
defintions/attributes? Are symbols used in the startup-code which are
also used in other files?

> I have just encountered some sample code where the ARM startup assembly
> code object file must be first in the list of files to be linked.  (If
> not, the code will not run.)  Other sample code doesn't seem to care
> what order the files are linked.
Please check the map-files for the both cases, you should see
differences esp. in the cross-reference. If you have difficulties to
interpret them you can pack the two map-files into a zip-file and attach
it to a message. Maybe the readers of the forum can help. Without a
little more information it's difficult to help.

> Is is a function if the linker script to tell the linker where to put
> certain object files?
This is somehow possible but it's not a "where to put object files" but
where to put the sections defined in the object file.

Author: Joe Dupre (jdupre)
Posted on:

Rate this post
0 useful
not useful
> The order has an impact but it's usually not a good idea to create code
> that depends on the order.


The problem was that the arm boot code, including the reset handler, was
assigned to the .text section, not the .startup section.  Therefore if
bootcode.s was linked first, everything was fine.  (I thought the ENTRY
declaration would handle this, but apparently not.)

[I had converted the project from a make project to an eclipse project,
so the linker object order got re-arranged.]

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.