A R_REF relocation as a non-relocating reference is required to prevent garbage collection (by the binder) of the ref symbol in object generation.
shchenz DiggerLin hubert.reinterpretcast stephenpeckham
- Group Reviewers
- rG49dcd08c3d96: [XCOFF] support the ref directive for object generation.
This would be very strange directly calling to XCOFFObjectWriter and skipping the abstract MC layer. For example, with this implementation I think you can not get the MCFixups for the refs in the MCAssembler dumping?
Is it possible to just create a MCFixup here and use existing logic to handle the relocations? With this method I think you don't need the std::vector<std::pair<const MCSymbol *, const MCFragment *>> RefSymbolInfo in the XCOFFObjectWriter.cpp, the MCFixups should all be attached to the MCFragment of the MCSection.
We also need a case that has R_REF relocation for .text section.
The fixup_ppc_nofixup is defined in llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h, and it looks inappropriate to include that in llvm/lib/MC?
yes, I think you would need an interface in class MCAsmBackend and override this interface in class XCOFFPPCAsmBackend. FK_NONE is not a good choice, it is for relocation types that are defined in targets and bigger FirstLiteralRelocationKind(Although now PPC does not have any fixup kind bigger than FirstLiteralRelocationKind, but we really should not break this common design.). See PPCAsmBackend::getFixupKindInfo().
Looks good to me except one nit.
nit: although we don't have user for other fixup kinds, for functionality complete, could we add other cases as well? This is what other targets do.
I don't really agree with adding other cases that are not used in this patch, because we will neither assurance its features for these cases nor test them.