How to convert a GNU linker Script ld to Scatter File (ARM)

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I would like to migrate from GCC to the new ARM COMPILER 6. But I'm not able to well convert the Gnu liker script (ld) to the equivalent of ARM Scatter file.

The Original Code is as following:

arm-none-eabi-ld -T link.ld test.o shared/bootcode.o shared/vertors.o -o test.elf 

Where link.ld script is as following

ENTRY(bootcode) SECTIONS {     . = 0x00000000;      /* Code starts with vectors, then bootcode, then other code */     .text :     {         *vectors.o(vectors)         *bootcode.o(boot)         *(.text) /* remainder of code */     } =0      .data : { *(.data) }     .bss  : { *(.bss)  }     /* Notes section     * This is not used so we discard it. Although not used it needs to be     * explicitly mentioned in the linker script as some toolchains will place     * the notes section at adderss 0 if it is not explicitly mentioned*/     /DISCARD/ : { *(.note*) }     } 

I would like to use armlink as a linker :

armlink --cpu=8-A.32 --entry=bootcode test.o shared/bootcode.o shared/vertors.o -o test.elf --scatter=ld.scat 

But I did not succeed in Creating a valid scatter File. I tried to play with the armlink options (--first, --last, --ro_base, --rw_base) but nothing went as expected (I'm getting successful compilation but the test is not working).

Any Idea on that please?

回答1:

I looked at the documentation here: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0803d/pge1362065973150.html

The GNU Linker Script you want to migrate can be rewritten as:

LOAD_ROM 0x0000               {     EXEC_ROM_1 0x0000   ; Name of first exec region (EXEC_ROM_1),                         ; Start address for exec region (0x0000)     {         vectors.o(VECTORS)         * (InRoot$$Sections)  ; All library sections that must be in a                               ; root region, for example, __main.o,                               ; __scatter*.o, __dc*.o, and * Region$$Table      }     EXEC_ROM_2 +0    ; Name of second exec region (EXEC_ROM_2)     {         bootcode.o(BOOT, +FIRST)         * (+RO)     }     SRAM +0      ; Name of third exec region (SRAM)     {         * (+RW, +ZI)         ; Place all RW and ZI data into                              ; this exec region     } } 

In order to specify the entry point of your image you can use the command line option --entry=bootcode as you already specified in your command line.

armlink --cpu=8-A.32 --entry=bootcode test.o shared/bootcode.o shared/vertors.o -o test.elf --scatter=ld.scat 


回答2:

armlink allows reading of GNU LD linker script, however, with restrictions. The flag is "--linker_script=ld_script".



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!