[PATCH] D29392: [ELF] - Change value checks to checkUInt for R_386_8/R_386_PC8/R_386_16/R_386_PC16 relocations.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 03:25:09 PST 2017

grimar added a comment.

In https://reviews.llvm.org/D29392#663412, @ruiu wrote:

> Can you describe why this is correct? Relaxing the error checks until the kernel links is not a good idea.
> I believe you should use checkUInt for R_386_{8,16} and checkInt for R_386_PC{8,16}.

Reproduce I have fails on R_386_PC16 relocation with value 0x000000000000fda3.

In code that place looks like:

  jmp	trampoline_start

disasm of LLD linked is:

  125a:	e9 a3 fd f4 eb       	jmp    ebf51002 <intcall+0xebf4bdaa>

BFD linked:

  125a:	e9 a3 fd f4 eb       	jmp    ebf51002 <end_signature+0xebf4bdae>

So as you see output is equal.
But BFD accepts the input, LLD - not. That unfortunately all usefull info I have now.

I switched to minimal kernel configuration yesterday and it looks does not use this object anymore (it does not generate it at all).
So we can return to that question a bit later, when I'll be able to check that place separatelly.

(I really doubt there is something wrong with that place. All I can do is try to change it and see if that is breaks anything, for my eye now
 it looks just like a regular jump).

In https://reviews.llvm.org/D29392#663429, @davide wrote:

> Sorry to say that, but this doesn't seem quite right to me. We should really understand why that check fails and not silencing it.
>  It could be anything from a linker bug (including, the broken check itself) from the assembler emitting a broken object (BTW, which assembler are you using?)

Hard to say what is right here, ABI says "The R_386_16, and R_386_8 relocations truncate the computed value to 16-bits and 8-bits respectively.",
doing any checks is not what corresponds the ABI and gnu linkers have different behavior here.

I will try to check the place above and I just guess if we want do checks and don't want to follow ABI,
 we probably will want to be compatible with BFD. Will see.

I use:
as -V
GNU assembler version 2.27 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.27
for working on kernel linkage.


More information about the llvm-commits mailing list