DSP

uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(52):__ebss_l1

2019-07-13 15:40发布

  快乐虾 http://blog.csdn.net/lights_joy/ lights@hb165.com   本文适用于 ADI bf561 DSP 优视BF561EVB开发板 uclinux-2008r1.5-rc3(smp patch) Visual DSP++ 5.0(update 5)   欢迎转载,但请保留作者信息   有一个链接错误: [Error li1021]  The following symbols referenced in processor 'p0' could not be resolved:         '_ebss_l1 [__ebss_l1]' referenced from 'arch-kernel.dlb[setup.doj]'         '_sdata_l1 [__sdata_l1]' referenced from 'arch-kernel.dlb[setup.doj]' 引发这个链接错误的原因在setup_arch函数的末尾,有这样的语句:        /* Copy atomic sequences to their fixed location, and sanity check that         these locations are the ones that we advertise to userspace.  */      memcpy((void *)FIXED_CODE_START, &fixed_code_start,             FIXED_CODE_END - FIXED_CODE_START);      BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start             != SIGRETURN_STUB - FIXED_CODE_START);      BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start             != ATOMIC_XCHG32 - FIXED_CODE_START);      BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start             != ATOMIC_CAS32 - FIXED_CODE_START);      BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start             != ATOMIC_ADD32 - FIXED_CODE_START);      BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start             != ATOMIC_SUB32 - FIXED_CODE_START);      BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start             != ATOMIC_IOR32 - FIXED_CODE_START);      BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start             != ATOMIC_AND32 - FIXED_CODE_START);      BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start             != ATOMIC_XOR32 - FIXED_CODE_START);      BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start          != SAFE_USER_INSTRUCTION - FIXED_CODE_START); 在这里,FIXED_CODE_START等几个定义都在include/asm/fixed_code.h中: ///* This file defines the fixed addresses where userspace programs can find //   atomic code sequences.  */ // #define FIXED_CODE_START    0x400 // #define SIGRETURN_STUB      0x400 // #define ATOMIC_SEQS_START   0x410 // #define ATOMIC_XCHG32       0x410 #define ATOMIC_CAS32        0x420 #define ATOMIC_ADD32        0x430 #define ATOMIC_SUB32        0x440 #define ATOMIC_IOR32        0x450 #define ATOMIC_AND32        0x460 #define ATOMIC_XOR32        0x470 // #define ATOMIC_SEQS_END     0x480 // #define SAFE_USER_INSTRUCTION   0x480 // #define FIXED_CODE_END      0x490 // fixed_code_start则是arch/ blackfin/ kernel/fixed_code.s中定义的一个符号。在fixed_code.s中有一段说明: /*  * This file contains sequences of code that will be copied to a  * fixed location, defined in .  The interrupt  * handlers ensure that these sequences appear to be atomic when  * executed from userspace.  * These are aligned to 16 bytes, so that we have some space to replace  * these sequences with something else (e.g. kernel traps if we ever do  * BF561 SMP).  */ 但是实在不明白为什么要将这些代码复制到这个固定的位置?? 这段代码引发的__ebss_l1符号链接错误,它的定义在vmlinux.lds.s中: #if L1_DATA_A_LENGTH # define LDS_L1_A_DATA  *(.l1.data) # define LDS_L1_A_BSS   *(.l1.bss) # define LDS_L1_A_CACHE *(.data_l1.cacheline_aligned) #else # define LDS_L1_A_DATA # define LDS_L1_A_BSS # define LDS_L1_A_CACHE #endif .data_l1 L1_DATA_A_START : AT(LOADADDR(.text_l1) + SIZEOF(.text_l1))      {          . = ALIGN(4);          __sdata_l1 = .;          LDS_L1_A_DATA          __edata_l1 = .;            . = ALIGN(4);          __sbss_l1 = .;          LDS_L1_A_BSS            . = ALIGN(32);          LDS_L1_A_CACHE            . = ALIGN(4);          __ebss_l1 = .;      } 很明显,它将L1_DATA_A这块内存划分为普通数据,BSS数据和CACHE 因此相应地在LDF文件中进行修改:       L1_data_a_1       {          INPUT_SECTION_ALIGN(4)          ___l1_data_cache_a = 0;          INPUT_SECTIONS($OBJECTS_CORE_A(L1_data_a) $LIBRARIES_CORE_A(L1_data_a))          INPUT_SECTIONS($OBJECTS_CORE_A(.data_l1.cacheline_aligned) $LIBRARIES_CORE_A(.data_l1.cacheline_aligned))                   /*$VDSG  */          /* Text inserted between these $VDSG comments will be preserved */          /*$VDSG  */                   RESERVE(heaps_and_stack_in_L1_data_a, heaps_and_stack_in_L1_data_a_length = 2048,4)       } > MEM_A_L1_DATA_A         L1_data_a_bsz ZERO_INIT       {          INPUT_SECTION_ALIGN(4)          INPUT_SECTIONS( $OBJECTS_CORE_A(L1_bsz) $LIBRARIES_CORE_A(L1_bsz))       } > MEM_A_L1_DATA_A         L1_data_a       {          INPUT_SECTION_ALIGN(4)                __sdata_l1 = .;                                INPUT_SECTIONS($OBJECTS_CORE_A{DualCoreMem("CoreA")}(cplb_data) $LIBRARIES_CORE_A{DualCoreMem("CoreA")}(cplb_data))          INPUT_SECTIONS($OBJECTS_CORE_A(cplb_data) $LIBRARIES_CORE_A(cplb_data))          INPUT_SECTIONS($OBJECTS_CORE_A(voldata) $LIBRARIES_CORE_A(voldata))          INPUT_SECTIONS($OBJECTS_CORE_A(constdata) $LIBRARIES_CORE_A(constdata))          INPUT_SECTIONS($OBJS_LIBS_INTERNAL_CORE_A(data1))          INPUT_SECTIONS($OBJS_LIBS_NOT_EXTERNAL_CORE_A(data1))          INPUT_SECTIONS($OBJECTS_CORE_A(data1) $LIBRARIES_CORE_A(data1))          INPUT_SECTIONS($OBJECTS_CORE_A(.edt) $LIBRARIES_CORE_A(.edt))          INPUT_SECTIONS($OBJECTS_CORE_A(.cht) $LIBRARIES_CORE_A(.cht))          INPUT_SECTIONS($OBJECTS_CORE_A(.l1.data) $LIBRARIES_CORE_A(.l1.data))                   /*$VDSG  */          /* Text inserted between these $VDSG comments will be preserved */          /*$VDSG  */                __edata_l1 = .;       } > MEM_A_L1_DATA_A         bsz_L1_data_a ZERO_INIT       {          INPUT_SECTION_ALIGN(4)                __sbss_l1 = .;                                INPUT_SECTIONS($OBJECTS_CORE_A(bsz) $LIBRARIES_CORE_A(bsz))                INPUT_SECTIONS($OBJECTS_CORE_A(.l1.bss) $LIBRARIES_CORE_A(.l1.bss))                                __ebss_l1 = .;                     } > MEM_A_L1_DATA_A         L1_data_a_stack_heap       {          INPUT_SECTION_ALIGN(4)          RESERVE_EXPAND(heaps_and_stack_in_L1_data_a, heaps_and_stack_in_L1_data_a_length , 0, 4)          ldf_heap_space = heaps_and_stack_in_L1_data_a;          ldf_heap_end = (ldf_heap_space + (heaps_and_stack_in_L1_data_a_length - 4)) & 0xfffffffc;          ldf_heap_length = ldf_heap_end - ldf_heap_space;       } > MEM_A_L1_DATA_A 在这里仍然保留了VDSP向导对heap的定义,因为不知道要引用的VDSP库中是否要使用malloc这样的函数来分配内存。    

1       参考资料

uclinux-2008R1.5-RC3(bf561)VDSP5的移植(47)per_cpu的奇怪问题(2009-1-22) uclinux-2008R1.5-RC3(bf561)VDSP5的移植(48)__start___param(2009-1-22) uclinux-2008R1.5-RC3(bf561)VDSP5的移植(49)likely(2009-1-24) uclinux-2008R1.5-RC3(bf561)VDSP5的移植(50).spinlock.text(2009-1-24) uclinux-2008R1.5-RC3(bf561)VDSP5的移植(51)CONFIG_LOG_BUF_SHIFT(2009-1-24)