Keil Logo

LX51: Locate Common Code Segments

Information in this article applies to:

  • C51 Version 7.50


We are using Linker Code Packing, and the linker generates segments with the name ?L?COMxxxx. However, we need to locate these segments to a specific address region. Since these segments always belong to the memory class CODE it seems to be impossible to locate them.

I have even tried to use a wildcard in the SEGMENTS directive (for example ?L?COM*(C:0x2000)) but this does not work either.

Is there any way to locate these segments in specific address ranges?


The linker generated segments with the name ?L?COMxxxx are generated very late during the optimization process. The only way to locate them is to use the memory class CODE. When you need to locate your application code to a specific memory region, you may use the USERCLASS directive.

The required steps for the setup in µVision are explained below:

  • Enter in Project - Options - C51 - Misc Controls: USERCLASS (CODE=APP). Then all application code will be in the memory class CODE_APP.
  • Now locate the memory class CODE (which contains the linker generated segments and the C51 run-time library and the memory class CODE_APP which contains the remaining part of the application program with the LX51 CLASSES directive. For example, enter under Project - Options - LX51 Locate - User classes:

    HDATA (X:0x0-X:0xFFFF),
    ECODE (C:0x0-C:0xFFFF), HCONST (C:0x0-C:0xFFFF),
    CODE (C:0-C:0x1FFF), CODE_APP (C:0x2000-C:0xFFFF)

    This locates the common code sequences to C:0 - C:0x1FFF and the application code to C:0x2000 - C:0xFFFF.

Note: The linker generates the common code sequences very late, and therefore the size is not known when the application code segments are located. You may need to adjust the address ranges for the different memory classes when you are getting *** ERROR L107: ADDRESS SPACE OVERFLOW linker errors.


  • Refer to USERCLASS in the Cx51 User's Guide.
  • Refer to CLASSES in the LX51 User's Guide.


Last Reviewed: Thursday, February 25, 2021

Did this article provide the answer you needed?
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.