[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] "error: invalid displacement" i386 1f 'L..1' does not
Re: [Tinycc-devel] "error: invalid displacement" i386 1f 'L..1' does not get resolved
Wed, 20 Apr 2022 17:04:45 +0200 (CEST)
Alpine 2.21 (LSU 202 2017-01-01)
On Sun, 17 Apr 2022, Volodymyr Boyko wrote:
I'm trying to assemble the following snippet of code:
1: jmp ___setjmp
but getting this error:
src/signal/i386/sigsetjmp.s:8: error: invalid displacement
After renaming/moving the label around I assume the issue is that local
labels cannot be forward;1b and my_label moved to the top do work fine.
Yeah, it's related to that, but specific to the 'jexcz' opcode: the
special thing about it is that it only comes in an 8-bit displacement form
_and_ doesn't have an inverse form. TCC, being single-pass, has to assume
that forward labels could be anywhere, and hence potentially need a 32bit
form (no matter that _in this case_ it would turn out to not be
necessary), so jumps are rewritten into their disp32 forms for such
labels. For jecxz that can't be done. And as the inverse form doesn't
exist we can't even work around this by emitting something like a
jecxnz +5 ; doesn't exist!
The GNU assembler uses multiple passes to figure out that the displacement
in the testcase turns out to fit into a disp8 field and hence all is well.
Add a couple more opcodes between the jecxz and the 1: label to make the
distance larger than 128 and see it erroring out as well.
Supporting this requires some surgery (e.g. to support the _PC8 relocation
and emitting them for this case only), so is of low priority.