I'm wondering how I could use 'armlink' to combine or merge a binary image into another image. With the ARM GNU tools, I can do the following:
1) Perform a partial linking (switch '-r') of as input file in binary format (switch '-b binary'). This will generate an ELF object file defined by switch '-o':
% arm-linux-gnueabihf-ld -r -o foo.o -b binary foo.bin
2) Then, one can link the resulting object file to generate a final binary. The "-T" switch points to the link script and "-o" defines the resulting output.
% arm-linux-gnueabihf-ld -T foo.ld foo.o -o output.bin
The linker script may look something like this:
=======
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")SECTIONS{ . = 0x0; .text : {*(.text)#if defined(CONFIG_LOOPSELF_PHYS_ADDR) __foo_start = .; foo.o . = ALIGN(4); __foo_end = .;#endif
}
========
How could I do something similar with the ARM tool chain? I understand that 'armlink' allows for partial linking (--partial switch). But I could not find any 'armlink' switch for binary inputs. Am I missing something?
Also, I found this note on "How to use armlik to combine two images":
https://community.arm.com/community-help/f/discussions/2043/how-to-use-armlik-to-combine-two-images
It describes a different method to possibly achieve the same goal. It involves writing some assembler source that includes the binary in a different section as also defined in the scatter file:
area my_code, code incbin my_code.bin area other_code, code incbin other_code.binend
Is that the only way I can achieve this?
Yes, there are other methods that you could use, some of which are described in the following article:
http://infocenter.arm.com/help/topic/com.arm.doc.faqs/ka15171.html
Also, the following article provides a full example of how the INCBIN method works:
http://infocenter.arm.com/help/topic/com.arm.doc.faqs/ka16368.html
(At some point in the future these articles will be migrated to developer.arm.com.)
.incbin is the equivalent directive for ARM Compiler 6:
https://developer.arm.com/docs/100068/latest/migrating-from-armasm-to-the-armclang-integrated-assembler/miscellaneous-directives