Reapply 222538 and update tests to explicitly request small code model
authorJoerg Sonnenberger <joerg@bec.de>
Tue, 25 Nov 2014 13:37:55 +0000 (13:37 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Tue, 25 Nov 2014 13:37:55 +0000 (13:37 +0000)
and PIC:

Allow FDE references outside the +/-2GB range supported by PC relative
offsets for code models other than small/medium. For JIT application,
memory layout is less controlled and can result in truncations
otherwise.

Patch from Akos Kiss.

Differential Revision: http://reviews.llvm.org/D6079

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222760 91177308-0d34-0410-b5e6-96231b3b80d8

21 files changed:
lib/MC/MCObjectFileInfo.cpp
test/MC/ELF/cfi-adjust-cfa-offset.s
test/MC/ELF/cfi-advance-loc2.s
test/MC/ELF/cfi-def-cfa-offset.s
test/MC/ELF/cfi-def-cfa-register.s
test/MC/ELF/cfi-def-cfa.s
test/MC/ELF/cfi-escape.s
test/MC/ELF/cfi-offset.s
test/MC/ELF/cfi-register.s
test/MC/ELF/cfi-rel-offset.s
test/MC/ELF/cfi-rel-offset2.s
test/MC/ELF/cfi-remember.s
test/MC/ELF/cfi-restore.s
test/MC/ELF/cfi-same-value.s
test/MC/ELF/cfi-signal-frame.s
test/MC/ELF/cfi-undefined.s
test/MC/ELF/cfi-window-save.s
test/MC/ELF/cfi-zero-addr-delta.s
test/MC/ELF/cfi.s
test/MC/ELF/pr19430.s
test/MC/X86/fde-reloc.s

index 7886ab62ca5557286e7640a817b0bf5bc2c2b2c7..96929e59385f7b8bee6648de9a66f96fc3b17fed 100644 (file)
@@ -273,6 +273,17 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
   case Triple::mips64el:
     FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
     break;
   case Triple::mips64el:
     FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
     break;
+  case Triple::x86_64:
+    if (RelocM == Reloc::PIC_) {
+      FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
+        ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
+         ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
+    } else {
+      FDECFIEncoding =
+        (CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
+        ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
+    }
+    break;
   default:
     FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
     break;
   default:
     FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
     break;
index 9d639f70d8ddb9ed12b08f1b26ff26a00960256d..f31a6b0acd6dc52ae3d9eda7d6bddf6459836cc3 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 98caa0185f59f4758d2924084a5d93ec89a3d38f..c11ccaf51ee287eb20ea6b9b7b352f398d0462b0 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 // test that this produces a correctly encoded cfi_advance_loc2
 
 
 // test that this produces a correctly encoded cfi_advance_loc2
 
index 59f740055d47253f3252c2d0a4e693104106f07b..93158ce22fbb8e660b9326eb1d7178b2434d3f23 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 178ba32882dcafbe4be1f6a83354f6c0e5c59029..8c550534b2f1393dcd46c4e57a24f058643665f5 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index dfb0d4b59396254ffbbb02d16047a68799647976..f0b493403ca18d0c542cb07914dbad786edd864b 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 5394ee414aa771add8603d895a53ebefed9d976d..3b7674640c72a18c24d9c58788b2c61240ba7c74 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index a65b4fc783c7166a6832907fe28e0bf2f2d80c31..02f31ba3ca1481aa40603dfd4f4c4b0d1928816a 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 94417702c13ca7fafabf366acd6d7eb497798c8c..3433bef8cde91456ff6e6fe0d77368feaf9e077d 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 0dc69c89cf4c0f94e0d02950884fd8d52c1567d6..f51b2d359391d9603f5fe24d56d5305ffcc4702f 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 360e7b0ea0f5807faaf386adbf3c491bf7b57edd..0ce8d038d9b55ad76409a4a2326b9fb3e5973930 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 3a38948b6a3ec3d4403e04dfc6c65325c6bd4384..c98695a4fe9743a9028ecf98e94ef141c9d3c637 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index e225797f54d66cf182f81931b25b2d3c5fe9b928..99a74e73e43ebc6c4d0914ce581289b201179ab5 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 2d37f4d0b43e4a0f54df40770734e8e92b91e9f8..b7329d17cfb7f45cde321870aafa54ba63156b27 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index 98deb0a1de5c145601e26678aa732f8883a3b153..9558d7bb5dccbbcdbd3ac6af8aec5674f1e0011a 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sd | FileCheck %s
 
 f:
         .cfi_startproc
 
 f:
         .cfi_startproc
index 568b3159cc44ca11aaa6966fb41822976d8f5d1f..09000c9627cf51d629ead023f2900637bc52cb99 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f:
        .cfi_startproc
 
 f:
        .cfi_startproc
index b083901c137ae8902f67f39aaaf1fef7b308b92f..dd20164070e9a7c4e143291a3114a920c878a95d 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 # Should use SPARC as the target to test this. However, SPARC does not
 # use MC yet.
 
 # Should use SPARC as the target to test this. However, SPARC does not
 # use MC yet.
index 8662839b5274a48567793a83154302eed1a395a7..61118ecec36785c1399a79b9836989b66bd28c6b 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 // Test that we don't produce a DW_CFA_advance_loc 0
 
 
 // Test that we don't produce a DW_CFA_advance_loc 0
 
index 21be615c5f39d2d823741cc41cb33fb069213b3c..42b0189ea603e82ccae58f5ba5c34fcc735ec964 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -sd | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -s -sr -sd | FileCheck %s
 
 f1:
         .cfi_startproc
 
 f1:
         .cfi_startproc
index a1e524662a965218f04c5057e42185e68447c130..528193d60aed97604be98d9990789f647c01e815 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -filetype=obj -o - | llvm-readobj -r | FileCheck %s
+// RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -filetype=obj -o - \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-readobj -r | FileCheck %s
 
 // Test that we can use .cfi_startproc without a global symbol.
 
 
 // Test that we can use .cfi_startproc without a global symbol.
 
index 63ac976621884bb2abfd6cd9d200b073b14c3bf3..9b5de15f9ed7f8a5a38dcb78d21f17ab6a85d40a 100644 (file)
@@ -1,4 +1,6 @@
-// RUN: llvm-mc -filetype=obj %s -o - -triple x86_64-pc-linux | llvm-objdump -r - | FileCheck --check-prefix=X86-64 %s
+// RUN: llvm-mc -filetype=obj %s -o - -triple x86_64-pc-linux \
+// RUN: -relocation-model=pic -code-model=small \
+// RUN: | llvm-objdump -r - | FileCheck --check-prefix=X86-64 %s
 // RUN: llvm-mc -filetype=obj %s -o - -triple i686-pc-linux | llvm-objdump -r - | FileCheck --check-prefix=I686 %s
 
 // PR15448
 // RUN: llvm-mc -filetype=obj %s -o - -triple i686-pc-linux | llvm-objdump -r - | FileCheck --check-prefix=I686 %s
 
 // PR15448