tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] strange behavior when linking with gcc compiled objec


From: grischka
Subject: Re: [Tinycc-devel] strange behavior when linking with gcc compiled object file
Date: Sat, 16 Jul 2016 19:27:05 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Jin Qian wrote:
I even did the experiment by modifying the few bytes of machine code in gcc compiled object file just to make it look like tcc compiled, then linking with tcc produced a good exe. Any ideas why tcc does this, why is the "-4" offset in lea instruction?

You are using objcopy to convert PE-COFF objects from gcc/mingw
to ELF for tcc.

COFF and ELF have different ideas where the relative displacement
starts:

     48 8d 0d XX XX XX XX ...
                          ^
                          COFF/DISP32 displacement start

     48 8d 0d XX XX XX XX ...
              ^
              ELF/R_XXX_PC32 displacement start

     48 8d 0d XX XX XX XX ...
                          ^
                          x86 machine displacement start

Which means that for ELF on x86, the actual distance is shorter by 4.

Objcopy ignores this.  Looks like a bug in objcopy.

-- gr




reply via email to

[Prev in Thread] Current Thread [Next in Thread]