EmbDev.net

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


von Joe D. (jdupre)


Rate this post
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?

von Martin T. (mthomas) (Moderator)


Rate this post
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.

von Joe D. (jdupre)


Rate this post
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.]

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.