This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Included module order change by export/import LIB

I habe built a project with µVision2 and generated a library (LIB file). I have imported this LIB into another µVision2 project. However, the link order of the imported modules within the LIB is now changed compared to the original order of the modules. This is a problem since I have to keep not only the module order, but also the init_segment should be kept invariant.
How can be kept the order of the included input module from the LIB? (I have used LIB51 LIBRARY MANAGER V4.24)

Parents
  • If you've manually assigned addresses to the code segments, then the linker isn't going to reorder them.

    By "init segment", do you mean ?C_INITSEG? This segment stores the values for initialized static variables. This segment will change for different programs depending on what variables you initialize statically (that is, with values in {} when you declare them). See the file INIT.A51. If you want this segment not to change, then all the rest of your code has to declare exactly the same initialized variables.

    (For some applications, C_INITSEG is a waste of space. If the program has to be able to re-initialize itself short of a complete reboot, then you'll need additional code to set values anyway. The "free" initialization at declaration time is then redundant; INIT.A51 can be omitted entirely, and const code tables or immediate values used to store the init values. If, on the other hand, you have a lot of variables that really can be initialized only once, then INITSEG gathers all that information in one place and initializes everything at once, which can be more efficient that init code spread out in every module.)

Reply
  • If you've manually assigned addresses to the code segments, then the linker isn't going to reorder them.

    By "init segment", do you mean ?C_INITSEG? This segment stores the values for initialized static variables. This segment will change for different programs depending on what variables you initialize statically (that is, with values in {} when you declare them). See the file INIT.A51. If you want this segment not to change, then all the rest of your code has to declare exactly the same initialized variables.

    (For some applications, C_INITSEG is a waste of space. If the program has to be able to re-initialize itself short of a complete reboot, then you'll need additional code to set values anyway. The "free" initialization at declaration time is then redundant; INIT.A51 can be omitted entirely, and const code tables or immediate values used to store the init values. If, on the other hand, you have a lot of variables that really can be initialized only once, then INITSEG gathers all that information in one place and initializes everything at once, which can be more efficient that init code spread out in every module.)

Children