Skip to content

Commit bdce4ad

Browse files
author
George Rimar
committedFeb 14, 2017
[ELF] - Do sign extend for addends of R_386_8, R_386_16 relocations
Patch makes addends for addends of R_386_8, R_386_16 relocations be sign extended. The same we did earlier for PC ones, currenly LLD fails to link linux kernel, reporting relocation out of range because of this. Differential revision: https://reviews.llvm.org/D29714 llvm-svn: 295052
1 parent 3efdffc commit bdce4ad

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
 

‎lld/ELF/Target.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,9 @@ int64_t X86TargetInfo::getImplicitAddend(const uint8_t *Buf,
491491
default:
492492
return 0;
493493
case R_386_8:
494-
return *Buf;
495494
case R_386_PC8:
496495
return SignExtend64<8>(*Buf);
497496
case R_386_16:
498-
return read16le(Buf);
499497
case R_386_PC16:
500498
return SignExtend64<16>(read16le(Buf));
501499
case R_386_32:
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# REQUIRES: x86
2+
# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
3+
4+
# RUN: ld.lld -Ttext=0x0 %t1.o -o %t.out
5+
# RUN: llvm-objdump -s -t %t.out | FileCheck %s
6+
# CHECK: Contents of section .text:
7+
# CHECK-NEXT: 0000 020100
8+
## 0x3 + addend(-1) = 0x02
9+
## 0x3 + addend(-2) = 0x0100
10+
# CHECK: SYMBOL TABLE:
11+
# CHECK: 00000003 .und
12+
13+
.byte und-1
14+
.short und-2
15+
16+
.section .und, "ax"
17+
und:

0 commit comments

Comments
 (0)
Please sign in to comment.