This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: Linker: Controlling the entry point



Tool/software: TI C/C++ Compiler

Hello All,

There is a linking option (--entry_point) to tell the code where to begin. I have made a label (_c_int00) in an assembly file then I added the option

(--entry_point = _c_int00) while linking. While debugging, the PC was at address 0x0 not the address of the entry point. Is there anything missing to make that option works properly. Thanks in advance.

  • Make sure that in this assembly file ...

    Bishoy Michael1 said:
    I have made a label (_c_int00) in an assembly file

    ... you make the symbol _c_int00 global with this line ...

        .global    _c_int00

    If that doesn't fix the problem, then please show exactly how the linker is invoked.  And attach the linker map file.  So the forum will accept it, add the file extension .txt to it.

    Thanks and regards,

    -George

  • Hello George,

    Thanks for your reply.

    I already have added that directive (.global). I attached the assembly, linker & map files.

    
    
    	.global _c_int00
    	
    	.armfunc _c_int00
        
    _c_int00
    
            ;*------------------------------------------------------
            ;* CALL APPLICATION
            ;*------------------------------------------------------
            BL      main
    
            .endasmfunc
    	.global main
    ******************************************************************************
                      TI ARM Linker PC v18.12.1                    
    ******************************************************************************
    >> Linked Mon Nov 25 19:16:17 2019
    
    OUTPUT FILE NAME:   <.\_R4\out\exe\R4.xer4f>
    ENTRY POINT SYMBOL: "_c_int00"  address: 000002c8
    
    
    MEMORY CONFIGURATION
    
             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      PROG_VEC_TCMA_RAM     00000000   00000100  00000000  00000100  RWIX
      MSS_TCMA_RAM          00000100   0003ff00  000008cc  0003f634  RWIX
      MSS_TCMB              08000000   00010000  00000000  00010000  RWIX
    
    
    SEGMENT ALLOCATION MAP
    
    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    00000100    00000100    000004cc   000002cc    r-x
      00000100    00000100    000002cc   000002cc    r-x .text
      000003cc    000003cc    00000200   00000000    r-- .bss
    000005cc    000005cc    00000400   00000200    r--
      000005cc    000005cc    00000200   00000200    r-- .const
      000007cc    000007cc    00000200   00000000    r-- .data
    
    
    SECTION ALLOCATION MAP
    
     output                                  attributes/
    section   page    origin      length       input sections
    --------  ----  ----------  ----------   ----------------
    .text      0    00000100    000002cc     
                      00000100    00000100     --HOLE-- [fill = aaaaaaaa]
                      00000200    000000c8     main.obj (.text)
                      000002c8    00000004     startup.obj (.text)
                      000002cc    00000100     --HOLE-- [fill = aaaaaaaa]
    
    .bss       0    000003cc    00000200     UNINITIALIZED
                      000003cc    00000200     --HOLE--
    
    .const     0    000005cc    00000200     
                      000005cc    00000200     --HOLE-- [fill = aaaaaaaa]
    
    .data      0    000007cc    00000200     UNINITIALIZED
                      000007cc    00000200     --HOLE--
    
    .cinit     0    00000100    00000000     UNINITIALIZED
    
    MODULE SUMMARY
    
           Module         code   ro data   rw data
           ------         ----   -------   -------
        .\_R4\out\obj\
           main.obj       200    0         0      
           startup.obj    4      0         0      
        +--+--------------+------+---------+---------+
           Total:         204    0         0      
                                                  
        +--+--------------+------+---------+---------+
           Grand Total:   204    0         0      
    
    
    GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name 
    
    address   name                
    -------   ----                
    ffffffff  __TI_pprof_out_hndl 
    ffffffff  __TI_prof_data_size 
    ffffffff  __TI_prof_data_start
    00000100  __TI_static_base__  
    ffffffff  __binit__           
    ffffffff  __c_args__          
    000005cc  __linker_bss_end    
    000003cc  __linker_bss_start  
    000007cc  __linker_const_end  
    000005cc  __linker_const_start
    000009cc  __linker_data_end   
    000007cc  __linker_data_start 
    000003cc  __linker_text_end   
    00000100  __linker_text_start 
    000002c8  _c_int00            
    ffffffff  binit               
    000005cc  bss_end             
    000003cc  bss_start           
    00000200  main                
    
    
    GLOBAL SYMBOLS: SORTED BY Symbol Address 
    
    address   name                
    -------   ----                
    00000100  __TI_static_base__  
    00000100  __linker_text_start 
    00000200  main                
    000002c8  _c_int00            
    000003cc  __linker_bss_start  
    000003cc  __linker_text_end   
    000003cc  bss_start           
    000005cc  __linker_bss_end    
    000005cc  __linker_const_start
    000005cc  bss_end             
    000007cc  __linker_const_end  
    000007cc  __linker_data_start 
    000009cc  __linker_data_end   
    ffffffff  __TI_pprof_out_hndl 
    ffffffff  __TI_prof_data_size 
    ffffffff  __TI_prof_data_start
    ffffffff  __binit__           
    ffffffff  __c_args__          
    ffffffff  binit               
    
    [19 symbols]
    
    /*
     * STACK SIZE MACRO DEFINITIONS
     */
    #define M_USER_STACK_SIZE   0x1800   /* Multiple of 8 bytes - 6KB */
    #define M_PREV_STACK_SIZE   0x10    /* Multiple of 8 bytes - 16B */
    
    /*
     * LINKER OPTIONS
     */
    --entry_point=_c_int00                    /* ENTRY POINT                   */
    -stack  0x2800                            /* SOFTWARE STACK SIZE           */
    -heap   0x0800                            /* HEAP AREA SIZE                */
    --retain="*(.intvecs)"
    
    /* SPECIFY THE SYSTEM MEMORY MAP */
    
    MEMORY
    {
        PROG_VEC_TCMA_RAM   : org = 0x00000000   len = 0x00000100    /* PROGRAM MEMORY    (ROM) (72 Bytes)- 8 BYTE ALIGNED */
        MSS_TCMA_RAM        : org = 0x00000100   len = 0x0003ff00    /* PROGRAM MEMORY (RAM : TCMA) (128 kB - 48 Bytes)    */
        MSS_TCMB            : org = 0x08000000   len = 0x00010000    /* DATA MEMORY       (RAM : TCMB) (64 kBytes)         */
    
    }
    
        --define=MCAL_CODE1=MSS_TCMA_RAM
        --define=MCAL_CODE2=MSS_TCMA_RAM
        --define=MCAL_DATA=MSS_TCMA_RAM
        --define=MCAL_BSS=MSS_TCMA_RAM
        --define=MCAL_NOINIT=MSS_TCMA_RAM
        --define=MCAL_CONST=MSS_TCMA_RAM
        --define FILL_PATTERN=0xAAAAAAAA
        --define FILL_LENGTH=0x100
    
    
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */
    
    SECTIONS
    {
        .intvecs            : { *(.intvecs) }    >  PROG_VEC_TCMA_RAM  ALIGN(8) /* INTERRUPT VECTORS                 */
        .startup            : { *(.startup) }    >  MSS_TCMA_RAM ALIGN(8)      /* STARTUP CODE - 8 BYTE ALIGNED     */
    
        /* TEXT SECTION - Executable Code */
        .text               :                    >  MCAL_CODE1, fill=FILL_PATTERN
        {
            .=align(4);
            __linker_text_start = .;
            . += FILL_LENGTH;
            *(.text)
            .=align(4);
            . += FILL_LENGTH;
            __linker_text_end = .;
        }
    
        /* CONST SECTION - Initialized Global Variables */
        .const      : load > MCAL_CONST, fill=FILL_PATTERN
        {
            .=align(4);
            __linker_const_start = .;
            . += FILL_LENGTH;
            *(.const)
            .=align(4);
            . += FILL_LENGTH;
            __linker_const_end = .;
        }
    
        /* DATA SECTION - Initialized Data */
        .data       : load > MCAL_DATA
        {
            .=align(4);
            __linker_data_start = .;
            . += FILL_LENGTH;
            *(.data)
            .=align(4);
            . += FILL_LENGTH;
            __linker_data_end = .;
        }
    
        /* BSS SECTION - Contains Uninitialized Global variables */
        .bss        : load > MCAL_BSS
                        RUN_START(bss_start)
                        RUN_END(bss_end)
        {
            .=align(4);
            __linker_bss_start = .;
            . += FILL_LENGTH;
            *(.bss)
            .=align(4);
            . += FILL_LENGTH;
            __linker_bss_end = .;
        }
    
        /* CINIT SECTION - Tables which initializes global variables */
        .cinit      : load > MCAL_DATA
    
        /* STACK - System Stack */
        .stack      : load > MCAL_DATA, fill=FILL_PATTERN
    
        /* SYSMEM - Heap Memory */
        .sysmem     : load > MCAL_DATA
    }
    
    
     

  • Everything I can see is in proper order.  The map file shows this ...

    ENTRY POINT SYMBOL: "_c_int00"  address: 000002c8
    /* skip many lines */
                      000002c8    00000004     startup.obj (.text)

    Perhaps some detail of system startup, such as an interrupt vector, needs attention.  If that is the case, then I lack the expertise to help you.

    Thanks and regards,

    -George

  • Thanks George, I am waiting for your reply. 

    Kind regards, 

    Bishoy Michael 

  • Unfortunately, I have no reply to give you.  In your case, the compiler tools have worked correctly.  If you are still stuck, then the issue is probably something I cannot help you with.  

    Some related questions to consider ... Is your program written in C or C++?  If so, it is unusual to use the linker option --entry_point.  Why do you use --entry_point?

    Thanks and regards,

    -George

  • Hello George,

    Yes the program is written in c language, what is the problem here?

    I have made a solution, I wrote that assembly file (startup.asm) in a certain section and placed that section at the beginning of the memory at address 0x0

        .sect ".intvecs"
        .global cstartup
    ;***************************************************************
    ;* FUNCTION DEF: cstartup
    ;***************************************************************
    cstartup: .asmfunc stack_usage(0)
    
            ;*------------------------------------------------------
            ;* CALL APPLICATION
            ;*------------------------------------------------------
            BL      main
    
            .endasmfunc
    
    ;******************************************************
    ;* UNDEFINED REFERENCES                               *
    ;******************************************************
    	.global main
    

    Thanks a lot for your support.

     

  • This startup assembly routine does nothing except call main.  When does the stack get set up?  When do global variables get initialized?  And other details like that.  The boot routine from the compiler RTS library does all of those things.  It is part of the compiler installation.  Here is a typical location ...

    C:\ti\ccs910\ccs\tools\compiler\ti-cgt-arm_18.12.4.LTS\lib\src\boot_cortex_m.c

    I apologize for not noticing this problem before.

    Thanks and regards,

    -George

  • Yes George the previous file jumps only to main and the code works properly, after power on reset the code goes to address 0x0 where I implement that label which only jumps to main. I have made it that simple just to make sure that the way of placing a label at address 0x0 works properly. 

    I will add global variable initialization, .. etc later. But, now I want to know why --entry_point doesn't work & why it is unusual to use the linker option --entry_point when I write C/C++ files.

    Sorry that much details. Thanks in advance. 

  • Hello,

    Seemingly project settings myapp_ccs.cmd my need your custom jump to address added.

    The default base must be modified too but that is all you really need to do, not modify the linker.

    #define APP_BASE 0x00000000

  • BTW: You also have to flash write application to the same address defined by APP_BASE. Certain MCU SRAM will not allow random base address must exist on 4k boundary, such as the flash boot loader mandates. 

  • Bishoy Michael1 said:
    why --entry_point doesn't work

    As far as I can tell, the linker has handled the entry point correctly.  What do you see that makes you think it is wrong?

    Bishoy Michael1 said:
    why it is unusual to use the linker option --entry_point when I write C/C++ files

    Because most (approaching all) projects that have C/C++ code do not use --entry_point, but use --rom_model or --ram_model instead.  Among the effects of --rom_model or --ram_model is setting the entry point of the program to the value of the symbol _c_int00.

    Thanks and regards,

    -George