This is an archive of the discontinued LLVM Phabricator instance.

[MC] Support relocation offset of sym+constant form for PendingFixup
ClosedPublic

Authored by StephenFan on Jan 14 2022, 7:16 AM.

Details

Summary

This patch add support relocation offset of sym+constant(like foo+4) form for pending fixup.

In the past, llvm-mc ignored the constant in sym+constant form, for foo+4, 4 would be ignored. And test case

.text
  ret
  nop
  nop
  .reloc foo+4, R_RISCV_32, 6

.data
.globl foo
foo:
  .word 0
  .word 0
  .word 0

when run llvm-mc -filetype=obj -triple=riscv64 %s | llvm-readobj -r
The output is

Relocations [
  Section (3) .rela.text {
    0x0 R_RISCV_32 - 0x6
  }
]

After applying this patch, the output is

Relocations [
  Section (3) .rela.text {
    0x4 R_RISCV_32 - 0x6
  }
]

Diff Detail

Event Timeline

StephenFan created this revision.Jan 14 2022, 7:16 AM
StephenFan requested review of this revision.Jan 14 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2022, 7:16 AM
StephenFan retitled this revision from [MC] Support constant offset for symbol PendingFixup to [MC] Support relocation offset of sym+constant form for PendingFixup.Jan 14 2022, 7:17 AM
This revision is now accepted and ready to land.Jan 20 2022, 4:14 AM
This revision was automatically updated to reflect the committed changes.