You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For JUMP instructions using an absolute/constant symbol as an argument, binutils-esp32ulp produces a different output depending on whether that symbol is exported with .global or not. This appears to be a bug.
The following example code can be used to reproduce the issue:
.set const,12 .globalconstentry: jump const
Assemble and link the example as follows:
base=global_bug # given the source is called "global_bug.s"
esp32ulp-elf-as -o ${base}.o ${base}.s
esp32ulp-elf-ld -T esp32.ulp.ld -o ${base}.elf ${base}.o
esp32ulp-elf-objcopy -O binary ${base}.elf ${base}.bin
Inspect the binary output as follows:
xxd global_bug.bin
Current behaviour
When building the example code as is, the binary result is:
Notice how the addr field is different. In fact in the second case (not global) the symbol value has been divided by 4.
I assume this is related to address translation from bytes to words, however the behaviour should at least be consistent, no matter whether a symbol is marked global or not.
Expected behaviour
I would expect the correct behaviour to be, that the JUMP instruction uses the symbol value as is (ie. addr == 12 - not divided by 4).
Furthermore, the JUMPR and JUMPS instructions behave that way too (i.e. they use those symbol values without conversion), irrespective of whether the symbol is marked global or not.
The text was updated successfully, but these errors were encountered:
Overview
For JUMP instructions using an absolute/constant symbol as an argument, binutils-esp32ulp produces a different output depending on whether that symbol is exported with
.global
or not. This appears to be a bug.The following example code can be used to reproduce the issue:
Assemble and link the example as follows:
Inspect the binary output as follows:
Current behaviour
When building the example code as is, the binary result is:
However, when commenting out (or removing) the line
.global const
- in other wordsconst
is NOT exported, then the binary result becomes:Notice the last (JUMP) instruction is different:
3000 0080
vs0c00 0080
.Decoding those two, I get
Notice how the
addr
field is different. In fact in the second case (not global) the symbol value has been divided by 4.I assume this is related to address translation from bytes to words, however the behaviour should at least be consistent, no matter whether a symbol is marked global or not.
Expected behaviour
I would expect the correct behaviour to be, that the JUMP instruction uses the symbol value as is (ie.
addr == 12
- not divided by 4).This would match how the ESP32 ULP coprocessor instruction set documentation describes that arguments, which are constants rather than labels, are used without conversion.
Furthermore, the
JUMPR
andJUMPS
instructions behave that way too (i.e. they use those symbol values without conversion), irrespective of whether the symbol is marked global or not.The text was updated successfully, but these errors were encountered: