Page MenuHomePhabricator

[MC] Put the pending fixups into relocation offset symbol's fragment
ClosedPublic

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

Details

Summary

For .reloc directive, if the relocation offset is a symbol, then the relocation entry should be placed into relocation section and its sh_info should point to the section where relocation offset symbol at.

Test case:

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

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

The relocation entry should be placed into .reloc.data. And it is also what gnu as does.

Diff Detail

Event Timeline

StephenFan created this revision.Jan 14 2022, 7:23 AM
StephenFan requested review of this revision.Jan 14 2022, 7:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2022, 7:23 AM
StephenFan retitled this revision from [MC] Put the Pending Fixups into location symbol's fragment to [MC] Put the pending fixups into relocation offset symbol's fragment.Jan 14 2022, 7:29 AM
StephenFan edited the summary of this revision. (Show Details)
StephenFan edited the summary of this revision. (Show Details)
MaskRay added inline comments.Jan 14 2022, 9:36 PM
llvm/lib/MC/MCObjectStreamer.cpp
131

Several cases are not covered by tests. They need tests.

llvm/test/MC/RISCV/reloc-directive.s
26

Add tests for FT_Dwarf and FT_PseudoProbe.

StephenFan marked an inline comment as done.Jan 19 2022, 1:25 AM
StephenFan added inline comments.
llvm/lib/MC/MCObjectStreamer.cpp
129

Hi @MaskRay , The test case of FT_Relaxable is not added. Because I don't know how to define a symbol which its fragment is FT_Relaxable. Do you have some ideas ?

137

I found that FT_CVDefRange is only used by COFF. Does COFF support .reloc directive?

MaskRay accepted this revision.Jan 19 2022, 7:56 PM

LGTM.

llvm/test/MC/RISCV/reloc-directive.s
34
# CHECK:      Section ({{.*}}) .rela.pseudoprobe {
# CHECK-NEXT:   0x0 R_RISCV_32 - 0x6
# CHECK-NEXT: }
This revision is now accepted and ready to land.Jan 19 2022, 7:56 PM
StephenFan marked an inline comment as done.Jan 25 2022, 7:24 PM