Keil Logo

ARMLINK: How to use an entry point defined in a library


Information in this knowledgebase article applies to:

  • MDK-ARM
  • ARMLINK

QUESTION

Is it possible to have an entry point defined in a library LIB file, which is linked to my application? Because if I do so, such as passing a Handler defined as an entry point in a library to the --entry option of armlink, I get following error message:

Error: L6320W: Ignoring --entry command. Cannot find argument 'vResetHandler'.

But when I define the identical vResetHandler function directly in my application, it works with the --entry option for armlink.

CAUSE

It is possible to pass an entry point defined in a library to armlink. This linker error is due to the way the linker resolves references. During linking, armlink will parse all the objects (*.o) to create a list of references and symbols. It then attempts to match all the references to the symbols. For the remaining undefined references it will search in the libraries.

However, the libraries will ONLY be searched to resolve references from the object files. An object or symbol from a library will NOT get included, unless there is a reference from an object (or dependency from another selected library symbol).

If there is no reference to the entry point defined in a library from the objects, it will not get included by armlink.

SOLUTIONS

There are some possible ways to fix this:

  • Pass the object directly to the linker, not in a library. For instance, extract the foo.o object that has an entry point from the test.lib library and pass that object as argument to the linker.
  • Use this syntax in the options of armlink:
      test.lib(foo.o)
    
    where foo.o has an entry point. This tells the linker to treat this specific foo.o object in the library as if it is passed directly.
  • Include a reference to a symbol in the foo.o object from somewhere else in your code. That would cause the linker to search the library and link the object.

MORE INFORMATION

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, April 4, 2017


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.