[PATCH] D29270: [ELF] - Change i386 i386-pc8.s/i386-pc16.test to work with 8/16 bits values accordingly.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 02:25:19 PST 2017


grimar created this revision.

It was requested by Rui to change these tests, because they fail after changing implementation of relocateOne to next:

  void X86TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
                                  uint64_t Val) const {
  ...
    switch (Type) {
    case R_386_8:
    case R_386_PC8:
      checkInt<8>(Loc, Val, Type);
      *Loc = Val;
      break;
    case R_386_16:
    case R_386_PC16:
      checkInt<16>(Loc, Val, Type);
      write16le(Loc, Val);
      break;
  ...
  }

Though ABI says "The R_386_16, and R_386_8 relocations truncate the computed value to 16-bits and 8-bits respectively".
ld.bfd errors on such inputs, ld.gold accepts them.

And because of using word "truncate" it is not clear for me what behavior is correct. Seems LLD and gold just follows ABI and
bfd performs additional checks. I have no arguments for doing or not doing that change.


https://reviews.llvm.org/D29270

Files:
  test/ELF/i386-pc16.test
  test/ELF/i386-pc8.s


Index: test/ELF/i386-pc8.s
===================================================================
--- test/ELF/i386-pc8.s
+++ test/ELF/i386-pc8.s
@@ -1,11 +1,11 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
 # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %S/Inputs/i386-pc8.s -o %t2.o
-# RUN: ld.lld %t1.o %t2.o -o %t.out
+# RUN: ld.lld -Ttext 0x0 %t1.o %t2.o -o %t.out
 # RUN: llvm-objdump -s -section=.text %t.out | FileCheck %s
 
 # CHECK:      Contents of section .text:
-# CHECK-NEXT:  11000 15253748
+# CHECK-NEXT:  0000 15253748
 
 .byte und-.+0x11
 .byte und-.+0x22
Index: test/ELF/i386-pc16.test
===================================================================
--- test/ELF/i386-pc16.test
+++ test/ELF/i386-pc16.test
@@ -1,11 +1,11 @@
 # REQUIRES: x86
 
 # RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t.exe
+# RUN: ld.lld -Ttext 0x0 %t.o -o %t.exe
 # RUN: llvm-objdump -s -section=.text %t.exe 2>&1 | FileCheck %s
 
 # CHECK:      Contents of section .text:
-# CHECK-NEXT:  11000 56441111 52341111
+# CHECK-NEXT:  0000 45231111 41231111
 
 !ELF
 FileHeader:
@@ -36,5 +36,5 @@
     - Name:     _start
       Type:     STT_FUNC
       Section:  .text
-      Value:    0x12345
+      Value:    0x1234
       Size:     4


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29270.86256.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170130/865719a8/attachment.bin>


More information about the llvm-commits mailing list