diff options
author | Tim Northover <Tim.Northover@arm.com> | 2012-12-07 16:50:23 +0000 |
---|---|---|
committer | Tim Northover <Tim.Northover@arm.com> | 2012-12-07 16:50:23 +0000 |
commit | 6eb3e87df04f8b035562d9865292c23f5b79f1a2 (patch) | |
tree | 189363ed072d39585a62b2cd032333fead485a1e /test/MC | |
parent | 69c0239a2673ea97e2adbcf0562dc2396b5df35c (diff) | |
download | external_llvm-6eb3e87df04f8b035562d9865292c23f5b79f1a2.zip external_llvm-6eb3e87df04f8b035562d9865292c23f5b79f1a2.tar.gz external_llvm-6eb3e87df04f8b035562d9865292c23f5b79f1a2.tar.bz2 |
Added Mapping Symbols for ARM ELF
Before this patch, when you objdump an LLVM-compiled file, objdump tried to
decode data-in-code sections as if they were code. This patch adds the missing
Mapping Symbols, as defined by "ELF for the ARM Architecture" (ARM IHI 0044D).
Patch based on work by Greg Fitzgerald.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169609 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/MC')
-rw-r--r-- | test/MC/ARM/data-in-code.ll | 176 | ||||
-rw-r--r-- | test/MC/ARM/elf-reloc-01.ll | 4 | ||||
-rw-r--r-- | test/MC/ARM/elf-reloc-02.ll | 6 | ||||
-rw-r--r-- | test/MC/ARM/elf-reloc-03.ll | 6 | ||||
-rw-r--r-- | test/MC/ARM/elf-reloc-condcall.s | 12 | ||||
-rw-r--r-- | test/MC/ARM/elf-thumbfunc-reloc.ll | 4 | ||||
-rw-r--r-- | test/MC/ARM/elf-thumbfunc.s | 2 | ||||
-rw-r--r-- | test/MC/ARM/mapping-within-section.s | 33 | ||||
-rw-r--r-- | test/MC/ARM/multi-section-mapping.s | 35 | ||||
-rw-r--r-- | test/MC/ARM/relocated-mapping.s | 11 |
10 files changed, 272 insertions, 17 deletions
diff --git a/test/MC/ARM/data-in-code.ll b/test/MC/ARM/data-in-code.ll new file mode 100644 index 0000000..c2feec5 --- /dev/null +++ b/test/MC/ARM/data-in-code.ll @@ -0,0 +1,176 @@ +;; RUN: llc -O0 -mtriple=armv7-linux-gnueabi -filetype=obj %s -o - | \ +;; RUN: elf-dump | FileCheck -check-prefix=ARM %s + +;; RUN: llc -O0 -mtriple=thumbv7-linux-gnueabi -filetype=obj %s -o - | \ +;; RUN: elf-dump --dump-section-data | FileCheck -check-prefix=TMB %s + +;; Ensure that if a jump table is generated that it has Mapping Symbols +;; marking the data-in-code region. + +define void @foo(i32* %ptr) nounwind ssp { + %tmp = load i32* %ptr, align 4 + switch i32 %tmp, label %default [ + i32 11, label %bb0 + i32 10, label %bb1 + i32 8, label %bb2 + i32 4, label %bb3 + i32 2, label %bb4 + i32 6, label %bb5 + i32 9, label %bb6 + i32 15, label %bb7 + i32 1, label %bb8 + i32 3, label %bb9 + i32 5, label %bb10 + i32 30, label %bb11 + i32 31, label %bb12 + i32 13, label %bb13 + i32 14, label %bb14 + i32 20, label %bb15 + i32 19, label %bb16 + i32 17, label %bb17 + i32 18, label %bb18 + i32 21, label %bb19 + i32 22, label %bb20 + i32 16, label %bb21 + i32 24, label %bb22 + i32 25, label %bb23 + i32 26, label %bb24 + i32 27, label %bb25 + i32 28, label %bb26 + i32 23, label %bb27 + i32 12, label %bb28 + ] + +default: + br label %exit +bb0: + br label %exit +bb1: + br label %exit +bb2: + br label %exit +bb3: + br label %exit +bb4: + br label %exit +bb5: + br label %exit +bb6: + br label %exit +bb7: + br label %exit +bb8: + br label %exit +bb9: + br label %exit +bb10: + br label %exit +bb11: + br label %exit +bb12: + br label %exit +bb13: + br label %exit +bb14: + br label %exit +bb15: + br label %exit +bb16: + br label %exit +bb17: + br label %exit +bb18: + br label %exit +bb19: + br label %exit +bb20: + br label %exit +bb21: + br label %exit +bb22: + br label %exit +bb23: + br label %exit +bb24: + br label %exit +bb25: + br label %exit +bb26: + br label %exit +bb27: + br label %exit +bb28: + br label %exit + + +exit: + + ret void +} + +;; ARM: # Symbol 2 +;; ARM-NEXT: $a +;; ARM-NEXT: 'st_value', 0x00000000 +;; ARM-NEXT: 'st_size', 0x00000000 +;; ARM-NEXT: 'st_bind', 0x0 +;; ARM-NEXT: 'st_type', 0x0 +;; ARM-NEXT: 'st_other' +;; ARM-NEXT: 'st_shndx', [[MIXED_SECT:0x[0-9a-f]+]] + +;; ARM: # Symbol 3 +;; ARM-NEXT: $a +;; ARM-NEXT: 'st_value', 0x000000ac +;; ARM-NEXT: 'st_size', 0x00000000 +;; ARM-NEXT: 'st_bind', 0x0 +;; ARM-NEXT: 'st_type', 0x0 +;; ARM-NEXT: 'st_other' +;; ARM-NEXT: 'st_shndx', [[MIXED_SECT]] + +;; ARM: # Symbol 4 +;; ARM-NEXT: $d +;; ARM-NEXT: 'st_value', 0x00000000 +;; ARM-NEXT: 'st_size', 0x00000000 +;; ARM-NEXT: 'st_bind', 0x0 +;; ARM-NEXT: 'st_type', 0x0 + +;; ARM: # Symbol 5 +;; ARM-NEXT: $d +;; ARM-NEXT: 'st_value', 0x00000030 +;; ARM-NEXT: 'st_size', 0x00000000 +;; ARM-NEXT: 'st_bind', 0x0 +;; ARM-NEXT: 'st_type', 0x0 +;; ARM-NEXT: 'st_other' +;; ARM-NEXT: 'st_shndx', [[MIXED_SECT]] + +;; ARM-NOT: ${{[atd]}} + +;; TMB: # Symbol 3 +;; TMB-NEXT: $d +;; TMB-NEXT: 'st_value', 0x00000016 +;; TMB-NEXT: 'st_size', 0x00000000 +;; TMB-NEXT: 'st_bind', 0x0 +;; TMB-NEXT: 'st_type', 0x0 +;; TMB-NEXT: 'st_other' +;; TMB-NEXT: 'st_shndx', [[MIXED_SECT:0x[0-9a-f]+]] + +;; TMB: # Symbol 4 +;; TMB-NEXT: $t +;; TMB-NEXT: 'st_value', 0x00000000 +;; TMB-NEXT: 'st_size', 0x00000000 +;; TMB-NEXT: 'st_bind', 0x0 +;; TMB-NEXT: 'st_type', 0x0 +;; TMB-NEXT: 'st_other' +;; TMB-NEXT: 'st_shndx', [[MIXED_SECT]] + +;; TMB: # Symbol 5 +;; TMB-NEXT: $t +;; TMB-NEXT: 'st_value', 0x00000036 +;; TMB-NEXT: 'st_size', 0x00000000 +;; TMB-NEXT: 'st_bind', 0x0 +;; TMB-NEXT: 'st_type', 0x0 +;; TMB-NEXT: 'st_other' +;; TMB-NEXT: 'st_shndx', [[MIXED_SECT]] + + +;; TMB-NOT: ${{[atd]}} + diff --git a/test/MC/ARM/elf-reloc-01.ll b/test/MC/ARM/elf-reloc-01.ll index c98026b..3ebd7c6 100644 --- a/test/MC/ARM/elf-reloc-01.ll +++ b/test/MC/ARM/elf-reloc-01.ll @@ -62,9 +62,9 @@ declare void @exit(i32) noreturn nounwind ;; OBJ: Relocation 1 ;; OBJ-NEXT: 'r_offset', -;; OBJ-NEXT: 'r_sym', 0x000002 +;; OBJ-NEXT: 'r_sym', 0x000007 ;; OBJ-NEXT: 'r_type', 0x2b -;; OBJ: Symbol 2 +;; OBJ: Symbol 7 ;; OBJ-NEXT: '_MergedGlobals' ;; OBJ-NEXT: 'st_value', 0x00000010 diff --git a/test/MC/ARM/elf-reloc-02.ll b/test/MC/ARM/elf-reloc-02.ll index e51bac3..6b6b03c 100644 --- a/test/MC/ARM/elf-reloc-02.ll +++ b/test/MC/ARM/elf-reloc-02.ll @@ -42,9 +42,9 @@ declare i32 @write(...) declare void @exit(i32) noreturn nounwind ;; OBJ: Relocation 0 -;; OBJ-NEXT: 'r_offset', -;; OBJ-NEXT: 'r_sym', 0x000002 +;; OBJ-NEXT: 'r_offset', +;; OBJ-NEXT: 'r_sym', 0x000005 ;; OBJ-NEXT: 'r_type', 0x2b -;; OBJ: Symbol 2 +;; OBJ: Symbol 5 ;; OBJ-NEXT: '.L.str' diff --git a/test/MC/ARM/elf-reloc-03.ll b/test/MC/ARM/elf-reloc-03.ll index 922242f..87f91c1 100644 --- a/test/MC/ARM/elf-reloc-03.ll +++ b/test/MC/ARM/elf-reloc-03.ll @@ -89,9 +89,9 @@ entry: declare void @exit(i32) noreturn nounwind ;; OBJ: Relocation 1 -;; OBJ-NEXT: 'r_offset', -;; OBJ-NEXT: 'r_sym', 0x00000c +;; OBJ-NEXT: 'r_offset', +;; OBJ-NEXT: 'r_sym', 0x000010 ;; OBJ-NEXT: 'r_type', 0x2b -;; OBJ: Symbol 12 +;; OBJ: Symbol 16 ;; OBJ-NEXT: 'vtable' diff --git a/test/MC/ARM/elf-reloc-condcall.s b/test/MC/ARM/elf-reloc-condcall.s index 08b4ecc..3fafb43 100644 --- a/test/MC/ARM/elf-reloc-condcall.s +++ b/test/MC/ARM/elf-reloc-condcall.s @@ -9,25 +9,25 @@ // OBJ: .rel.text // OBJ: 'r_offset', 0x00000000 -// OBJ-NEXT: 'r_sym', 0x000004 +// OBJ-NEXT: 'r_sym', 0x000005 // OBJ-NEXT: 'r_type', 0x1d // OBJ: 'r_offset', 0x00000004 -// OBJ-NEXT: 'r_sym', 0x000004 +// OBJ-NEXT: 'r_sym', 0x000005 // OBJ-NEXT: 'r_type', 0x1c // OBJ: 'r_offset', 0x00000008 -// OBJ-NEXT: 'r_sym', 0x000004 +// OBJ-NEXT: 'r_sym', 0x000005 // OBJ-NEXT: 'r_type', 0x1c // OBJ: 'r_offset', 0x0000000c -// OBJ-NEXT: 'r_sym', 0x000004 +// OBJ-NEXT: 'r_sym', 0x000005 // OBJ-NEXT: 'r_type', 0x1d // OBJ: 'r_offset', 0x00000010 -// OBJ-NEXT: 'r_sym', 0x000004 +// OBJ-NEXT: 'r_sym', 0x000005 // OBJ-NEXT: 'r_type', 0x1d // OBJ: .symtab -// OBJ: Symbol 4 +// OBJ: Symbol 5 // OBJ-NEXT: some_label diff --git a/test/MC/ARM/elf-thumbfunc-reloc.ll b/test/MC/ARM/elf-thumbfunc-reloc.ll index ecac11d..b2f253d 100644 --- a/test/MC/ARM/elf-thumbfunc-reloc.ll +++ b/test/MC/ARM/elf-thumbfunc-reloc.ll @@ -28,10 +28,10 @@ entry: ; 00000008 0000070a R_ARM_THM_CALL 00000001 foo ; CHECK: Relocation 0 ; CHECK-NEXT: 'r_offset', 0x00000008 -; CHECK-NEXT: 'r_sym', 0x000007 +; CHECK-NEXT: 'r_sym', 0x000009 ; CHECK-NEXT: 'r_type', 0x0a ; make sure foo is thumb function: bit 0 = 1 -; CHECK: Symbol 7 +; CHECK: Symbol 9 ; CHECK-NEXT: 'foo' ; CHECK-NEXT: 'st_value', 0x00000001 diff --git a/test/MC/ARM/elf-thumbfunc.s b/test/MC/ARM/elf-thumbfunc.s index 0aa7f41..91b2eee 100644 --- a/test/MC/ARM/elf-thumbfunc.s +++ b/test/MC/ARM/elf-thumbfunc.s @@ -12,7 +12,7 @@ foo: bx lr @@ make sure foo is thumb function: bit 0 = 1 (st_value) -@CHECK: Symbol 4 +@CHECK: Symbol 5 @CHECK-NEXT: 'st_name', 0x00000001 @CHECK-NEXT: 'st_value', 0x00000001 @CHECK-NEXT: 'st_size', 0x00000000 diff --git a/test/MC/ARM/mapping-within-section.s b/test/MC/ARM/mapping-within-section.s new file mode 100644 index 0000000..56dd6ef --- /dev/null +++ b/test/MC/ARM/mapping-within-section.s @@ -0,0 +1,33 @@ +@ RUN: llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s + + .text +@ $a at 0x0000 + add r0, r0, r0 +@ $d at 0x0004 + .word 42 + .thumb +@ $t at 0x0008 + adds r0, r0, r0 + adds r0, r0, r0 +@ $a at 0x000c + .arm + add r0, r0, r0 +@ $t at 0x0010 + .thumb + adds r0, r0, r0 +@ $d at 0x0012 + .ascii "012" + .byte 1 + .byte 2 + .byte 3 +@ $a at 0x0018 + .arm + add r0, r0, r0 + +@ CHECK: 00000000 .text 00000000 $a +@ CHECK-NEXT: 0000000c .text 00000000 $a +@ CHECK-NEXT: 00000018 .text 00000000 $a +@ CHECK-NEXT: 00000004 .text 00000000 $d +@ CHECK-NEXT: 00000012 .text 00000000 $d +@ CHECK-NEXT: 00000008 .text 00000000 $t +@ CHECK-NEXT: 00000010 .text 00000000 $t diff --git a/test/MC/ARM/multi-section-mapping.s b/test/MC/ARM/multi-section-mapping.s new file mode 100644 index 0000000..f7c4e89 --- /dev/null +++ b/test/MC/ARM/multi-section-mapping.s @@ -0,0 +1,35 @@ +@ RUN: llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s + + .text + add r0, r0, r0 + +@ .wibble should *not* inherit .text's mapping symbol. It's a completely different section. + .section .wibble + add r0, r0, r0 + +@ A section should be able to start with a $t + .section .starts_thumb + .thumb + adds r0, r0, r0 + +@ A setion should be able to start with a $d + .section .starts_data + .word 42 + +@ Changing back to .text should not emit a redundant $a + .text + .arm + add r0, r0, r0 + +@ With all those constraints, we want: +@ + .text to have $a at 0 and no others +@ + .wibble to have $a at 0 +@ + .starts_thumb to have $t at 0 +@ + .starts_data to have $d at 0 + +@ CHECK: 00000000 .text 00000000 $a +@ CHECK-NEXT: 00000000 .wibble 00000000 $a +@ CHECK-NEXT: 00000000 .starts_data 00000000 $d +@ CHECK-NEXT: 00000000 .starts_thumb 00000000 $t +@ CHECK-NOT: ${{[adt]}} + diff --git a/test/MC/ARM/relocated-mapping.s b/test/MC/ARM/relocated-mapping.s new file mode 100644 index 0000000..3bed14c --- /dev/null +++ b/test/MC/ARM/relocated-mapping.s @@ -0,0 +1,11 @@ +@ RUN: llvm-mc -triple=arm-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s + +@ Implementation-detail test (unfortunately): values that are relocated do not +@ go via MCStreamer::EmitBytes; make sure they still emit a mapping symbol. + add r0, r0, r0 + .word somewhere + add r0, r0, r0 + +@ CHECK: 00000000 .text 00000000 $a +@ CHECK-NEXT: 00000008 .text 00000000 $a +@ CHECK-NEXT: 00000004 .text 00000000 $d |