1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Fix the fde encoding used by mips to match gas.

This finally fixes the encoding. The patch also
* Removes eh-frame.ll. It was an unnecessary .ll to .o test that was checking
  the wrong value.
* Merge fde-reloc.s and eh-frame.s into a single test, since the only difference
  was the run lines.
* Don't blindly test the content of the entire .eh_frame section. It makes it
  hard to anyone actually fixing a bug and hitting a difference in a binary
  blob. Instead, use a CHECK for each field and document what is being checked.

llvm-svn: 178615
This commit is contained in:
Rafael Espindola 2013-04-03 03:13:19 +00:00
parent 6a1038a368
commit de2bc5c06e
4 changed files with 164 additions and 113 deletions

View File

@ -223,10 +223,13 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
}
void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
if (T.getArch() != Triple::mips &&
T.getArch() != Triple::mipsel &&
T.getArch() != Triple::mips64 &&
T.getArch() != Triple::mips64el )
if (T.getArch() == Triple::mips ||
T.getArch() == Triple::mipsel)
FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
else if (T.getArch() == Triple::mips64 ||
T.getArch() == Triple::mips64el)
FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
else
FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
if (T.getArch() == Triple::x86) {

View File

@ -1,52 +0,0 @@
; This tests .eh_frame CIE descriptor for the.
; Data alignment factor
; RUN: llc -filetype=obj -mcpu=mips64r2 -mattr=n64 -march=mips64el %s -o - \
; RUN: | llvm-objdump -s - | FileCheck %s
; N64
; CHECK: Contents of section .eh_frame:
; CHECK-NEXT: 0000 1c000000 00000000 017a504c 52000178 .........zPLR..x
; CHECK-NEXT: 0010 1f0b0000 00000000 00000000 000c1d00 ................
; CHECK-NEXT: 0020 2c000000 24000000 00000000 00000000 ,...$...........
; CHECK-NEXT: 0030 7c000000 00000000 08000000 00000000 |...............
; CHECK-NEXT: 0040 00440e10 489f019c 02000000 00000000 .D..H...........
; ModuleID = 'simple_throw.cpp'
@_ZTIi = external constant i8*
@str = private unnamed_addr constant [7 x i8] c"All ok\00"
define i32 @main() {
entry:
%exception.i = tail call i8* @__cxa_allocate_exception(i64 4) nounwind
%0 = bitcast i8* %exception.i to i32*
store i32 5, i32* %0, align 4
invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
to label %.noexc unwind label %return
.noexc: ; preds = %entry
unreachable
return: ; preds = %entry
%1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
catch i8* null
%2 = extractvalue { i8*, i32 } %1, 0
%3 = tail call i8* @__cxa_begin_catch(i8* %2) nounwind
%puts = tail call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @str, i64 0, i64 0))
tail call void @__cxa_end_catch()
ret i32 0
}
declare i32 @__gxx_personality_v0(...)
declare i8* @__cxa_begin_catch(i8*)
declare void @__cxa_end_catch()
declare i8* @__cxa_allocate_exception(i64)
declare void @__cxa_throw(i8*, i8*, i8*)
declare i32 @puts(i8* nocapture) nounwind

View File

@ -1,46 +1,167 @@
// Assembler generated object test.
// This tests .eh_frame descriptors minimally.
// Test the bits of .eh_frame on mips that are already implemented correctly.
// What we really need is a prettyprinter output check not unlike what
// gnu's readobj generates instead of checking the bits for .eh_frame.
// FIXME: This test would be a lot cleaner if llvm-objdump had the
// --dwarf=frames option.
// RUN: llvm-mc -filetype=obj -mcpu=mips32r2 -triple mipsel-unknown-linux -arch=mipsel %s -o - \
// RUN: | llvm-objdump -s - | FileCheck -check-prefix=CHECK-LEO32 %s
// RUN: llvm-mc -filetype=obj %s -o %t.o -arch=mips
// RUN: llvm-objdump -r -s %t.o | FileCheck --check-prefix=MIPS32 %s
// RUN: llvm-mc -filetype=obj -mcpu=mips32r2 -triple mips-unknown-linux -arch=mips %s -o - \
// RUN: | llvm-objdump -s - | FileCheck -check-prefix=CHECK-BEO32 %s
// RUN: llvm-mc -filetype=obj %s -o %t.o -arch=mipsel
// RUN: llvm-objdump -r -s %t.o | FileCheck --check-prefix=MIPS32EL %s
// RUN: llvm-mc -filetype=obj -mcpu=mips64r2 -mattr=n64 -arch=mips64el %s -o - \
// RUN: | llvm-objdump -s - | FileCheck -check-prefix=CHECK-LE64 %s
// RUN: llvm-mc -filetype=obj %s -o %t.o -arch=mips64
// RUN: llvm-objdump -r -s %t.o | FileCheck --check-prefix=MIPS64 %s
// RUN: llvm-mc -filetype=obj -mcpu=mips64r2 -mattr=n64 -arch=mips64 %s -o - \
// RUN: | llvm-objdump -s - | FileCheck -check-prefix=CHECK-BE64 %s
// O32 little endian
// CHECK-LEO32: Contents of section .eh_frame:
// CHECK-LEO32-NEXT: 0000 10000000 00000000 017a5200 017c1f01 .........zR..|..
// CHECK-LEO32-NEXT: 0010 000c1d00 10000000 18000000 00000000 ................
// CHECK-LEO32-NEXT: 0020 00000000 00000000 ........
// O32 big endian
// CHECK-BEO32: Contents of section .eh_frame:
// CHECK-BEO32-NEXT 0000 00000010 00000000 017a5200 017c1f01 .........zR..|..
// CHECK-BEO32-NEXT 0010 000c1d00 00000010 00000018 00000000 ................
// CHECK-BEO32-NEXT 0020 00000000 00000000 ........
// N64 little endian
// CHECK-LE64: Contents of section .eh_frame:
// CHECK-LE64-NEXT: 0000 10000000 00000000 017a5200 01781f01 .........zR..x..
// CHECK-LE64-NEXT: 0010 000c1d00 18000000 18000000 00000000 ................
// CHECK-LE64-NEXT: 0020 00000000 00000000 00000000 00000000 ................
// N64 big endian
// CHECK-BE64: Contents of section .eh_frame:
// CHECK-BE64-NEXT: 0000 00000010 00000000 017a5200 01781f01 .........zR..x..
// CHECK-BE64-NEXT: 0010 000c1d00 00000018 00000018 00000000 ................
// CHECK-BE64-NEXT: 0020 00000000 00000000 00000000 00000000 ................
// RUN: llvm-mc -filetype=obj %s -o %t.o -arch=mips64el
// RUN: llvm-objdump -r -s %t.o | FileCheck --check-prefix=MIPS64EL %s
func:
.cfi_startproc
.cfi_endproc
// MIPS32: RELOCATION RECORDS FOR [.eh_frame]:
// MIPS32-NEXT: R_MIPS_32
// MIPS32: Contents of section .eh_frame:
// MIPS32-NEXT: 0000
// Length
// MIPS32: 00000010
// CIE ID
// MIPS32: 00000000
// Version
// MIPS32: 01
// Augmentation String
// MIPS32: 7a5200
// Code Alignment Factor
// MIPS32: 01
// Data Alignment Factor (-4)
// MIPS32: 7c
// Return Address Register
// MIPS32: 1f
// Augmentation Size
// MIPS32: 01
// MIPS32: .........zR..|..
// MIPS32-NEXT: 0010
// Augmentation (fde pointer encoding: DW_EH_PE_sdata4)
// MIPS32: 0b
// FIXME: The instructions are different from the ones produces by gas.
// MIPS32EL: RELOCATION RECORDS FOR [.eh_frame]:
// MIPS32EL-NEXT: R_MIPS_32
// MIPS32EL: Contents of section .eh_frame:
// MIPS32EL-NEXT: 0000
// Length
// MIPS32EL: 10000000
// CIE ID
// MIPS32EL: 00000000
// Version
// MIPS32EL: 01
// Augmentation String
// MIPS32EL: 7a5200
// Code Alignment Factor
// MIPS32EL: 01
// Data Alignment Factor (-4)
// MIPS32EL: 7c
// Return Address Register
// MIPS32EL: 1f
// Augmentation Size
// MIPS32EL: 01
// MIPS32EL: .........zR..|..
// MIPS32EL-NEXT: 0010
// Augmentation (fde pointer encoding: DW_EH_PE_sdata4)
// MIPS32EL: 0b
// FIXME: The instructions are different from the ones produces by gas.
// MIPS64: RELOCATION RECORDS FOR [.eh_frame]:
// MIPS64-NEXT: R_MIPS_64
// MIPS64: Contents of section .eh_frame:
// MIPS64-NEXT: 0000
// Length
// MIPS64: 00000010
// CIE ID
// MIPS64: 00000000
// Version
// MIPS64: 01
// Augmentation String
// MIPS64: 7a5200
// Code Alignment Factor
// MIPS64: 01
// Data Alignment Factor (-8). GAS uses -4. Should be ok as long as all
// offsets we need are a multiple of 8.
// MIPS64: 78
// Return Address Register
// MIPS64: 1f
// Augmentation Size
// MIPS64: 01
// MIPS64: .........zR..x..
// MIPS64-NEXT: 0010
// Augmentation (fde pointer encoding: DW_EH_PE_sdata8)
// MIPS64: 0c
// FIXME: The instructions are different from the ones produces by gas.
// MIPS64EL: RELOCATION RECORDS FOR [.eh_frame]:
// FIXME: llvm-objdump currently misprints the relocations for mips64el
// MIPS64EL: Contents of section .eh_frame:
// MIPS64EL-NEXT: 0000
// Length
// MIPS64EL: 10000000
// CIE ID
// MIPS64EL: 00000000
// Version
// MIPS64EL: 01
// Augmentation String
// MIPS64EL: 7a5200
// Code Alignment Factor
// MIPS64EL: 01
// Data Alignment Factor (-8). GAS uses -4. Should be ok as long as all
// offsets we need are a multiple of 8.
// MIPS64EL: 78
// Return Address Register
// MIPS64EL: 1f
// Augmentation Size
// MIPS64EL: 01
// MIPS64EL: .........zR..x..
// MIPS64EL-NEXT: 0010
// Augmentation (fde pointer encoding: DW_EH_PE_sdata8)
// MIPS64EL: 0c
// FIXME: The instructions are different from the ones produces by gas.

View File

@ -1,21 +0,0 @@
// This just tests that a relocation of the specified type shows up as the first
// relocation in the relocation section for .eh_frame when produced by the
// assembler.
// RUN: llvm-mc -filetype=obj %s -o - -triple mips-unknown-unknown | \
// RUN: llvm-objdump -r - | FileCheck --check-prefix=MIPS32 %s
// RUN: llvm-mc -filetype=obj %s -o - -triple mips64-unknown-unknown | \
// RUN: llvm-objdump -r - | FileCheck --check-prefix=MIPS64 %s
// PR15448
func:
.cfi_startproc
.cfi_endproc
// MIPS32: RELOCATION RECORDS FOR [.eh_frame]:
// MIPS32-NEXT: R_MIPS_32
// MIPS64: RELOCATION RECORDS FOR [.eh_frame]:
// MIPS64-NEXT: R_MIPS_64