This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support .reloc *, R_{386,X86_64}_NONE, *

Authored by MaskRay on May 16 2019, 9:27 AM.



This can be used to create references among sections. When --gc-sections
is used, the referenced section will be retained if the origin section
is retained.

See R_MIPS_NONE (D13659), R_ARM_NONE (D61992), R_AARCH64_NONE (D61973) for similar changes.

Diff Detail


Event Timeline

MaskRay created this revision.May 16 2019, 9:27 AM
rnk accepted this revision.May 16 2019, 12:50 PM


This morning I didn't know why this was interesting, but then @inglorion told me about the new .init_array + reloc-none GC sections strategy. I still have concerns about dropping debug info as LLD is doing now, but I'll pass them along separately.

This revision is now accepted and ready to land.May 16 2019, 12:50 PM
pcc added inline comments.May 16 2019, 12:55 PM
17 ↗(On Diff #199848)

The comment isn't accurate.

Should this be a generic fixup kind (i.e. MCFixupKind)? It seems that both ELF and COFF support it on all targets.

MaskRay marked an inline comment as done.May 16 2019, 6:50 PM

.init_array+R_*_NONE is a missed optimization in linkers (ld.bfd+gold+lld) but I'm not sure how useful it is. It may break semantics and I think usually it indicates real bugs, see PR41693 for a recent issue.

This is interesting as I want Android guys to use a better workaround than the current PT_TLS hack in lld ELF ARM/AArch64. (

@pcc told me this trick long ago and mentioned .reloc is not supported in llvm:) The trick is also mentioned on

The R_386_NONE support can be used to add tests for a bug in lld that I want to fix

17 ↗(On Diff #199848)

Thanks for pointing this out.

I'll add a generic fixup in the ARM patch D61992.

MaskRay updated this revision to Diff 199967.May 16 2019, 8:13 PM
MaskRay edited the summary of this revision. (Show Details)

Use generic FK_NONE

This revision was automatically updated to reflect the committed changes.