1

I'm trying to assemble some basic testing code for an embedded device I'm reverse-engineering, which runs little-endian xtensa threadx. From googling the only assembler that seems to support xtensa in my linux distro's repos (fedora) is GNU Assembler (xtensa-linux-gnu-as).

However when assembling code the output is always big-endian, with seemingly no way to change it to little-endian. Typical relevant GNU assembler options for other architectures (-mlittle-endian, -EL) don't seem to be supported for xtensa.

Is there some obscure way I couldn't find to make xtensa-linux-gnu-as output little endian? Or some other alternate assembler I can use instead that does?

Example assembly for xtensa-linux-gnu-as:

.int 0x12345678

Assembled output hex dump:

00000000: 1234 5678                                .4Vx

1 Answer 1

2

GNU binutils version 2.40 or newer support dynamic xtensa core configuration. It can be built with the following project: https://github.com/jcmvbkbc/xtensa-dynconfig/tree/original using xtensa configuration overlay of your specific core or one of the predefined cores available here: https://github.com/jcmvbkbc/xtensa-toolchain-build/tree/master/overlays/original

As an example the following script builds dynconfig library for the esp32s3:

git clone https://github.com/jcmvbkbc/xtensa-dynconfig -b original
git clone https://github.com/jcmvbkbc/config-esp32s3 esp32s3
make -C xtensa-dynconfig ORIG=1 CONF_DIR=`pwd` esp32s3.so

export XTENSA_GNU_CONFIG=`pwd`/xtensa-dynconfig/esp32s3.so

If you run the assembler with the XTENSA_GNU_CONFIG environment variable set as shown above it will generate fairly generic code for little-endian xtensa.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.