[PATCH] D79311: [lld-macho] Support X86_64_RELOC_SIGNED_{1,2,4}

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 13:26:51 PDT 2020


int3 added a comment.

Thanks for putting this up!

> See the comment in lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp RecordX86_64Relocation.

The comment there confuses me a little:

  // The Darwin x86_64 relocation format has a problem where it cannot
  // encode an address (L<foo> + <constant>) which is outside the atom
  // containing L<foo>. Generally, this shouldn't occur but it does
  // happen when we have a RIPrel instruction with data following the
  // relocation entry (e.g., movb $012, L0(%rip)). Even with the PCrel
  // adjustment Darwin x86_64 uses, the offset is still negative and the
  // linker has no way to recognize this.

It says "the linker has no way to recognize this", but it appears that the implicit addend already allows the linker to recognize it. Any idea why it also needs a special relocation type? Is it redundant / a mistake in the implementation? ("However, the specification or implementation of this seems to be incomplete..." seems to indicate that I guess.)



================
Comment at: lld/test/MachO/x86-64-reloc-signed.s:17
+_main:
+  movl $0x434241, _s(%rip)  # X86_64_RELOC_SIGNED4
+  callq _f
----------------
nit: X86_64_RELOC_SIGNED_4 (missing underscore)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79311/new/

https://reviews.llvm.org/D79311





More information about the llvm-commits mailing list