Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22192

How do I link startup file inside of static library in GCC?

$
0
0

Clarification

I want to create static library from my code to share the artifacts (but not the code). I will call this Main_Project.

In my Main_Project, I have startup.s and flash.ld files.

startup.s:    .section    .isr_vector,"a",%progbits    .type   g_pfnVectors, %objectg_pfnVectors:    .word   _estack    .word   Reset_Handler    .word   NMI_Handler    .word   HardFault_Handler    .word   MemManage_Handler    .word   BusFault_Handler    .word   UsageFault_Handler'
flash.ld:/* Entry Point */ENTRY(Reset_Handler)/* Highest address of the user mode stack */_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */_Min_Heap_Size = 0x200; /* required amount of heap */_Min_Stack_Size = 0x400; /* required amount of stack *//* Memories definition */MEMORY{  RAM    (xrw)   : ORIGIN = 0x20000000,   LENGTH = 128K  FLASH  (rx)    : ORIGIN = 0x8000000,    LENGTH = 436K  API    (rx)    : ORIGIN = 0x806D000,    LENGTH = 32K}/* Sections */SECTIONS{  /* The startup code into "FLASH" Rom type memory */  .isr_vector :  {    . = ALIGN(4);    KEEP(*(.isr_vector)) /* Startup code */    . = ALIGN(4);  } >FLASH  /* The program code and other data into "FLASH" Rom type memory */  .text :  {    . = ALIGN(4);    *(.text)           /* .text sections (code) */    *(.text*)          /* .text* sections (code) */    *(.glue_7)         /* glue arm to thumb code */    *(.glue_7t)        /* glue thumb to arm code */    *(.eh_frame)    KEEP (*(.init))    KEEP (*(.fini))    . = ALIGN(4);    _etext = .;        /* define a global symbols at end of code */  } >FLASH  .api_section :  {    . = ALIGN(4);    __api_section_start__ = .;    *(.api_section*)    __api_section_end__ = .;   } > API   ASSERT(LENGTH(API) >= (__api_section_end__ - __api_section_start__), "API memory overflowed !")
tx_initialize_low_leve.S:    .global     _tx_thread_system_stack_ptr    .global     _tx_initialize_unused_memory    .global     _tx_timer_interrupt    .global     __main    .global     __tx_SVCallHandler    .global     __tx_PendSVHandler    .global     __tx_NMIHandler                     @ NMI    .global     __tx_BadHandler                     @ HardFault    .global     __tx_SVCallHandler                  @ SVCall    .global     __tx_DBGHandler                     @ Monitor    .global     __tx_PendSVHandler                  @ PendSV    .global     __tx_SysTickHandler                 @ SysTick    .global     __tx_IntHandler                     @ Int 0    .global     __Vectors#ifdef USE_DYNAMIC_MEMORY_ALLOCATION    .global     Image$$RW_IRAM1$$ZI$$Limit#endif@@SYSTEM_CLOCK      =   160000000SYSTICK_CYCLES    =   ((SYSTEM_CLOCK / 1000) -1)    .text 32    .align 4    .syntax unified

I created static library named "Main_Lib.a" using all source and header files in my Main_Project.

After this point, I created an empty project is named "static_test". In this project, I added "Main_Lib.a", include files etc. After that, added static library to makefile as below but static_test can not find vector table from Main_Lib.a because I do not know how to implement that in empty project from a static library.

Makefile:

static_test.elf static_test.map: $(OBJS) $(USER_OBJS) makefile objects.list $(OPTIONAL_TOOL_DEPS)    arm-none-eabi-gcc -o "static_test.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m4 --specs=nosys.specs -Wl,-Map="static_test.map" -Wl,--gc-sections -static -L"D:\workspace_arge\static_test\Lib" -l:Main_Lib.a -l:STL_Lib.a --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group    @echo 'Finished building target: $@'    @echo ''

Console Error:

D:/workspace_arge/static_lib_creator/Debug/../Src/tx_initialize_low_level.S:548: undefined reference to `g_pfnVectors'

How can I show or add my startup.s, tx_initialize_low_level.S and flash.ld configurations to static_test project?


Viewing all articles
Browse latest Browse all 22192


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>