1

Let's say I have an object file (elf file) created from asm source:

.text
.code 32
    MOV R1, #10
    LDR R2, [R1]
.string "hello world"
fun1:
    MOV R1, #1
    LDR R2, =_symbol1
    LDR R3, =_symbol2
    b _reset
.end

Running arm-elf-nm gives me symbols:

U _reset
U _symbol1
U _symbol2
t fun1

So the 3 symbols used to load some addresses to registers are undefined. Now let's use arm-elf-objcopy to make a binary file. I assume that the binary file consinsts of plain bits, no relocation whatsoever.

My question is: will the _symbol1 and _symbol2 be replaced with 0's if they were undefined? On the other hand, if they were defined,

.equ _symbol1 0x400
.equ _symbol2 0x500

would they be replaced with those values?

Bart
  • 420
  • 3
  • 18
  • 3
    I don't know. What happened when you tried it? :-) – paxdiablo Nov 27 '13 at 07:57
  • Well I haven't parsed the .bin file, I will try to decode the instructions and see what happens. But I was counting on getting a confirmation from a hypothetical point of view. – Bart Nov 27 '13 at 08:06
  • Afaik assembler doesn't do link step, and pretty much loose about asking addresses. So you should get some default bit patterns. – auselen Nov 27 '13 at 09:31
  • 1
    Yes, I forgot that I cannot have an executable file without the linking. When some symbols are undefined, linker will display errors. The .bin file has to be created out of the .elf file produced by the linker, when all symbol addresses are known. – Bart Nov 27 '13 at 12:34

0 Answers0