https://sourceware.org/bugzilla/show_bug.cgi?id=17099

Toni Spets <toni.spets at iki dot fi> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |toni.spets at iki dot fi

--- Comment #1 from Toni Spets <toni.spets at iki dot fi> ---
Created attachment 8262
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8262&action=edit
Add support for absolute relocations

I've also encountered this issue and it makes some interesting absolute
jump/call tricks impossible with assembly. The workaround I've been using is to
use ELF32 object files for ld so they are relocated properly. The only downside
is that it seems to be impossible to get GCC/AS to output in non-default object
format so I had to use NASM with -f elf.

This patch takes absolute R_PCRLONG type relocations into account and adjusts
the relative address.

I don't know if this is the correct fix, but it provides me correct results. In
addition because this edge case throws assertion error without this change, at
worst it would produce incorrect results rather than asserts.

The simple test case would be something like (in GNU as):

-- test.s --
_main:
    nop
    nop
    jmp 0x12345678
    call 0x12345678
-- /test.s --

i686-w64-mingw32-gcc -c test.s
./ld-new test.o
i686-w64-mingw32-objdump -d a.exe

...
00401000 <_start>:
  401000:       90                      nop
  401001:       90                      nop
  401002:       e9 71 46 f4 11          jmp    12345678
<___crt_xc_end__+0x11f42678>
  401007:       e8 6c 46 f4 11          call   12345678
<___crt_xc_end__+0x11f42678>
  40100c:       c3                      ret
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to