llvm-mirror/test/MC/COFF/diff.s
Rafael Espindola 1b06c08409 Change creation of relative relocations on COFF.
For whatever reason, when processing

  .globl foo
foo:
  .data
bar:
  .long foo-bar

llvm-mc creates a relocation with the section:

0x0 IMAGE_REL_I386_REL32 .text

This is different than when the relocation is relative from the
beginning. For example, a file with

call foo

produces

0x0 IMAGE_REL_I386_REL32 foo

I would like to refactor the logic for converting "foo - ." into a
relative relocation so that it is shared with ELF. This is the first
step and just changes the coff implementation to match what ELF (and
COFF in the case of calls) does.

llvm-svn: 306063
2017-06-22 21:57:04 +00:00

58 lines
1.1 KiB
ArmAsm

// RUN: llvm-mc -filetype=obj -triple i686-pc-mingw32 %s | llvm-readobj -s -sr -sd | FileCheck %s
.section baz, "xr"
.def X
.scl 2;
.type 32;
.endef
.globl X
X:
mov Y-X+42, %eax
retl
.def Y
.scl 2;
.type 32;
.endef
.globl Y
Y:
retl
.def _foobar;
.scl 2;
.type 32;
.endef
.text
.long 0
.globl _foobar
.align 16, 0x90
_foobar: # @foobar
# BB#0:
ret
.data
.globl _rust_crate # @rust_crate
.align 4
_rust_crate:
.long 0
.long _foobar
.long _foobar-_rust_crate
.long _foobar-_rust_crate
// CHECK: Name: .data
// CHECK: Relocations [
// CHECK-NEXT: 0x4 IMAGE_REL_I386_DIR32 _foobar
// CHECK-NEXT: 0x8 IMAGE_REL_I386_REL32 _foobar
// CHECK-NEXT: 0xC IMAGE_REL_I386_REL32 _foobar
// CHECK-NEXT: ]
// CHECK: SectionData (
// CHECK-NEXT: 0000: 00000000 00000000 0C000000 10000000
// CHECK-NEXT: )
// CHECK: Name: baz
// CHECK: Relocations [
// CHECK-NEXT: ]
// CHECK: SectionData (
// CHECK-NEXT: 0000: A1300000 00C3C3
// CHECK-NEXT: )